This is a Canonical Question about solving IPv4 subnet conflicts between a VPN client's local network and one across the VPN link from it.
After connecting to a remote location via OpenVPN, clients try to access a server on a network that exists on a subnet such as 192.0.2.0/24. However, sometimes, the network on the client's LAN has the same subnet address: 192.0.2.0/24. Clients are unable to connect to the remote server via typing in its IP because of this conflict. They are unable to even access the public internet while connected to the VPN.
The problem is that this subnet 192.0.2.0/24 needs to be routed by the VPN, but it also needs to be routed as the client's LAN.
Does anyone know how to mitigate this issue? I have access to the OpenVPN server.
If you need a temporary dirty workaround to a single or a handful known server ips, the simplest solution should be the static client side routing option.
In my case I added my desired destination server (192.168.1.100) to my routing table on my linux client via:
Afterwards, remove this static route with the route delete command.
It is possible to solve this using NAT; it's just not very elegant.
So under the assumption you couldn't solve this by having internal nets which have so uncommon network numbers as to never actually come into conflict, here's the principle:
As both the local and remote subnet have identical network numbers, traffic from your client will never realize it has to go through the tunnel gateway to reach its destination. And even if we imagine it could, the situation would be the same for the remote host as it is about to send an answer.
So stay with me and pretend that as of yet, there are no side issues as I write that for full connectivity, you would need to NAT both ends inside the tunnel so as to differentiate the hosts and allow for routing.
Making some nets up here:
So inside the VPN tunnel, the office hosts are now 198.51.100.x and remote office hosts are 203.0.113.x. Let's furthermore pretend all hosts are mapped 1:1 in the NAT of their respective VPN gateways. An example:
So when host 192.0.2.5/24 in the remote office wants to connect to the host with the same ip in the office network, it needs to do so using the address 198.51.100.5/24 as destination. The following happens:
So whilst there is a solution, there are a number of issues which must be addressed for this to work in practice:
So solving this needs careful design. If your remote office really consists of road warriors you add a layer of problems in that:
Depending on your VPN client you might be able to automatically select one VPN or the other depending on the network address of the local segment.
Observe that all mentioning of NAT in this context denotes a NAT function which so to speak takes place within the tunnel perspective. Processwise, the static NAT mapping must be done before the packet "enters" the tunnel, i.e. before it is encapsulated in the transport packet which is to take it across the internet to the other VPN gateway.
This means that one must not confuse the public ip addresses of the VPN gateways (and which in practice may also be NAT:ed, but then wholly outside the perspective of transport to the remote site through VPN) with the unique private addresses used as masquerades for the duplicate private addresses. If this abstraction is difficult to picture, an illustration of how NAT may be physically separated from the VPN gateway for this purpose is made here:
Using NAT in Overlapping Networks.
Condensing the same picture to a logical separation inside one machine, capable of performing both the NAT and VPN gateway functionality, is simply taking the same example one step further, but does place greater emphasis on the capabilities of the software at hand. Hacking it together with for example OpenVPN and iptables and posting the solution here would be a worthy challenge.
Softwarewise it certainly is possible:
PIX/ASA 7.x and Later: LAN-to-LAN IPsec VPN with Overlapping Networks Configuration Example
and:
Configuring an IPSec Tunnel Between Routers with Duplicate LAN Subnets
The actual implementation therefore depends on a lot of factors, the operating systems involved, associated software and its possibilities not the least. But it certainly is doable. You would need to think and experiment a bit.
I learned this from Cisco as seen by the links.
yup this is the worst. for me it happened all the time from hotel rooms, before it vpn admins realized they should use more obscure ip ranges. 10.0.0.0/24 and 10.1.1.1/24 are the worst. if you can help it never ip a wireless network like that.
so the answer is "fix" the wap to use a different internal network (ie 10.255.255.0/24) and then give you a diff lease (ie ip in a range that can route back to corp vpn), or if you have no / cant get admin on wap, just go to starbucks. or 20 minutes of wardriving :)
if this is just in a lab setting, just use different ranges.
The Answer from Aydin K. is for linux. If your want the same funtionality for windows, you can type
or
you can get the interface id with the command:
I'm on a mac running El Capitan. While the suggestions above didn't work for me they led me to a working solution:
ifconfig
start the VPN, do
ifconfig
and note which is the new interface. In my case it was ppp0 with an ip address of 192.168.42.74type in:
I tested first with a
ping
and then I proved it worked by accessing the git server.When I tried using dev ppp0 for the end of the route command as mentioned above, it complained.
I have a simple solution that I'm using at a co-working space that has a conflicting IP range (10.x)
I connected to the network with my mobile phone, then I shared the network connection via bluetooth with my laptop. I can now use the VPN for my remote employer.
I'm sure this will work just the same via USB if you need a faster connection.
If you just need to hit a few one or two ip addresses, add route statement to your ovpn configuration file like this:
route 192.168.1.10 255.255.255.255
route 192.168.1.11 255.255.255.255
It will add a route for just those Ip's when you connect your vpn and remove it when the vpn it disconnected.
Worked for me on Windows anyway.
Just as a reminder: this whole issue is due to years of IPv4 address shortage, and extensive use of private IP range behind NAT to workaround this shortage !
The ideal and definitive solution to this issue is quite straightforward (albeit it can, and will, takes some time to be globally rolled-out) : IPv6...
In an IPv6 world, there's no public IP shortage (and there won't be, event in a few decade). So there no reason not to have a public IP on each and every device of every network. And if you need network isolation, keep filtering with a firewall, but without ugly NAT...
if you have same ip block both local and remote networks and want to access only remote block local && remote network address : 192.168.2.0/24 following options for windows 10 worked for me
add these options to OpenVPN certificate file
why? Real ethernet interface have metric 0
TAP vpn interface has metric 256
we must increase TAP interface's priority