Featured Post

Linux daemon using Python daemon with PID file and logging

The python-daemon package ( PyPI listing , Pagure repo ) is very useful. However, I feel it has suffered a bit from sparse documentation, an...

2011-05-18

Modifying MTU to prevent sftp from stalling

I have Ubuntu 11.04 Natty on my laptop, now, and it almost always stalls when trying to download a file via sftp while on wifi with the VPN on. Turns out, modifying the MTU (maximum transmission unit) on the wifi fixes the problem. The default value is 1500, but apparently, the VPN protocol adds overhead which reduces the effective size. On my laptop, the VPN tunnel virtual device has an MTU of 1412.

        tun0  Link encap:UNSPEC  HWaddr ... 
        inet addr:xxx.xx.xx.xxx  P-t-P:xxx.xx.xx.xxx  Mask:255.255.255.248
        UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1412  Metric:1
        RX packets:92323 errors:0 dropped:0 overruns:0 frame:0
        TX packets:61094 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:500
        RX bytes:119168710 (119.1 MB)  TX bytes:4994871 (4.9 MB)

So, what I did was change the MTU of the wifi device wlan0 to 1412:

        sudo ifconfig wlan0 mtu 1412