Add MTU config setting

This commit is contained in:
Paul-Christian Volkmer 2022-12-10 10:31:26 +01:00
parent 0957eda443
commit 1d945f7ffb
3 changed files with 29 additions and 3 deletions

View File

@ -23,10 +23,11 @@ $ docker-compose build
Customize the file `docker-compose`. You can change the following environment variables as needed
* `DEVICE`: Some `tun` device, e.g. `tun0`
* `DEVICE`: Some `tun` device, defaults to `tun0`
* `SERVER_HOST`: The host name of your server
* `SERVER_PORT`: The port the service should listen at
* `NETWORK`: Some custom /24 network. e.g. `192.168.42.0`
* `NETWORK`: Some custom /24 network. Defaults to `192.168.42.0`
* `MTU`: MTU to be used. Use default wireguard MTU if not set.
* `CLIENTS`: Number of clients for which configurations are to be created. Do not use more than 240 clients.
* `DISABLE_FORWARD_ALL_TRAFFIC`: Use `true` or `yes` to not add iptables rules and do not forward all traffic.
@ -45,8 +46,9 @@ wg_1 | - Writing config to file tun0.conf
wg_1 | - Using endpoint hostname example.com
wg_1 | - Using port 51820
wg_1 | - Using network 192.168.42.0/24
wg_1 | - Generating 5 client configs and client QR codes
wg_1 | - Using default MTU
wg_1 | - Forward all traffic
wg_1 | - Generating 5 client configs and client QR codes
wireguard_wg_1 exited with code 0
```

View File

@ -39,6 +39,13 @@ cat <<EOF > $DEVICE-client_$CLIENT_ID.conf
Address = $NETWORK.$(($CLIENT_ID+10))/24
ListenPort = $SERVER_PORT
PrivateKey = ${CLIENT_SEC_KEY}
EOF
if [ $MTU ]; then
echo "MTU = $MTU" >> $DEVICE-client_$CLIENT_ID.conf
fi
cat <<EOF >> $DEVICE-client_$CLIENT_ID.conf
[Peer]
PublicKey = $SERVER_PUB_KEY

View File

@ -30,6 +30,12 @@ else
fi
echo " - Using network $NETWORK.0/24"
if [[ -z $MTU ]]; then
echo " - Using default MTU"
else
echo " - Using MTU: $MTU"
fi
if [ "$DISABLE_FORWARD_ALL_TRAFFIC" != "true" ] && [ "$DISABLE_FORWARD_ALL_TRAFFIC" != "yes" ]; then
echo " - Forward all traffic"
else
@ -66,6 +72,10 @@ ListenPort = $SERVER_PORT
PrivateKey = $SERVER_SEC_KEY
EOF
if [ $MTU ]; then
echo "MTU = $MTU" >> $DEVICE.conf
fi
if [ "$DISABLE_FORWARD_ALL_TRAFFIC" != "true" ] && [ "$DISABLE_FORWARD_ALL_TRAFFIC" != "yes" ]; then
cat <<EOF >> $DEVICE.conf
@ -102,6 +112,13 @@ cat <<EOF >> $DEVICE-client_$i.conf
Address = $NETWORK.$(($i+10))/24
ListenPort = $SERVER_PORT
PrivateKey = ${CLIENT_SEC_KEYS[$i]}
EOF
if [ $MTU ]; then
echo "MTU = $MTU" >> $DEVICE-client_$i.conf
fi
cat <<EOF >> $DEVICE-client_$i.conf
[Peer]
PublicKey = $SERVER_PUB_KEY