OpenVPN On One VLAN - Direct Internet On Another

Scripts with setup, destroy, and modify routing tables and firewall rulesets for client connections.

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

Post Reply
BlakeDC
OpenVpn Newbie
Posts: 1
Joined: Thu Jan 07, 2016 5:55 pm

OpenVPN On One VLAN - Direct Internet On Another

Post by BlakeDC » Thu Jan 07, 2016 5:59 pm

Hey Everyone,

Did some digging, tweaked some scripts, and ultimately this works for me as I have it right now...until it stops working.

Randomly my client's, and the router, will stop getting access to the VPN after an undetermined amount of time. I'm assuming there's something goin on with settings/scripts/reconfigs while the system is up and running, or when the script gets executed etc. Anyways, here's the gist:

I've setup:

Code: Select all

#!/bin/sh
for i in /proc/sys/net/ipv4/conf/*/rp_filter ; do
echo 0 > $i
done
ip route flush table 100
ip route del default table 100
ip rule del fwmark 1 table 100
ip route flush cache
iptables -t mangle -F PREROUTING
ip route show table main | grep -Ev ^default | grep -Ev tun11 | while read ROUTE ; do
ip route add table 100 $ROUTE
done
ip route add default table 100 via $(nvram get wan_gateway)
ip rule add fwmark 1 table 100
ip route flush cache
iptables -t mangle -A PREROUTING -i br1 -j MARK --set-mark 1
iptables -t mangle -A PREROUTING -i br0 -j MARK --set-mark 0
in the FIREWALL script area. I had read an older post to put it in WANUp, but it never would change anything. Moving it to Firewall made it work (at least at boot) so I left it there.

Now my current issue is what I stated above: Everything loses it's routing or whatever issue after an undertermined amount of time.

I want to check my scripts and everything to make sure it all looks right, and to make sure I'm not missing some kind of QA setting somewhere where the router fixes issues it might see, and destroys my routes.

Thanks :ugeek:

Post Reply