Change order of route matching in Linux

Posted on 2009-04-08
Last Modified: 2012-05-06
Hello, do you know if it is possible to change the matching order for traffic.

I need to be able to change the matching order for VPN route policies.

Currently the local routing tables are processed first ('ip rule show' etc), and then NETKEY based IPSec VPN policies are matched.

I need to be able to define a backup static route (to provide redundancy to the VPNs) in the local routing tables that is matched AFTER the VPN route policies.

For example, if the IPSec (NETKEY based) VPN is established the VPN route policy will match first and the traffic will be routed through the tunnel etc.

If the IPSec VPN is NOT established, the traffic will NOT match any VPN route policy and the traffic will be routed via the local routing table instead.

How can this be done?

I am amazed that when NETKEY was being developed, it was designed with a total disregard for VPN redundancy. Hence I am trying to do this to provide a backup route for failed VPNs.

Does anyone know if there is a bulletin board or a specific community which develops the NETKEY libraries so I can ask this question there if no one here knows an answer?

Thanks in advance.
Question by:MonitorSupport
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4

Author Comment

ID: 24096935
Alternatively and probably a better solution, would be to add the backup route to the 'Security Policy' table, instead of changing the matching orders.

'ip xfrm policy list' shows you the current security policies, as created by openswan when VPNs establish.

How can I use 'ip xfrm policy add ...' to insert the necessary backup 'Security Policy' to act as backup route when the openswan VPN tunnel policy is not in place?

Thanks in advance.
LVL 78

Expert Comment

ID: 24105862
Are you working on some appliance that runs under the linux OS?
I think the same vendor had a different VPN handling mechanism that supported what you need in kernel 2.4 but not in 2.6.

Author Comment

ID: 24106431
Yes this is a Linux appliance.

In 2.4 it was easy as KLIPS was used which created IPSecX interfaces where X is a unique number etc. This then allowed for addition of local routing table entires.

However 2.6 uses NETKEY which has no regard for redundancy whatsoever as there are no IPSecX interfaces (meaning no backup routes and no ability to advertise established VPNs via dynamic routing). Instead the routing is done at a Security Policy level by the addition of an entry in the SPDB when the tunnel comes up (and deleted when the tunnel goes down).

As such I need to add a route to the bottom of the SPDB to act as a redundant path for a VPN.

Cheers for your time.
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

LVL 78

Expert Comment

ID: 24106523
You should search EE, I think there was another similar issue where the user had TWO of those appliances (multi-WAN) and needed to setup a route between the two in the event a VPN from one dies so the load balanced traffic from the LAN will get to its destination.

Author Comment

ID: 24107259
Hi Arnold, that post as one of ours!

This is actually a continuation of the same problem however this time I am specifically trying to work out how to insert a Security Policy based route to implement your idea of a backup route.

Cheers, Andy.
LVL 78

Expert Comment

ID: 24108090

Good luck.

Accepted Solution

MonitorSupport earned 0 total points
ID: 24592898
We purchased a different appliance (Draytek 5510) which supports the advertisement of dynamic routing for established VPNs!!!

Arnold thank you for all your time and help.
LVL 78

Expert Comment

ID: 24598905
I would think that the different approaches taken to address your question led to the solution which was to buy the requisite equipment to meet your needs.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
IPv6 and IPv4 Subnetting scheme 4 103
VPN Server 5 79
VPN Server Configuration in windows 7 7 76
SSL-VPN 1 91
Secure VPN Connection terminated locally by the Client.  Reason 442: Failed to enable Virtual Adapter. If you receive this error on Windows 8 or Windows 8.1 while trying to connect with the Cisco VPN Client then the solution is a simple registry f…
If you use NetMotion Mobility on your PC and plan to upgrade to Windows 10, it may not work unless you take these steps.
Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question