Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MTU configuration options #3

Merged
merged 2 commits into from
May 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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