I am generating an OpenVPN configuration for my server. I want clients to be able to access my server's router, which is 192.168.1.1, as well as the local network, so I pushed this route:
192.168.1.1/24
and then imported the OVPN file on my Windows OpenVPN client (the official one).
On my Windows, it works. On other Windows (from my father's computer), it connects but I can't access 192.168.1.1. I end up acessing the local router, not the remote one.
Somebody said on OpenVPN forum that I shouldn't add 192.168.1.1/24
. Why? How should I do it then?
They are telling you not to use
192.168.1.1/24
because almost all home routers use that subnet by default. Just change it to192.168.2.0/24
- that should cure your problem.As @Hauke Laging have mentioned, you can map another subnet/IP (that is less often used by home routers) to
192.168.1.0/24
/192.168.1.1
. For example:or
Then you can access
192.168.1.0/24
/192.168.1.1
the server is connected to with10.0.9.0/24
/10.11.12.13
on the VPN client.This can be done with
DNAT
orNETMAP
in iptables as well. Assuming by "accessing the router" you mean its web UI, you may even just DNAT say$server_vpn_ip:80
to192.168.1.1:80
, if the former isn't occupied already.(Note: assuming the server has already been doing IP forwarding and masquerading.)
Avoid commonly used private networks in VPN subnets
This concerns both the subnets assigned to the VPN clients on the remote side, but also all the networks that needs to be accessed using the VPN. If there is a local network the client is directly connected to and it has a overlapping subnet, it takes precedence.
I've listed some subnets you should avoid in an answer from 2017:
OpenVPN recommendations and defaults
OpenVPN has published an article on Numbering private subnets:
For the client subnets, OpenVPN defaults to
10.8.0.0/24
. From Topology in OpenVPN: