Koozali.org: home of the SME Server

Change dhcp lease time

Offline henrikmc

  • *
  • 18
  • +0/-0
Change dhcp lease time
« on: October 30, 2008, 12:53:50 PM »
I was happy with the dhcp contrib for sme 6.0.1.

Now in 7.3, I cant seem to find anything like it. I need the adjust the dhcp lease time as its way to short in default settings.

How to accomplish this?  :shock:

Offline mmccarn

  • *
  • 2,656
  • +10/-0
Re: Change dhcp lease time
« Reply #1 on: October 30, 2008, 01:13:07 PM »
Try this.
Code: [Select]
mkdir -p /etc/e-smith/templates-custom/etc/dhcpd.conf
cd  /etc/e-smith/templates-custom/etc/dhcpd.conf
echo "    default-lease-time  {21*86400};"      > 25LeaseTimeDefault
echo "    max-lease-time      {21*86400};"      > 25LeaseTimeMax
expand-template /etc/dhcpd.conf
sv restart dhcpd

*  Replace "21" with the desired number of days.
*  The spaces in front of "default-lease-time" and "max-lease-time" are important!
*  SME default 'default-lease-time' is 1 day (86400 seconds).
*  SME default 'max-lease-time' is 7 days (7*86400 = 604800 seconds).
*  The SME expand-template command performs the calculation inside the braces and puts the results into the output file without braces.

Verify that your changes "stuck" by looking at the actual values in /etc/dhcpd.conf:
Code: [Select]
grep lease-time /etc/dhcpd.confThe above sample, using {21*86400}, produces the following in /etc/dhcpd.conf:
    default-lease-time  1814400;
    max-lease-time      1814400;


You can un-do these customizations with:
Code: [Select]
rm -f /etc/e-smith/templates-custom/etc/dhcpd.conf/25LeaseTimeDefault
rm -f /etc/e-smith/templates-custom/etc/dhcpd.conf/25LeaseTimeMax
expand-template /etc/dhcpd.conf
sv restart dhcpd

