I have an OpenVPN client set up on my AC68 running 380.65. Using policy rules, I have one device set to route all traffic through the VPN. Using john9527's custom openvpn-event script (located here), I've also set up scripts (eg, "vpnclient1-route-up" "vpnclient1-down") to add/remove some port forwards through the VPN. It all works brilliantly.
Here's my new challenge. I have another device where I only want SOME of its traffic to go through the VPN, but NOT block it when the VPN is down. Through some searching, I found Martineau's instructions on how to do this (located here). My question is, instead of adding this to nat-start, can I add this to my vpnclient1-route-up and vpnclient1-down scripts that get called by the openvpn-event script?
So to vpnclient1-route-up, I would add:
Then, in vpnclient1-down, I would add:
When the VPN is disconnected, this would restore normal routing to WAN for the specific IP addresses and ports that I have specified...this is the behaviour I'm looking for.
My question is, how reliable would this setup be? I keep my VPN connected for days at a time, so I'm just wondering if any of these rules would get overwritten periodically. I think I read somewhere that some people can see ip rules get reset once a day or so?
And just another quick question: for this to work for web browsing, I would need to specify ports 80, 443, and 53. Any other ports?
Here's my new challenge. I have another device where I only want SOME of its traffic to go through the VPN, but NOT block it when the VPN is down. Through some searching, I found Martineau's instructions on how to do this (located here). My question is, instead of adding this to nat-start, can I add this to my vpnclient1-route-up and vpnclient1-down scripts that get called by the openvpn-event script?
So to vpnclient1-route-up, I would add:
Code:
ip rule del fwmark 0xy000
ip rule add fwmark 0xy000 table 11y prio 1000y
iptables -t mangle -D PREROUTING -i br0 --src xxx.xxx.xxx.xxx,zzz.zzz.zzz.zzz -p tcp -m multiport --dport nn,pp -j MARK --set-mark 0xy000/0xy000
iptables -t mangle -A PREROUTING -i br0 --src xxx.xxx.xxx.xxx,zzz.zzz.zzz.zzz -p tcp -m multiport --dport nn,pp -j MARK --set-mark 0xy000/0xy000
Then, in vpnclient1-down, I would add:
Code:
ip rule del fwmark 0xy000
iptables -t mangle -D PREROUTING -i br0 --src xxx.xxx.xxx.xxx,zzz.zzz.zzz.zzz -p tcp -m multiport --dport nn,pp -j MARK --set-mark 0xy000/0xy000
When the VPN is disconnected, this would restore normal routing to WAN for the specific IP addresses and ports that I have specified...this is the behaviour I'm looking for.
My question is, how reliable would this setup be? I keep my VPN connected for days at a time, so I'm just wondering if any of these rules would get overwritten periodically. I think I read somewhere that some people can see ip rules get reset once a day or so?
And just another quick question: for this to work for web browsing, I would need to specify ports 80, 443, and 53. Any other ports?