Spilt Tunnelling and Policy Routing

How to customize and extend your OpenVPN installation.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

crows
OpenVPN Power User
Posts: 58
Joined: Mon Jul 06, 2015 1:50 am

Re: Spilt Tunnelling and Policy Routing

Post by crows » Thu Jul 16, 2015 10:15 am

Do I still need to do this if I can do as per jpeg?

Image
TiTex wrote:then create the folders somehere else and change the path of the scripts

crows
OpenVPN Power User
Posts: 58
Joined: Mon Jul 06, 2015 1:50 am

Re: Spilt Tunnelling and Policy Routing

Post by crows » Thu Jul 16, 2015 11:03 am

TiTex wrote:then create the folders somehere else and change the path of the scripts
Why is it when I execute these commands manually via telnet, they all execute with no errors there is a tmp/pia directory and an up.sh file in there, however when I browse my 192.168.0.109 machine is using ISP not VPN? however I i execute the same commands without echo and any directory reference it works.

mkdir -p /tmp/pia/

echo "#!/bin/sh" > /tmp/pia/up.sh
echo "iptables -t nat -I POSTROUTING -o tun1 -j MASQUERADE" >> /tmp/pia/up.sh
echo "ip route show table main | grep -Ev ^default | while read ROUTE ; do ip route add table 25 $ROUTE; done" >> /tmp/pia/up.sh
echo "gvip=$(ifconfig | grep -A 1 tun1 | grep inet | cut -d: -f3 | cut -d' ' -f1)" >> /tmp/pia/up.sh
echo "ip route add table 25 default via $gvip dev tun1" >> /tmp/pia/up.sh
echo "ip rule add from 192.168.0.109 table 25" >> /tmp/pia/up.sh
echo "ip rule add to 66.171.248.172 table main" >> /tmp/pia/up.sh
echo "ip route flush cache" >> /tmp/pia/up.sh

crows
OpenVPN Power User
Posts: 58
Joined: Mon Jul 06, 2015 1:50 am

Re: Spilt Tunnelling and Policy Routing

Post by crows » Thu Jul 16, 2015 11:46 am

I'm sorry for all the posts, i cannot edit my posts...i understand what the script does, i.e creates the tmp directories and files within pia, up and down.sh. These files run manually but dont have any effect on the output. We know it works because i can execute them manually and it works.

I have also identified to execute scripts in my build you need this format ./up.sh

crows
OpenVPN Power User
Posts: 58
Joined: Mon Jul 06, 2015 1:50 am

Re: Spilt Tunnelling and Policy Routing

Post by crows » Fri Jul 17, 2015 1:01 am

Is the most effective way to re-run scripts to use the cron command? I'm finding that my VPN provider drops connection once to twice a day making my rules inadequate.

I cant believe how much trouble this has been.

crows
OpenVPN Power User
Posts: 58
Joined: Mon Jul 06, 2015 1:50 am

Re: Spilt Tunnelling and Policy Routing

Post by crows » Tue Jul 21, 2015 4:50 am

I just like to thank Eddie and Titex for helping me get this working. I am ever grateful for their help and patience and not giving up on me.

Thanks

TiTex
OpenVPN Super User
Posts: 310
Joined: Tue Apr 12, 2011 6:22 am

Re: Spilt Tunnelling and Policy Routing

Post by TiTex » Tue Jul 21, 2015 7:37 am

i also learned a few things in the process , so you're welcome :)

Post Reply