Using DD-WRT to connect to VPN and Forward all traffic of certain devices through VPN

Solution 1:

This is a routing question, so using iptables may not suitable. Here we will use iproute2, which, fortunately, included with DD-WRT.

Suppose 1.1.1.1 is the IP address of the default gateway of the DD-WRT (you have to figure it out, may be by ways of disable OpenVPN so that the default gateway will be set to normal and issue a route -n command to see the normal - before OpenVPN-get-connected default gateway).

Now set up another route table like that (we will use table 10):

# ip route add default via 1.1.1.1 table 10

And set up rules so that traffic from some IPs in the LAN will get routed using this new table:

# ip rule add from 192.168.0.0/24 table 10

Or from individual IPs:

# ip rule add from 192.168.0.3/32 table 10
# ip rule add from 192.168.0.5/32 table 10

You can verify with:

# ip route show table 10
# ip rule list

Read more here on startup scripts on DD-WRT if you want all of these to survive on reboot.