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 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 -interface ppp0
add host 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.

Leave a Comment