Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Location: The country that converted APES to Human Beings.
Distribution: Ubuntu, Solaris, OLE, Red Hat, Asianux, Turbo Linux
Posts: 10
Rep:
script for clearing the linux dhcp server lease.
Hi,
I have a openSUSE10.2(X86-64) Linux DHCP Server in my environment. It has a lot of VM's and Desktop systems which get added continuously. Also, it has a lots of Static-IP entries.
Part-I
Issue:
The DHCP Server stopped leasing the IP's somehow.
Workaround:
1. Stopped the dhcpd service. (service dhcpd stop)
2. Navigated to /var/lib/dhcp/db folder.
3. Deleted the "dhcpd.leases" and "dhcpd.leases~" files.
4. Recreated the "dhcpd.leases" file. (touch dhcpd.leases)
5. Started the dhcpd service. (service dhcpd stop)
Conclusion:
The server started leasing IP's in the environment again.
Part-II
Issue:
Again the server stopped after some time.
Workaround was the same as mentioned in the Part-I.
Then I thought of creating a script that will run every 3 hours which will clean the dhcp cache.
Following will be the contents of the script:
service dhcpd stop
cd /var/lib/dhcp/db
rm -rf *
touch dhcpd.leases
service dhcpd restart
Can you please let me know whether the issue was regarding the dhcp cache only and guide me to create a script?
Also, please let me know exact command to add this script in the scheduler? (at/crontab)
Thanks in advance!
Last edited by vishwas786; 12-03-2010 at 09:09 AM.
Reason: Its not a post but a query.
Hi,
I have a openSUSE10.2(X86-64) Linux DHCP Server in my environment. It has a lot of VM's and Desktop systems which get added continuously. Also, it has a lots of Static-IP entries.
Part-I
Issue:
The DHCP Server stopped leasing the IP's somehow.
Workaround:
1. Stopped the dhcpd service. (service dhcpd stop)
2. Navigated to /var/lib/dhcp/db folder.
3. Deleted the "dhcpd.leases" and "dhcpd.leases~" files.
4. Recreated the "dhcpd.leases" file. (touch dhcpd.leases)
5. Started the dhcpd service. (service dhcpd stop)
Conclusion:
The server started leasing IP's in the environment again.
Part-II
Issue:
Again the server stopped after some time.
Workaround was the same as mentioned in the Part-I.
Then I thought of creating a script that will run every 3 hours which will clean the dhcp cache.
Following will be the contents of the script:
service dhcpd stop
cd /var/lib/dhcp/db
rm -rf *
touch dhcpd.leases
service dhcpd restart
Can you please let me know whether the issue was regarding the dhcp cache only and guide me to create a script?
Also, please let me know exact command to add this script in the scheduler? (at/crontab)
No, we can't tell you what caused the error, since you don't post any log files or other errors that you may have seen. We have no idea where the problem was, but as a rule you should NOT have to reset your DHCP server every three hours. Check your system logs and DHCP logs, and see if you're having any errors that can be fixed correctly. Also, you may want to provide some details about your network configuration on this DHCP server (bonded interfaces? One or multiple? Load balanced??, etc.).
And if you want to create a script, we can "guide you" to Google, where there are thousands of BASH scripting tutorials, to help get you started. We will be glad to HELP you write it, but we're not going to write it for you. Google can also lead you to lots of information regarding how to edit your system scheduler to run a job. Type in "man crontab" or "man at", and you'll see how to use them.
It has a lot of VM's and Desktop systems which get added continuously. Also, it has a lots of Static-IP entries.
hrmmmm....
I *assume* that you - instead of endusers - are creating the static IPs to ensure no IP addresses are used from dhcpd's address pool...
There could be a problem with VMs constantly being added since I'm guessing they're all obtaining their IP addressess from dhcpd.
Me and the other forum folks could give you a better answer if you link/post your logs and dhcpd.conf files.
is there a way to update or purge instead of flushing the dhcpd.leases file ?
because i think that if you flush the dhcp.leases the ip lease will be set free instead of active because dhcp server reads leases from that file when he is offering an address and that may cause duplicate address if you reduce range !
i'm struggling from this and i couldn't a solution.
is there a way to update or purge instead of flushing the dhcpd.leases file ?
because i think that if you flush the dhcp.leases the ip lease will be set free instead of active because dhcp server reads leases from that file when he is offering an address and that may cause duplicate address if you reduce range !
i'm struggling from this and i couldn't a solution.
You need to open your own thread with your own question; this had been closed for *TEN YEARS* before you reopened it. Anything applicable in this thread isn't likely to have the same solution now. Further, you also don't provide any details about your system, what you're running, have done/tried, etc. What is the actual PROBLEM you're having, aside from anything theoretical??
Open your own thread, provide details and ask a clear question. Read the "Question Guidelines" link in my posting signature, and the LQ Rules.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.