How to bypass specific website or IP from OpenVPN connection on Mac
We all have sites that needs to bypass the VPN connection and OpenVPN is popular open source VPN software but it lacks to have bypass a website from it’s network but if you’ve a mac then it’s a easy process as shown in below guide and hope it helps you.
To bypass specific websites or IP addresses from OpenVPN connection on a Mac, you can use the route command to exclude them from the VPN tunnel. Here’s how you can do it:
Open the Terminal app on your Mac. You can find it in Applications > Utilities.
First, find your default gateway IP address. You can do this by running the following command in Terminal:
netstat -nr | grep default
This command will display your default gateway IP address in the second column. Note it down as you’ll need it in the next steps.
- Now, find the IP address of the website you want to bypass. You can use the following command, replacing “example.com” with the website you want to bypass:
nslookup example.com
This command will give you the IP address of the website. Note it down as you’ll need it in the next steps.
- To bypass the website from theOpenVPN connection, use the route command with the following syntax, replacing “your_gateway_ip” with the default gateway IP you noted down earlier, and “website_ip” with the IP address of the website you want to bypass:
sudo route add -host website_ip your_gateway_ip
For example, if your default gateway IP is 192.168.1.1 and the website’s IP is 123.45.67.89, the command would be:
sudo route add -host 123.45.67.89 192.168.1.1
You will be prompted to enter your Mac’s admin password to execute the command. Once you’ve entered the password, the route will be added, and the specified website will be bypassed from the OpenVPN connection.
To check if the bypass is working, you can visit the website and check your IP address. It should show your regular IP address instead of the VPN IP address.
If you want to remove the bypass, you can use the following command, replacing “website_ip” with the IP address of the website you want to remove the bypass for:
sudo route delete -host website_ip
- You can repeat steps 3-7 for any additional websites or IP addresses you want to bypass from the OpenVPN connection.
Note: These changes are temporary and will be reset when you restart your Mac. To make the bypass permanent, you can create a script to run these commands at startup or add them to your OpenVPN configuration file.