Per-host MTU – in NetworkManager and in Github Actions
For some reason, my home Internet connection stopped receiving large packets. This could be something with PMTU discovery blocks on the ISP side, or it could be something that I changed. An automated job which uploaded files using SSH (to be exact: scp) to my home stopped working. The failure was a time-out after the authentication phase.
This job is happening as part of Github Actions flow, and it worked well until recently. I did not pursue a solution with the ISP at this stage, but I needed to solve it. It means that I need to configure the pipeline container which runs the upload action to have MTU matching my home MRU. I cannot control the entire Internet, unfortunately, but at least – that I can do.
To do so – add the following commands to your pipeline
BACKUP_IP=${MY_TARGET_IP} # An IP address of the target upload server
GW=$( ip route list default | awk '{print $3}' )
sudo ip route add ${BACKUP_IP}/32 via ${GW} mtu 1492
Replace MTU value 1492 (PPPoE) with a value matching the destination server MRU.
During my tests, I verified the issue from an external Linux server I already manage. There, I was able to pinpoint the issue there. The ‘ip route’ command from above works just the same. I did want, however, to make sure that the routing was set on any network interface restart.
The easiest way was to add a NetworkManager profile value, which I did:
nmcli c m enX0 +ipv4.routes "${DEST_IP}/32 ${GW} mtu=1492"
Replace the values of the network interface card with the profile (connection) name. Set IP address as the DEST_IP and the current router address as GW. Also – if required – set the MTU to be of the value
It results in a persistent per-host MTU settings across network interface restart or system reboot.
Unfortunately, it works only with a static IP address, and will not do for a dynamic DNS name. For that – you should use a dispatch script which will be triggered on network interface up action. You should also add a scheduled task for refreshing the route once a while.
