diff --git a/wireguard-install.sh b/wireguard-install.sh index dc72b7ec..66623849 100644 --- a/wireguard-install.sh +++ b/wireguard-install.sh @@ -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 @@ -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" @@ -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}