Page 1 of 1

[SOLVED] How To Control DHCP Lease In OpenVPN

Posted: Fri Nov 25, 2011 12:47 pm
by blueaquan
Hello Everybody
My OpenVPN configuration is working perfectly alright with Active Directory authentication. However, I noticed that the IP address that's assigned to the Client Machines from the Server is for a period of one Year.
Is there a way to control this Parameter? If yes, I would like to bring this down to one day. Could you kindly help?


Thanks

Blue

Re: How To Control DHCP Lease In OpenVPN

Posted: Tue Nov 29, 2011 6:45 am
by Mimiko
who is serving DHCP requests: OpenVPN or some other DHCP server? If OpenVPN - its not a problem. If some DHCP server on LAN - you have to configure it. It's out of scope of OpenVPN.

Re: How To Control DHCP Lease In OpenVPN

Posted: Tue Nov 29, 2011 11:36 am
by janjust
the 1 year DHCP lease is assigned by OpenVPN itself; it can be controled (on the CLIENT side for Windows clients using

Code: Select all

ip-win32 dynamic [offset] [lease-time] 
e.g.

Code: Select all

ip-win32 dynamic 0 3600

Re: How To Control DHCP Lease In OpenVPN

Posted: Thu Dec 01, 2011 6:35 pm
by blueaquan
Hi Mimiko and Janjust
The Lease is served by OpenVPN, however it would be great if there was a simpler way to do it on the OpenVPN Server rather than on individual client machines...


Thanks
Blue

Re: How To Control DHCP Lease In OpenVPN

Posted: Fri Dec 02, 2011 9:11 am
by janjust
In a 'tun' style network the DHCP lease is done by the OpenVPN *client*, not the server. The OpenVPN client program acts as a mini DHP client to the local tap-win32 adapter.
If you want to have a server side DHCP server then you need a 'tap' style network, possibly using bridging (which I would NOT recommend)

On the server side you might be able to get away with

Code: Select all

push "ip-win32 dynamic [offset] [lease-time] "

Re: How To Control DHCP Lease In OpenVPN

Posted: Fri Dec 02, 2011 5:33 pm
by blueaquan
Hi Janjust
I have a bridge mode setup on my Network with OpenVPN running on FreeBSD 8.0 serving Win XP clients. Therefore I should be able to use the option you mentioned in my "server.conf" file...?
Also what's the Offset parameter? Could you kindly give me an example please...?


Thanks
Blue

Re: How To Control DHCP Lease In OpenVPN

Posted: Mon Dec 05, 2011 8:35 am
by janjust
I've never tested if this works, but it just might: add

Code: Select all

push "ip-win32 dynamic 0 3600"
to the server.conf file, restart the openvpn server and reconnect the clients.

Re: How To Control DHCP Lease In OpenVPN

Posted: Tue Dec 06, 2011 5:36 pm
by blueaquan
Hi Janjust
Congratulations! it worked! I added the push ip-win32 directive to my server.conf file and the lease now shows one day.

Thanks to you and everybody in this thread.

Blue

Re: How To Control DHCP Lease In OpenVPN

Posted: Tue Dec 06, 2011 10:36 pm
by janjust
great to hear that - this is one for the FAQs :ugeek:

closing topic.