Route only specific hostnames through the VPN

This is where we can discuss what we would like to see added or changed in OpenVPN.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
vinopenvpn
OpenVpn Newbie
Posts: 1
Joined: Sun Apr 11, 2021 11:11 pm

Route only specific hostnames through the VPN

Post by vinopenvpn » Sun Apr 11, 2021 11:24 pm

Hello,
I have been trying to figure out how to route specific hostname (example.com) through the VPN and all other traffic will not use VPN.
I tried adding following to the .ovpn file

Code: Select all

route-nopull
route IP_ADDRESS 255.255.255.0
where IP_ADDRESS is the ip address for the host (example.com) that I want to go through the VPN but I get an error

Code: Select all

Options error: option 'redirect-gateway' cannot be used in this context ([PUSH-OPTIONS])
Options error: option 'dhcp-option' cannot be used in this context ([PUSH-OPTIONS])
Options error: option 'route' cannot be used in this context ([PUSH-OPTIONS])
Is this something possible to do? Also I would like to avoid ip address and specify hostname (I think I need allow-pull-fqdn but that is next step)

I have an Asus router with Merlin firmware.

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: Route only specific hostnames through the VPN

Post by TinCanTech » Mon Apr 12, 2021 12:16 am

Never use --route-nopull .. unless you want to break your VPN.

Instead, use --pull-filter ignore "what ever you want to ignore"

Or better yet, learn how to configure your router so it does what you want.

Then you can add what-ever routes you like with --route

Post Reply