Last active
December 22, 2024 01:42
-
-
Save glimpsed/dcbad6c8924faba6a9b058fec3c24303 to your computer and use it in GitHub Desktop.
How to route network traffic through a VPN (OpenVPN/TunnelBlick) ONLY for specific websites/IPs only on macOS / OS X (static routing)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add the following line at the top of your .ovpnfile to prevent it from routing all network traffic on your Mac through | |
the VPN: | |
route-nopull | |
Next add the following line to allow the VPN to reroute traffic ONLY for a given IP address / domain (if you need to enable it | |
for a domain you can use its IP address): | |
route 1.2.3.4 | |
This can also be used to enable selective traffic re-routing for IP subnets. By adding "route 62.42.34.0", you will enable the | |
VPN for all IP addresses between 62.42.34.1-255. | |
Multiple rules can also be added by duplicating the "route 1.2.3.4" line and changing the IP / subnet. |
Thanks for the instruction! For my ovpn file: I have to remove redirect-gateway def1
line, which redirect all default traffic via the VPN.
My configuration looks like this:
route-nopull
route 10.0.0.0 255.0.0.0
client
nobind
dev tun
<key>
-----BEGIN PRIVATE KEY-----
...
Hi Team, my config is as below:
route-nopull
route 10.0.0.0 255.0.0.0
client
nobind
dev tun
proto udp
sndbuf 0
rcvbuf 0
remote Y.Y.X.C
resolv-retry infinite
nobind
explicit-exit-notify 3
persist-key
persist-tun
remote-cert-tls server
But I am failing to ping the Internet whilst I am connected to my VPN...can you kindly point out where I am wrong? i.e
└─$ ping 4.2.2.2
PING 4.2.2.2 (4.2.2.2) 56(84) bytes of data.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you very much!