LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-08-2016, 01:56 AM   #1
Ze MoreirA
LQ Newbie
 
Registered: Aug 2007
Location: Tbilisi, Georgia
Posts: 18

Rep: Reputation: 0
Automate route changes when VPN connects [OpenSuse Tumbleweed]


I have VPN (VPNC) configured on my system.
When I connect, it changes routing table from:

Code:
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         172.30.184.193  0.0.0.0         UG        0 0          0 wlo1
172.30.128.93   172.30.184.193  255.255.255.255 UGH       0 0          0 wlo1
172.30.184.192  0.0.0.0         255.255.255.192 U         0 0          0 wlo1
TO:
Code:
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         0.0.0.0         0.0.0.0         U         0 0          0 tun0
0.0.0.0         172.30.184.193  0.0.0.0         UG        0 0          0 wlo1
XX.XX.XX.XX     172.30.184.193  255.255.255.255 UGH       0 0          0 wlo1
172.30.128.93   172.30.184.193  255.255.255.255 UGH       0 0          0 wlo1
172.30.138.0    0.0.0.0         255.255.255.0   U         0 0          0 tun0
172.30.184.192  0.0.0.0         255.255.255.192 U         0 0          0 wlo1
With this routing table I can't access internet, so I made little script that I manually execute:
Code:
route add  default gw 172.30.184.193  wlo1
route add  -net  172.30.0.0 netmask 255.255.0.0 tun0
There are 2 problems:

1. I can't figure out how to automatically execute this script when interface tun0 comes up.
I found there are directories if-down.d if-up.d under /etc/sysconfig/network, but I can't figure out how to write script itself.

2. 10-15 minutes after script was ran, routing table rolls back to after VPN configuration and need to run script again. Have no idea why this happens.

Please help, need to write script which is triggered when VPN connects
And need to make route changes persistent as long as VPN is connected.
 
Old 06-08-2016, 02:59 AM   #2
Ze MoreirA
LQ Newbie
 
Registered: Aug 2007
Location: Tbilisi, Georgia
Posts: 18

Original Poster
Rep: Reputation: 0
Ok, I found workaround like this:

Instead of connecting to VPN from KDE's Connection editor, I set up configuration file /etc/vpnc/<connection>.conf

contents (details obviously not given):

IPSec gateway XX.XX.XX.XX
IPSec ID XXYYZZ
IPSec secret qwerty
Xauth username vpn_user
Xauth password 123abc

Added routing commands at the end of /etc/vpnc/vpnc-script:

# tail /etc/vpnc/vpnc-script
exit 1
;;
esac
###########################
#set up proper routes
###########################
route add default gw 172.30.184.193 wlo1
route add -net 172.30.0.0 netmask 255.255.0.0 tun0

exit 0

and execute:
# vpnc /etc/vpnc/<connection>.conf

After doing this, I can connect to hosts in VNP network and also internet.

This resolved issue, but i'm still interested how to trigger scripts under /etc/sysconfig/network/if-up.d

Last edited by Ze MoreirA; 06-08-2016 at 03:01 AM.
 
Old 06-08-2016, 01:46 PM   #3
Ze MoreirA
LQ Newbie
 
Registered: Aug 2007
Location: Tbilisi, Georgia
Posts: 18

Original Poster
Rep: Reputation: 0
I celebrated too early, routing table falls back to
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 tun0

so I have to run my script anyway
 
  


Reply

Tags
change, route, script, vpn


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: openSUSE Tumbleweed Gets Linux Kernel 4.0.1 and GNOME 3.16.1 LXer Syndicated Linux News 0 05-08-2015 11:36 PM
openSUSE Factory to merge with Tumbleweed jeremy Linux - News 0 10-27-2014 05:45 PM
System messed up after zypper dup (openSUSE 12.2 + Tumbleweed) yzT! SUSE / openSUSE 3 02-20-2013 03:56 AM
LXer: openSUSE 11.4 review – KDE 4.6 and Tumbleweed shine LXer Syndicated Linux News 0 03-18-2011 02:00 PM
pon connects ok to remote VPN but I cant get a route added automatically CADIT Linux - Networking 3 03-08-2010 11:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration