diff --git a/10-monitor-ppp-mtu.sh b/10-monitor-ppp-mtu.sh old mode 100644 new mode 100755 diff --git a/11-change-ppp-mtu-debug.sh b/11-change-ppp-mtu-debug.sh old mode 100644 new mode 100755 index 329db15..670acc2 --- a/11-change-ppp-mtu-debug.sh +++ b/11-change-ppp-mtu-debug.sh @@ -5,6 +5,7 @@ MINTERFACES="(ppp0)" # Desired MTU of PPP interfaces PTARGET=1500 +SET_MSS=FALSE runningmtu=0 restartpppd=0 @@ -82,6 +83,22 @@ while true; do fi fi done + + if [[ $SET_MSS ]]; then + echo "Checking if iptables MSS Value needs to be updated" + currentMSS=$(iptables -L -t mangle --line-numbers | grep -m 1 'SYN,RST/SYN TCPMSS' | sed 's/.*set \([0-9]\{4\}\).*/\1/') + targetMSS=$(($PTARGET-40)) + if [[ $currentMSS -ne $targetMSS ]]; then + echo "Updating MSS from $currentMSS to $targetMSS" + while [[ $(iptables -L -t mangle --line-numbers | grep 'SYN,RST/SYN TCPMSS') ]]; do + iptables -t mangle -D UBIOS_FORWARD_TCPMSS 1 + done + iptables -t mangle -A UBIOS_FORWARD_TCPMSS -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss $targetMSS + else + echo "iptables already has correct MSS Value" + fi + fi + if [[ $restartpppd == 1 ]]; then echo Killing pppd killall -SIGHUP pppd diff --git a/11-change-ppp-mtu.sh b/11-change-ppp-mtu.sh old mode 100644 new mode 100755 index 28c489f..ae03db8 --- a/11-change-ppp-mtu.sh +++ b/11-change-ppp-mtu.sh @@ -5,6 +5,7 @@ MINTERFACES="(ppp0)" # Desired MTU of PPP interfaces PTARGET=1500 +SET_MSS=false function check_mtu { ip link list | grep -E $MINTERFACES | grep 'mtu '$PTARGET > /dev/null @@ -54,6 +55,20 @@ while true; do ip link set $pinterface mtu $PTARGET fi done + + if [[ $SET_MSS ]]; then + echo "Checking if iptables MSS Value needs to be updated" + currentMSS=$(iptables -L -t mangle --line-numbers | grep -m 1 'SYN,RST/SYN TCPMSS' | sed 's/.*set \([0-9]\{4\}\).*/\1/') + targetMSS=$(($PTARGET-40)) + if [[ $currentMSS -ne $targetMSS ]]; then + echo "Updating MSS from $currentMSS to $targetMSS" + while [[ $(iptables -L -t mangle --line-numbers | grep 'SYN,RST/SYN TCPMSS') ]]; do + iptables -t mangle -D UBIOS_FORWARD_TCPMSS 1 + done + iptables -t mangle -A UBIOS_FORWARD_TCPMSS -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss $targetMSS + fi + fi + # Kill pppd to apply changes (it gets restarted automatically) # This does take down existing ppp links but as pppd comes straight back up, so should the links # Only kill pppd if there are ppp interfaces active and changes were made