Thursday, May 30, 2013

Exciting new puzzles! Brought to you by vpnc!

I wanted to connect to my employer's VPN, so I typed "vpnc" with the usual parameters. After entering my password (etc), my computer claimed to be connected, but I couldn't resolve any hostnames. Huh? I typed "vpnc-disconnect" (as root), and was told
no vpnc found running
Harrumpf. So I restored /etc/resolv.conf (vpnc puts some rfc1918 addresses in there, which is what my company's intranet uses for DNS), and tried to run vpnc again.

No joy: it couldn't find the IP address of my company. In fact, nothing outside the house was reachable. Why not?

collin@p3:~> netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
xxx.yyy.zz.ww   192.168.1.254   255.255.255.255 UGH    1500 0          0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U         0 0          0 lo
collin@p3:~>
(xxx.yyy.zz.ww is my company's vpn gateway). Well, there's no default route, for one thing! So I tried this:
collin@p3:~> sudo route add default 192.168.1.254
SIOCADDRT: No such device
Gaaa... it's been too long since I typed that string. What's the incantation required?
collin@p3:~> man route
ROUTE(8)                   Linux Programmer's Manual                  ROUTE(8)



NAME
       route - show / manipulate the IP routing table

SYNOPSIS
       route [-CFvnee]

       route  [-v]  [-A  family]  add [-net|-host] target [netmask Nm] [gw Gw]
              [metric N] [mss M] [window W]  [irtt  I]  [reject]  [mod]  [dyn]
              [reinstate] [[dev] If]
…
OK, that gave me the needed clue; I was missing the magic word gw, so I typed:
collin@p3:/mnt/home/collin> sudo route add default gw 192.168.1.254
and voilà, everyting started working!
collin@p3:/mnt/home/collin> netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U         0 0          0 lo
0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 eth0
collin@p3:/mnt/home/collin>
The default route (in yellow) appeared, and I could do everything I needed.

Why did vpnc hose my routing table then abort? I don't know; I suppose this old IBM lease-return has some hardware problems. But they only affect me once in a while, so since it ain't totally broken, I won't replace it.

No comments: