LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Route creation when an interface is UP (https://www.linuxquestions.org/questions/linux-newbie-8/route-creation-when-an-interface-is-up-4175417330/)

digitel 07-18-2012 01:26 AM

Route creation when an interface is UP
 
Hi All,
New to this forum.
I need an help on this (if possible)


I have a machine establishing a VPN Tunnel with a remote server
When the connection is established, a new interface called Tunnel0 is created
I need a new route (like route add -n 192.168.100.0/24 -interface Tunnel0 )to be created automatically each time this Tunnel0 is UP
It would be nice the route was deleted once the Tunnel0 is DOWN or removed.

Any Hint ??

Thank you very much

pingu 07-18-2012 02:06 AM

Normally this is handled by the server side, where you configure it to push specific routes to clients.
Observer that in some vpn-client-apps there is a configure option to ignore routes sent by server.
First tip is to check that.

If that is not the case, routes are not pushed by server and you can't control the server, I can see 2 ways:
1) A script that first opens the tunnel and then adds the route.
2) A script that catches output from "ifconfig" and adds the route, if not present, when tunnel is up.

Not very difficult, first option being the easiest.

digitel 07-18-2012 09:47 AM

Quote:

Originally Posted by pingu (Post 4731359)
I can see 2 ways:
1) A script that first opens the tunnel and then adds the route.
2) A script that catches output from "ifconfig" and adds the route, if not present, when tunnel is up.

2) is the best option from my side....

Since the VPN client rises the connection only when needed by operator (tunnel couldn't be activated even for days...) I suppose that script should run with no sense the whole day looking for Tunnel0 to be present...
Is there a lighter solution ?

Anyway, as I'm a newbie, does anybody have some script lines to suggest ??

Thank you very much


All times are GMT -5. The time now is 02:45 AM.