Page 1 of 1

Linux Client Route Configuration

Posted: Sun Nov 01, 2015 2:45 am
by kolpinkb
Does anyone have a nice script that they use to execute changes to the routing table in Ubuntu 14.04 and up when the vpn connection is established? Currently, I have to establish the vpn connection and then I run the following script:

root@XXXXX:~/Documents# ./route.sh add vpn_server_ip

---------------------------------------------------------------------------------------------------------------------------------------------
#!/bin/bash
if [ "x$2" == "x" ];
then
echo "vpn server ip missing! ./route.sh add/del vpn_server_ip "

else

case "$1" in

add)



# restore default route to home network
ip route delete default
ip route add default via 192.168.43.1 dev wlp3s0

# obtain ip address for vpn_vpn
ifdown vpn_vpn
ifup vpn_vpn


# add route to vpn server

ip route add $2/32 via 192.168.43.1 dev wlp3s0
ip route delete default
ip route add default via 192.168.74.1 dev vpn_vpn


;;

del)


ip route del $2/32
ip route del default
ip route add default via 192.168.43.1 dev wlp3s0
ifdown vpn_vpn


;;

esac


fi
~
~
~
~
~
~
~
~
"route.sh" 46 lines, 619 characters
------------------------------------------------------------------------------------------------------------------------------------------

Re: Linux Client Route Configuration

Posted: Tue Nov 17, 2015 12:54 am
by raafat
I think you'r going at the wrong direction, so tell us more about your setup so that i can help you (:


Good luck

Re: Linux Client Route Configuration

Posted: Thu Nov 26, 2015 5:46 am
by thisjun
NetworkManager is using in ubuntu.
https://help.ubuntu.com/community/NetworkManager