(Note: added to wiki at http://wiki.contribs.org/Dhcpd_lease_time )
« Last Edit: October 30, 2008, 01:50:59 PM by mmccarn »

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Change dhcp lease time
« Reply #2 on: October 30, 2008, 01:16:18 PM »
I need the adjust the dhcp lease time as its way to short in default settings.

Really? What problem do you have with the default setting?

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Change dhcp lease time
« Reply #3 on: October 30, 2008, 01:23:03 PM »

Code: [Select]
mkdir -p /etc/e-smith/templates-custom/etc/dhcpd.conf
cd  /etc/e-smith/templates-custom/etc/dhcpd.conf
echo "    default-lease-time  {21*86400};"      > 25LeaseTimeDefault
echo "    max-lease-time      {21*86400};"      > 25LeaseTimeMax
expand-template /etc/dhcpd.conf
sv restart dhcpd


naturally, I could always put (for example) 3600 and 7200.. I mean, time has to be expressed in seconds, no matter what I put.. right?

Ciao

Stefano

P.S. what about creating DB entries for leasetime and leasetimemax?

Offline mmccarn

  • *
  • 2,656
  • +10/-0
Re: Change dhcp lease time
« Reply #4 on: October 30, 2008, 02:42:49 PM »
Quote
naturally, I could always put (for example) 3600 and 7200
Yes.

You could also do more math:
* {60*60} (60 seconds times 60 minutes ==> 1 hr)
* {60*60*2} (2 hrs)
* {60*60*24} (24 hrs, 60 minutes, 60 seconds ==> 1 day
* {60*60*24*7*3} (1 day times 7 times 3 ==> 3 weeks)

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Change dhcp lease time
« Reply #5 on: October 30, 2008, 04:53:38 PM »
P.S. what about creating DB entries for leasetime and leasetimemax?

It would be possible, but it's also very easy for someone who wants to tweak this to supply a custom template. Nobody has yet suggested a reason why the default creates a problem. Each client exchanging a few packets with the server per day is hardly excessive traffic.

[Check the bug tracker for the many other things that developers might better spend their time on.]

Offline henrikmc

  • *
  • 18
  • +0/-0
Re: Change dhcp lease time
« Reply #6 on: November 01, 2008, 10:08:07 PM »
It would be possible, but it's also very easy for someone who wants to tweak this to supply a custom template. Nobody has yet suggested a reason why the default creates a problem. Each client exchanging a few packets with the server per day is hardly excessive traffic.

[Check the bug tracker for the many other things that developers might better spend their time on.]

Yes, its easy but compared to other functions that sme provides in server-manager, its not.

For me, I would have liked the following:

DHCP control panel:
- Adjust lease times, one day is short in my networks. 3-7 days, and in some nets with servers I would prefere 30 days... Makes them static while keeping it easy with DHCP.
- See active leases with possiblilty to release them
- Set reservations for certain MAC's (not sure if dhcp server in sme dist is capable)
- Set / adjust scope options

DNS:

- Dynamic DNS, all my clients a-records will have to be created manually as it is now. Let DHCP server update DNS?
- Create records panel, mx, A-record etc.
- Flush dns cache

Just my needs, if nobody else would need it then there is no need to spend time building this. But I guess thats why we have contribs, they usually emerge from one admin needs dont they?

Thank you for the help, much appreciated. And I must say that sme 7.3 works well. Its a pleassure to work with. On one highly customised 6.0.1, I used the upgradedisk method, and almost everything worked after the restore. (except databases and e-mail aliases)

Oh, just one thing - what about a language selection possibility in the server-manager?

H

Offline pfloor

  • *****
  • 889
  • +1/-0
Re: Change dhcp lease time
« Reply #7 on: November 01, 2008, 11:49:31 PM »
Yes, its easy but compared to other functions that sme provides in server-manager, its not.

For me, I would have liked the following:

DHCP control panel:
- Adjust lease times, one day is short in my networks. 3-7 days, and in some nets with servers I would prefere 30 days... Makes them static while keeping it easy with DHCP.
- See active leases with possiblilty to release them
- Set reservations for certain MAC's (not sure if dhcp server in sme dist is capable)
- Set / adjust scope options

DNS:

- Dynamic DNS, all my clients a-records will have to be created manually as it is now. Let DHCP server update DNS?
- Create records panel, mx, A-record etc.
- Flush dns cache

Just my needs, if nobody else would need it then there is no need to spend time building this. But I guess thats why we have contribs, they usually emerge from one admin needs dont they?

Thank you for the help, much appreciated. And I must say that sme 7.3 works well. Its a pleassure to work with. On one highly customised 6.0.1, I used the upgradedisk method, and almost everything worked after the restore. (except databases and e-mail aliases)

Oh, just one thing - what about a language selection possibility in the server-manager?

H


WOW, Good Stuff!!!

Sounds like you'll be busy writing some code for the next few days.  Wrap all that up in a couple of RPM's and post them to the bug tracker for testing and consideration into the base OS when you're done.

In life, you must either "Push, Pull or Get out of the way!"

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Change dhcp lease time
« Reply #8 on: November 02, 2008, 04:02:11 AM »
- Adjust lease times, ...

Nobody has yet suggested why the default causes any problem.

Quote
- See active leases with possiblilty to release them

The DHCP protocol doesn't allow for leases to be revoked once granted.

Quote
Oh, just one thing - what about a language selection possibility in the server-manager?

That's done via browser settings.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: Change dhcp lease time
« Reply #9 on: November 02, 2008, 11:16:06 AM »
- Set reservations for certain MAC's (not sure if dhcp server in sme dist is capable)
AFAIK this can be done through the hostname panel, you can serve an IP address based on MAC address there.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline axessit

  • *****
  • 213
  • +0/-0
Re: Change dhcp lease time
« Reply #10 on: November 02, 2008, 10:00:35 PM »
I use the DHCP manager from the SME 6 contrib. Had to change a file though to make it display the correct machine names and MAC addresses, and it didn't quite display the successful change page properly, but it did actually do the changes. I emailed the file thru to the contrib author at the time (forget who now) to perhaps update, but haven't seen anything yet.

It let you remove leases from the dhcp lease file, change the default lease time as you want.

As already posted, you can reserve IP addresses - I use it for reserving network printers and wireless access points etc, then just set them all for DHCP and away you go. You can then ping a sensible name too, like "photocopier" instead of having to remember IP addresses etc.

As for DNS updates, SME supports the free DNS.org and other services if you want to find your box on the internet. Set it up via the console.


Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Change dhcp lease time
« Reply #11 on: November 02, 2008, 11:23:24 PM »
I emailed the file thru to the contrib author at the time (forget who now) to perhaps update, but haven't seen anything yet.

Please use the bug tracker. Thanks.