How OpenVPN server assigns IP addresses to clients

This forum is for admins who are looking to build or expand their OpenVPN setup.

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
rusttree
OpenVpn Newbie
Posts: 3
Joined: Fri Oct 13, 2017 8:55 pm

How OpenVPN server assigns IP addresses to clients

Post by rusttree » Fri Oct 20, 2017 12:45 am

I have an OpenVPN server running on an embedded Linux device. The clients connect to it through a wireless WAN interface. The server also has a LAN interface with a static IP that I manually configured.

I noticed that the server automatically assigns new clients to an IP address in the same subnet as the static IP on the LAN. That happens to be exactly the behavior that I wanted, but I don't understand why it works. I did not explicitly configure the server to do that. What would happen, for example, if I had two LAN interfaces with different static IPs? Does it just default to the subnet of the first other interface it finds? Is this behavior explained in the documentation somewhere?

Here is the server configuration file (this is in OpenWRT, but it should be clear how the options are applied):

Code: Select all

config openvpn 'myvpn'
        option enabled '1'
        option verb '3'
        option proto 'udp'
        option port '1194'
        option dev 'tap'
        option mode 'server'
        option tls_server '1'
        list push 'route-gateway dhcp'
        option keepalive '10 120'
        option ca '/etc/openvpn/ca.crt'
        option cert '/etc/openvpn/server.crt'
        option key '/etc/openvpn/server.key'
        option dh '/etc/openvpn/dh2048.pem'
        option log '/var/log/openvpn.log'

Post Reply