Thursday, May 23, 2013

PPTP VPN Fails Frequently?

I have upped my Ubuntu to Raring Ringtail 13.04. Everything was just awesome. I set up my workspace. Now, it was the time to code. Woohoo! Connected to PPTP VPN to checkout code.  While I was checking out the code, VPN disconnected. Then on, each time I connect to VPN, it gets disconnected in a minute or so. Never stayed long enough to do something useful. When I switched from ethernet to another broadbad wi-fi, PPTP was stable. So, there was something wrong with my ethernet setting.

After a lot of head banging and, hit and trial, I landed on this post on a forum. It was not very encouraging, plus it was really old. I gave it a try anyway and voilĂ ! it worked! The trick is to lower MTU value. MTU is maximum transmission unit, to quote Wikipedia:
In computer networking, the maximum transmission unit (MTU) of a communications protocol of a layer is the size (in bytes) of the largest protocol data unit that the layer can pass onwards. MTU parameters usually appear in association with a communications interface (NIC, serial port, etc.). Standards (Ethernet, for example) can fix the size of an MTU; or systems (such as point-to-point serial links) may decide MTU at connect time.
 I have set MTU to 1200 down from 1500. Using sudo ifconfig eth0 mtu 1200 command in Ubuntu.
#Before
$ sudo ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:24:d8:d8:32:09
          inet addr:192.168.1.33  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: feff::224:e8ff:fe88:3209/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:142813 errors:0 dropped:0 overruns:0 frame:0
          TX packets:97325 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:174397037 (174.3 MB)  TX bytes:8177616 (8.1 MB)

#Execute command
$ sudo ifconfig eth0 mtu 1200

#After (successfully connected to VPN and stable)
$ sudo ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:24:d8:d8:32:09
          inet addr:192.168.1.33  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1200  Metric:1
          RX packets:142851 errors:0 dropped:0 overruns:0 frame:0
          TX packets:97372 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:174401881 (174.4 MB)  TX bytes:8184649 (8.1 MB)