0

I have an .ovpn configuration file which allows me to reach endpoints on the VPN if I uncomment redirect-gateway def1, but I do not want all network traffic going through the VPN. Only certain endpoints.

If I try and visit an internal website, let's say 42.123.123.10 with redirect-gateway def1 present it works. If I comment redirect-gateway def1 and use any of the following it does not work.

Additionally, I cannot see the interface named ovpn-tun when running ifconfig so I am not sure what to set network rules on if I configured a script to add routes or what have you.

Attempted

route-nopull
route 42.123.123.10 255.255.255.255 ;OR the following line
route 42.123.123.10 255.255.255.0   ;OR the following line
route 42.123.123.10

Base Config

route-nopull
client
dev ovpn-tun
remote {REDACTED} 1194 udp
cipher AES-256-CBC
auth SHA512
resolv-retry infinite
;redirect-gateway def1
route 42.123.123.10
nobind
persist-key
persist-tun
user nobody
group nogroup
verb 10
1

I forgot the interface must be an existing one, so I used utun which is on macOS by default.

I removed all entries for route in the OpenVPN config file and instead installed iproute2mac via homebrew, brew install iproute2mac so I have access to the ip command which I am used to the syntax of.

I then ran ip route add 42.123.123.10 dev utun2 (I know my interface will be utun2 as without OpenVPN running there are two utun interfaces for me, utun0, and utun1 checked with ifconfig or ip r.

Now it works.

OpenVPN allows you to run scripts via the configuration files so I will dump these route add and route delete rules in some files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .