I have a VPN server hosted on Windows 2019 and configured on IKEv2, Everything works very well from all clients, however on Linux clients I have one last point to adjust, so for clarification I use the following script positioned in the dispatcher to adjust the MTU and add the necessary routes (which was not necessary in the case where the connection is L2TP):
#!/bin/bash
set -xv
DEFAULT_MTU=1500
MTU=1400
INTERFACE=$(ip route | grep -v linkdown | awk '$1 == "default" {if (!min || $5 < min) {min=$5; iface=$5}} END {print iface}')
if [[ ! "$1" =~ ^nm-xfrm-.* ]] && [[ ! "$1" =~ tun.* ]]; then
echo "$1 is not a vpn interface. Exit script"
exit 0
fi
if [ ! -d /sys/class/net/tun0 ]; then
for itf in $(ls /sys/class/net/ | grep -E -v '^(lo|ppp0)$' ); do
sudo ip link set dev "$itf" mtu "$DEFAULT_MTU"
done
fi
case "$2" in
up|vpn-up)
ip link set dev "$INTERFACE" mtu "$MTU"
ip link set dev $1 mtu "$MTU"
ip route add to default dev $1 proto static scope link metric 50
ip route add to XX.XX.XX.XX/XX dev $1 proto static scope link metric 50 table 220
;;
down|vpn-down)
for itf in $(ls /sys/class/net/ | grep -E -v '^(lo|ppp0)$' ); do
ip link set dev "$itf" mtu "$DEFAULT_MTU"
done
;;
*)
exit 0
;;
esac
I use routing table 220 for docker machine.
And it turns out that if I connect via wifi everything works fine, access to websites via browser and via curl goes well, however as soon as I connect an USB-C adapter with an ethernet port some sites no longer respond.
I thought it was an MTU problem initially, but I'm wondering if there isn't something else causing the problem, or maybe it's not possible.
I specify that I use the strongswan package with NetworkManager.