[SOLVED] How To Control DHCP Lease In OpenVPN

This forum is for general conversation and user-user networking.

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

Locked
blueaquan
OpenVPN User
Posts: 21
Joined: Sat Sep 03, 2011 8:33 pm

[SOLVED] How To Control DHCP Lease In OpenVPN

Post by blueaquan » Fri Nov 25, 2011 12:47 pm

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

User avatar
Mimiko
Forum Team
Posts: 1564
Joined: Wed Sep 22, 2010 3:18 am

Re: How To Control DHCP Lease In OpenVPN

Post by Mimiko » Tue Nov 29, 2011 6:45 am

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.

User avatar
janjust
Forum Team
Posts: 2703
Joined: Fri Aug 20, 2010 2:57 pm
Location: Amsterdam
Contact:

Re: How To Control DHCP Lease In OpenVPN

Post by janjust » Tue Nov 29, 2011 11:36 am

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

blueaquan
OpenVPN User
Posts: 21
Joined: Sat Sep 03, 2011 8:33 pm

Re: How To Control DHCP Lease In OpenVPN

Post by blueaquan » Thu Dec 01, 2011 6:35 pm

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

User avatar
janjust
Forum Team
Posts: 2703
Joined: Fri Aug 20, 2010 2:57 pm
Location: Amsterdam
Contact:

Re: How To Control DHCP Lease In OpenVPN

Post by janjust » Fri Dec 02, 2011 9:11 am

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] "

blueaquan
OpenVPN User
Posts: 21
Joined: Sat Sep 03, 2011 8:33 pm

Re: How To Control DHCP Lease In OpenVPN

Post by blueaquan » Fri Dec 02, 2011 5:33 pm

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

User avatar
janjust
Forum Team
Posts: 2703
Joined: Fri Aug 20, 2010 2:57 pm
Location: Amsterdam
Contact:

Re: How To Control DHCP Lease In OpenVPN

Post by janjust » Mon Dec 05, 2011 8:35 am

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.

blueaquan
OpenVPN User
Posts: 21
Joined: Sat Sep 03, 2011 8:33 pm

Re: How To Control DHCP Lease In OpenVPN

Post by blueaquan » Tue Dec 06, 2011 5:36 pm

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

User avatar
janjust
Forum Team
Posts: 2703
Joined: Fri Aug 20, 2010 2:57 pm
Location: Amsterdam
Contact:

Re: How To Control DHCP Lease In OpenVPN

Post by janjust » Tue Dec 06, 2011 10:36 pm

great to hear that - this is one for the FAQs :ugeek:

closing topic.

Locked