After having spent now hours troubleshooting, trawling potential solutions on this site and others, and I am resigned to beg the advice of my betters. I am working to route all network traffic on an instance of Ubuntu over a Cisco VPN at a university. Using either the built in network manager or vpnc, I can successfully establish a connection to the VPN, and can successfully route traffic to any university IP over the VPN. However, aside of those specific IP ranges, I cannot seem to conjure any route which will successfully map all network traffic over the VPN.

So far, I've attempted:

route add -net gw homeportal dev tun0
route add -net tun0
route add -net gw dev tun0
route add -net gw dev eth0
iptables -A FORWARD -o tun0 -j ACCEPT
iptables -A FORWARD -i tun0 -j ACCEPT
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE

And many other silly, ineffective, things that I cannot remember well enough to transcribe accurately.

In addition, I've tried routing smaller IP ranges, and specific IPs, each to no avail. I'm not really sure what's going wrong, as the extent of the effects I've been able to observe are failures of name resolution, and failures to route traffic over the VPN. What am I doing wrong here?


Here is the output of ip route show after starting the VPN connection with VPNC:

default via dev eth0  proto static dev tun0  scope link dev tun0  scope link dev tun0  scope link via dev eth0  src dev tun0  scope link dev tun0  scope link dev tun0  scope link dev tun0  scope link dev eth0  proto kernel  scope link  src  metric 1 dev tun0  scope link dev tun0  scope link dev tun0  scope link dev tun0  scope link dev tun0  scope link dev tun0  scope link dev tun0  scope link dev tun0  scope link

More information-

I've successfully routed arbitrary traffic over this VPN in MS Windows via the Cisco AnyConnect client with default configuration. Here is what the routing table looks like when the AnyConnect client is working (this is a different computer behind the same router at

IPv4 Route Table
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
     30      2      2         On-link    306         On-link    306         On-link    306      2     31      2      2         On-link    286         On-link    286         On-link     31         On-link    286         On-link    276         On-link    276         On-link    276         On-link    257         On-link    257         On-link    257         On-link    276         On-link    276         On-link    276      2      2      2      2      2      2      2      2         On-link    306         On-link    286         On-link    276         On-link    276         On-link  10000         On-link    306         On-link    286         On-link    276         On-link    276         On-link  10000
  • I imagine that it will be clear that network routing is quite new to me, so I would appreciate a fairly high level of verbosity in answers.
    – deftfyodor
    Aug 10, 2014 at 8:43
  • 1
    It would be helpful if you could state whether you are using any client (anyconnect?), and if you could post your routing table, thank you. Aug 10, 2014 at 9:32
  • Do so using ip route, by the way. Aug 10, 2014 at 9:35
  • 2
    Yes, please do not use obsolete routing commands: use ip route show for the routing table. Obsolete commands hide some of the complexities which are possible and helpful also with VPNs, let alone VLANs,... Aug 10, 2014 at 9:38
  • @grawity, @MariusMatutiae - Sure thing, I've edited the question with the command output. Thanks for mentioning the ip route command, I hadn't run across it before.
    – deftfyodor
    Aug 10, 2014 at 9:45

2 Answers 2


Your local network is, as shown by this line in your routing table: dev eth0  proto kernel  scope link  src  metric 1

Your VPN network is, as shown by this line: dev tun0  scope link 

Currently, your default router is:

 default via dev eth0  proto static 

which is of course what you do not want, because it belongs to your local LAN: thus all of your stuff is routed through your local gateway, as if the VPN did not exist.

 You do have however, the all-important statement via dev eth0  src  

which is the route to your VPN-provider.


I had not realized that the routing table is simply the one that is obtained from your VPN, without your intervention. This may indicate (indirectly) that your service provider is willing to forward only the traffic explicitly allowed in your table through the interface tun0, and may have taken further steps to block all other traffic, in which case your efforts will be futile.

However, assuming that your provider is willing to forward all of your traffic, what you need to do is the following.

First, you need to find out whether there is a gateway willing to accept your connection on the other side, because we need its IP address. I will give you four methods to do this.

1) With the pc connected to the VPN, try the following command:

   sudo dhclient -v tun0

If everything goes well, you should see a reply containing this line:

 DHCPOFFER of a.b.c.d from x.y.w.z

x.y.w.z is the IP address of the local gateway. You may have to shutdown your VPN after this test, and maybe even to reboot your pc, because we will have just messed up the routing table pretty well.

2) Alternatively, you may try navigating to one of the allowed sites (those that appear in your routing table as going through the tun0 interface), then issuing the command:

  ip neigh show

You should get a list of pcs contacted through the ARP protocol, with MAC and IP address; most likely, you will receive either zero or one reply. If you get a single reply, then that's your router.

3) If you get no such reply, then you may try with

  sudo nmap -sn

(which is going to be very slow). Your gateway will be one of the pcs listed, most likely the one with address ending in .1 or in .254, if any such exist.

4) Use the tcpdump command:

  sudo tcpdump -n -i tun0

and see the IP addresses spewed out by the command.

If you get no proper reply to this test either, it means someone has really tightened the screws in his network.

But let us be optimistic, and suppose you now have a candidate IP address x.w.y.z for the remote router. You will need to delete the default gateway, (as sudo!):

  ip route del default via

an add the new one:

  ip route add default via x.w.y.z 

and try to navigate.

Let me repeat: since your provider has allowed traffic only to a few selected IP addresses through his VPN, it is possible he may have taken extra measures (=firewall) to prevent a smart user to force his generic traffic through his VPN. In this case, there is nothing you can do. But if he did not, the above steps should help you find a solution.

  • Thank you for the very elaborate reply, however entering the second half, I experience a bit of a hiccough. the output of ip addr show dev tun0 reads 10: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1412 qdisc pfifo_fast state UNKNOWN group default qlen 500 link/none inet brd scope global tun0 valid_lft forever preferred_lft forever, with no peer address to be observed. In addition, the routing table I posted earlier had not been modified by me at all- it was generated entirely by the vpn client.
    – deftfyodor
    Aug 10, 2014 at 18:05
  • @deftfyodor Please see my edit. Aug 11, 2014 at 6:49
  • Using the tcpdump command, I was indeed able to discern the gateway, and route default traffic to it. Unfortunately, it still only works for the specifically provisioned IP ranges. I'm certainly inclined to believe that there is some additional security measure in place- however I have no problem at all routing arbitrary traffic over the same VPN in MS Windows using the AnyConnect client- so there must surely be more to the story.
    – deftfyodor
    Aug 11, 2014 at 19:39
  • @deftfyodor Can you check whether your routing table in Windos is different from that in Linux? Aug 11, 2014 at 19:53
  • It is generally similar, though there are some elements which differ- in particular, is set to route via my network router as the gateway, holding the VPN gateway as the interface. I've edited the question to show the Windows routing table.
    – deftfyodor
    Aug 11, 2014 at 20:02

All of your route commands are missing netmasks, so they only match the specific address, not the entire internet. So replace with in the first command you tried:

ip route add -net gw homeportal dev tun0

There may be one caveat which I'm not sure if your VPN client solves by itself: the tunnel endpoint needs to be excluded from being routed via the VPN, it has to be routed via your eth0 interface. So if adding this default route breaks your VPN, add a specific route for your VPN endpoint:

ip route add <ENDPOINT>/32 dev eth0

  • 2
    I think the second one is supposed to be ip route, no? Also, while it's always a good idea to add netmasks, it seems that route assumes /0 when adding Aug 10, 2014 at 10:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .