Skip to content

Commit

Permalink
Add MTU configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
conradgg committed May 19, 2024
1 parent 006e8c1 commit e7ce129
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions wireguard-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ function installQuestions() {
read -rp "Server WireGuard port [1-65535]: " -e -i "${RANDOM_PORT}" SERVER_PORT
done

# Set MTU for the server and the clients
until [[ ${SERVER_MTU} =~ ^[0-9]+$ ]] && [ "${SERVER_MTU}" -ge 1200 ] && [ "${SERVER_MTU}" -le 1500 ]; do
read -rp "Server MTU [1200-1500]: " -e -i 1420 SERVER_MTU
done

until [[ ${CLIENT_MTU} =~ ^[0-9]+$ ]] && [ "${CLIENT_MTU}" -ge 1200 ] && [ "${CLIENT_MTU}" -le 1500 ]; do
read -rp "Client MTU [1200-1500]: " -e -i 1420 CLIENT_MTU
done

# Adguard DNS by default
until [[ ${CLIENT_DNS_1} =~ ^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ ]]; do
read -rp "First DNS resolver to use for the clients: " -e -i 1.1.1.1 CLIENT_DNS_1
Expand Down Expand Up @@ -221,13 +230,15 @@ SERVER_PRIV_KEY=${SERVER_PRIV_KEY}
SERVER_PUB_KEY=${SERVER_PUB_KEY}
CLIENT_DNS_1=${CLIENT_DNS_1}
CLIENT_DNS_2=${CLIENT_DNS_2}
ALLOWED_IPS=${ALLOWED_IPS}" >/etc/wireguard/params
ALLOWED_IPS=${ALLOWED_IPS}
CLIENT_MTU=${CLIENT_MTU}" >/etc/wireguard/params
# Add server interface
echo "[Interface]
Address = ${SERVER_WG_IPV4}/24,${SERVER_WG_IPV6}/64
ListenPort = ${SERVER_PORT}
PrivateKey = ${SERVER_PRIV_KEY}" >"/etc/wireguard/${SERVER_WG_NIC}.conf"
PrivateKey = ${SERVER_PRIV_KEY}
MTU = ${SERVER_MTU}" >"/etc/wireguard/${SERVER_WG_NIC}.conf"
if pgrep firewalld; then
FIREWALLD_IPV4_ADDRESS=$(echo "${SERVER_WG_IPV4}" | cut -d"." -f1-3)".0"
Expand Down Expand Up @@ -353,6 +364,7 @@ function newClient() {
PrivateKey = ${CLIENT_PRIV_KEY}
Address = ${CLIENT_WG_IPV4}/32,${CLIENT_WG_IPV6}/128
DNS = ${CLIENT_DNS_1},${CLIENT_DNS_2}
MTU = ${CLIENT_MTU}
[Peer]
PublicKey = ${SERVER_PUB_KEY}
Expand Down

0 comments on commit e7ce129

Please sign in to comment.