Overlapping Static Routes

Do you have to connect to a VPN in order to work? Do you need to connect to more than one VPN to work? Have you ever connected to a VPN that broke your Internet connection? VPNs are great, but static routes and DNS servers can really ruin your day sometimes. Recently, I had to connect to my work’s corporate VPN and from there had to connect to a separate internal VPN to access an environment I was working on (don’t ask). While connecting to multiple VPNs in and of itself is not an issue in my case I quickly learned that I did not have the connectivity I needed to access the environment through the second VPN.

What was happening and how can you fix it?

A VPN connects you to one or more private networks over a secure tunnel. Typically, VPNs push static routes to your local computer so your computer knows how to get to these new networks. The most common issue with static routes is when a static route overlaps with an existing static route on your local computer. It is easier to highlight this point through an example:

In the above example you can see static routes defined on my local system specific to the 172.16 network. The first output represents a static route over a TUN interface and was the route I needed to access the environment I mentioned above. The second output represents a static route over a Juniper interface and was specific to my corporate connection. As you can see there is some overlap between the two static routes. So which one wins? The easiest way to check is to run a traceroute to a host in the overlapping route:

All you need to care about is the first hop in the traceroute. If the first hop connects to the gateway you expect then you should be good. In my case that gateway was In the above test you can see I was getting routed to If you run an ifconfig you should see that the jnc0 interface was connected to thus confirming the issue.

The leaves the question of why was the corporate route winning? At first you might be tempted to say that the first route defined always wins, but that is not the case. The route that wins is always the most specific route. Since 172.16, which is equivalent to 172.16/16, is more specific than 172.16/15 it wins. So how do you fix it? One option is to remove the more specific route if possible. If possible means you do not need the route to access something else and that you can remove it. If you need the route for something else then you are stuck. The only way around this issue is to NAT the IP to some non-overlapping IP (outside the scope of this post). If you can remove a static route depends on how the static route was configured. Typically, if the second entry in the static route (i.e. the gateway) is an IP address or the word “default” then you can remove it. If the entry says “link#” then it likely cannot be removed (enforced by a VPN policy). Since in my case the more specific route was not the one I wanted it looked like I was stuck.

Two options to get around my particular issue are as follows:

  1. Client-side: Add a more specific route to access the environment. While you can not have two identical routes going to two different locations, you can publish more specific routes to get the access you need.
  2. Server-side: Push a more specific route in the VPN profile. If you have access to the server or can request a change to the server you can ask for more specific routes to be pushed. Depending on your environment this may be a more viable solution if this issue will impact a large number of people.

So what are the more specific routes needed to fix my issue?

WARNING: Some versions of the route command include the -p flag to make a route persistent across reboots. I would not advise doing this as the route may be incorrect when you are off the VPN and could prevent you from accessing something that you need.

NOTE: One other thing you may notice about the static routes I care about is that their gateway points to I bring this up because you may be on a LAN in that network (e.g. your home network). If this is the case then you may have connectivity issues due to the overlapping IP space.

© 2013 – 2014, Steve Flanders. All rights reserved.

Leave a Reply