What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Policy based routing (manual method) - but with 2 VPNs?

wizin

Regular Contributor
RT-N66U with latest Merlin Build

So I got it working after following wiki - https://github.com/RMerl/asuswrt-merlin/wiki/Policy-based-routing-(manual-method)?

Now say I want to setup Client 2 with another country location and want a particular device to use that, how would I go about that

Instructions are basically assuming Client 1
This is the code

#!/bin/sh

sleep 2

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 br0 -j MARK --set-mark 1

iptables -t mangle -A PREROUTING -i br0 -m iprange --src-range 192.168.x.xxx -j MARK --set-mark 0

exit 1
 
RT-N66U with latest Merlin Build

So I got it working after following wiki - https://github.com/RMerl/asuswrt-merlin/wiki/Policy-based-routing-(manual-method)?

Now say I want to setup Client 2 with another country location and want a particular device to use that, how would I go about that

Instructions are basically assuming Client 1
This is the code

#!/bin/sh

sleep 2

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 br0 -j MARK --set-mark 1

iptables -t mangle -A PREROUTING -i br0 -m iprange --src-range 192.168.x.xxx -j MARK --set-mark 0

exit 1
The easiest way is to assign a static IP to the device based on mac address. In the OpenVPN Client tab, set Redirect Internet Traffic to "Policy Rules". Then, enter the IP of the device you assigned, 0.0.0.0 for destination IP and VPN for iface.
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top