Tagging a device for the VPN and forcing it to ONLY use the WAN works for me using this sequence in the VPN_Select.sh script.
(P.S I am not concerned about accessing the WAN prior to the VPN becoming available!)
Code:
iptables -t mangle -A PREROUTING -i br0 -s 192.168.1.100 -j MARK --set-mark 10
iptables -I FORWARD -i br0 -s 192.168.1.100 -o eth0 -j DROP
If I start the command on 192.168.1.100
it will continue to successfully ping via the VPN (response time is between 600ms-900ms rather than 25ms via WAN)
Checking the selective routing metrics
Code:
iptables -t mangle -nvL --line
should confirm that the PKT count for the selected device goes UP proving it is using the VPN
Code:
Chain PREROUTING (policy ACCEPT 4108K packets, 400M bytes)
num pkts bytes target prot opt in out source destination
nn 2412 146K MARK all -- br0 * 0.0.0.0/0 0.0.0.0/0 source IP range 192.168.1.100-192.168.1.100 MARK set 0xA
If I then stop the VPN then the ping command should stop....
Checking the WAN blocking metrics
should show that the PKT count for the selected device goes UP proving it is BLOCKED from using the WAN
Code:
Chain FORWARD (policy DROP 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
nn 64 164K DROP all -- br0 eth0 192.168.1.100 0.0.0.0/0
subsequently simply deleting the WAN BLOCKING rule
then allows 192.168.1.100 to browse via the WAN as normal.
In the case of routing everything apart from a couple of ports 563 and 32400 then if we assume by default all traffic bypasses the VPN, in theory the following command (and only requires table 10) should suffice:
i.e. Use VPN for source 192.168.1.100 if port <> 563 and port <> 32400
Code:
iptables -t mangle -A PREROUTING -i br0 -s 192.168.1.100 -m multiport -p tcp --dport ! 563,32400 -j MARK --set-mark 10
would be the only selective routing command required - but I don't think the ! syntax works for -m multiport :-(
So 3 explicit commands are probably required as U have specified to use both table 10 and table 12.
NOTE: Rule order in iptable Chains is fraught with pitfalls, and is often the cause when an expected rule is prempted :-(
Code:
iptables -t mangle -A PREROUTING -i br0 -s 192.168.1.100 -p tcp --dport 32400 -j MARK --set-mark 12
iptables -t mangle -A PREROUTING -i br0 -s 192.168.1.100 -p tcp --dport 563 -j MARK --set-mark 12
iptables -t mangle -A PREROUTING -i br0 -s 192.168.1.100 -j MARK --set-mark 10
and we can probably be more explicit with the blocking rules (order critical!)
i.e. in firewall-start/nat-start
Code:
iptables -I FORWARD -i br0 -s 192.168.1.100 -o eth0 -j DROP
iptables -I FORWARD -i br0 -s 192.168.1.100 -p tcp --dport 563 -o eth0 -j ACCEPT
iptables -I FORWARD -i br0 -s 192.168.1.100 -p tcp --dport 32400 -o eth0 -j ACCEPT
Hopefully you can test out if the above works and should be able to see if/when any of the blocking rules are firing.
Also check for iptable duplicates, as firewall-start/nat-start can fire for multiple events/interfaces :-(
So best to have a reboot of the router then manually test the above.
i.e.
Code:
1. Turn off 192.168.1.00
2. Enter the 3 blocking rules
3. Turn on 192.168.1.100
Confirm that 192.168.1.100 can ONLY access port 563 or 32400 via the WAN
Start the following (hopfully it should timeout)
ping -t www.ibm.com
4. Start VPN
5. Enter the three MARK commands (if they are not already in the VPN_Select.sh script)
6. Confirm that 192.168.1.100 is using the VPN for all traffic except ports 563 and 32400
The ping command should now show success.
7. Stop VPN
Confirm that 192.168.1.100 can only access port 563 or 32400 via the WAN
The ping command should show timeout
8. Start VPN
The ping command should resume successfully
Regards,