How to set a static IP (client side) in OpenVPN?

I am setting up a VPN network with a lot of little devices (running OpenWRT). In my use case, the devices are all identified by a number and I would like their ip adresses to match their ID (e.g: the device number 6 will have an ip in X.X.X.6).

I am aware of client-config-dir and ifconfig-push but i cannot use them because all my devices use the same certificate (duplicate-cn is enabled). This is a requirement since generating one certificate for each devices will be too constraining (moreover, we don’t want to change the configuration of the VPN server if we add a device in the system)

Is it possible to set the ip adress in the client configuration file ? I didn’t found anything in the documentation about that particular topic… And everything I tried didn’t succeed.

Basically, what I have in mind would be the following:

  • Client Connect to the VPN server and asks for a specific adress (“give me the ip: 172.16.0.22”)
  • If the adress is already taken, the handshake fails. If it is free, the client is given the adress he asked before

Related:


Leave a Reply