VPN: Temporarily solve same subnet conflicts

2 minute read

I recently had the problem of needing to establish a connection to a server behind a VPN that was in the same subnet as the network I was connecting from. Every call I wanted to make to the server on the remote network wouldn’t go through as it was looking for the server on the local network.

To eventually reach the server, I temporarily added a route to the routing tables, telling the client it should transmit traffic to the destination ip through the interface of the VPN connection.

If you ever come across a similar situation, here’s how to solve it.

First, find out which interface your VPN is using:

> ifconfig

Let’s assume it runs via ppp0. Let’s further assume that the server you want to reach is at 192.168.1.10. Now, to tell your client about it, add the route via the route command (this is on macOS, but should work more or less the same on a Linux system):

> sudo route add -host 192.168.1.10 -interface ppp0
add host 192.168.1.10: gateway ppp0

Doing a quick ping, you should see that your desired server is now reachable.

Note that when you re-connect you may need to setup the route again as the setting is not persisting.

Like to comment? Feel free to send me an email or reach out on Twitter.

Did this or another article help you? If you like and can afford it, you can buy me a coffee (3 EUR) ☕️ to support me in writing more posts. In case you would like to contribute more or I helped you directly via email or coding/troubleshooting session, you can opt to give a higher amount through the following links or adjust the quantity: 50 EUR, 100 EUR, 500 EUR. All links redirect to Stripe.