Moving openvpn server - can it autodetect its LAN?

Need help configuring your VPN? Just post here and you'll get that help.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Forum rules
Please use the [oconf] BB tag for openvpn Configurations. See viewtopic.php?f=30&t=21589 for an example.
Post Reply
BobAGI
OpenVPN Power User
Posts: 167
Joined: Mon May 05, 2014 10:17 pm

Moving openvpn server - can it autodetect its LAN?

Post by BobAGI » Sun Oct 08, 2023 1:20 pm

Situation:
OpenVPN server (2.5.1) installed and running on a RaspberryPi device.
Server shut down and moved to another location and started there.

Since the new location uses a different LAN IP range, can the server.conf be configured such that the server will auto-detect the new IP range and adjust its setting accordingly?
I have already added the multihome directive so it can use either the wlan0 or eth0 network interfaces. But those are on the same network so that does not help much.

There is a setting in the conf file that deals with the redirection of clients toward the OpenVPN server's LAN and out to the Internet this way:

Code: Select all

push "route 192.168.119.0 255.255.255.0" #Gives access to Local LAN
When it is moved to another LAN like 10.132.55.0/24 then one has to go in (as root) and edit the server.conf file to make it work....

So can it be told to push whichever LAN it is currently running on? Instead of having to enter the numeric LAN address into the file.
Or can this particular line be read from a file on startup so I can script its modification on system startup (before OpenVPN starts)?

Post Reply