OpenVpn to allow a particular ip address

So I setup openVpn by following this:

https://support.nordvpn.com/Connectivity/Router/1047411192/OpenWRT-setup-with-NordVPN.htm

I have setup a static ip address for one of my laptops. I need that ip address - 192.168.1.5 - to only ever use the vpn as setup in the link.

I have tried using "VPN Policy Routing" but to no avail. In dd-wrt i just set the static ip in the "pbr" field and everything was good to go - is there some similar plugin or anything at all that does this?

echo "100 vpn" >> /etc/iproute2/rt_tables

Add the following rule and routes in /etc/config/network

config rule
        option in     'lan'
	option src   '192.168.1.5/32'
	option lookup '100'

config 'route' 'name_your_route'
        option 'interface' 'vpn'
        option 'target' '0.0.0.0'
        option 'netmask' '0.0.0.0'
        option 'gateway' 'gw_to_the_vpn'
        option 'table' '100'

config 'route' 'lan route'
        option 'interface' 'lan'
        option 'target' '192.168.1.0'
        option 'netmask' '255.255.255.0'
        option 'table' '100'

Restart network.

2 Likes

Hey,

so I finally have time (ie nobody needs the internet for a day or two!) to try this out -

so is the only thing that need editing the value "gw_to_the_vpn"? And would I just set it to the value of the end vpn - ie if my vpn makes it look like my ip is 100.1.1.1, would that be the value "gw_to_the_vpn"?

Or would it be something else?

Yes, that's correct. You can try to omit it and hope that auto-detect will fill the gateway automatically in.