0

I am trying to add persistent routes to my Debian box, which I am using as VPN server.

I am currently using "ip route" commands to add the routing. Here's an example of a command that I use:

ip route add 192.168.111.0/24 via 192.168.10.1 dev ppp0
ip route add 192.168.110.0/24 via 192.168.10.1 dev ppp1

The problem is that everytime the server restarts, or one of the connections get disconnected, it gets reconnected with a different interface #, which makes the previously added route command invalid already. I need a way to keep the routing valid, even when the interface # changes.

I have found a similar question, but the solution here is for Windows, not for Debian/Linux:

How to add persistent route for 2 VPN connections when interface # varies?

I would appreciate it if someone could point me to the right direction of getting the same solution but for Debian.

Thanks!

1 Answers1

0

In case other people come across the same issue, here's how I solved it..

I added a bash script inside /etc/ppp/ip-up.d/ This will be run each time the ppp connections are created.

These are the contents of the bash script:

#!/bin/sh
ip_local=$5
ip_range=${ip_local%?}
replacement="0/24"
/sbin/route add -net $ip_range$replacement dev $1

These are the docs that helped me:

http://pptpclient.sourceforge.net/routing.phtml#automatic-setup

http://www.lfix.co.uk/oliver/ip-up.html

If anyone has a suggestion on a cleaner/better way to do it, let me know :-)