LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-03-2010, 08:46 AM   #1
vishwas786
LQ Newbie
 
Registered: Oct 2007
Location: The country that converted APES to Human Beings.
Distribution: Ubuntu, Solaris, OLE, Red Hat, Asianux, Turbo Linux
Posts: 10

Rep: Reputation: 0
Question 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.
 
Old 12-03-2010, 11:26 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by vishwas786 View Post
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.
 
Old 12-05-2010, 04:45 PM   #3
Ehtetur
Member
 
Registered: Mar 2008
Location: Denver, CO
Distribution: Red Hat Enterprise Linux
Posts: 52

Rep: Reputation: 16
Quote:
Originally Posted by vishwas786 View Post
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.
 
Old 11-20-2020, 09:01 PM   #4
karam1
LQ Newbie
 
Registered: Nov 2020
Posts: 1

Rep: Reputation: Disabled
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.
 
Old 11-21-2020, 08:38 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by karam1 View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
DHCP execute script on lease dlublink Linux - Networking 6 01-04-2010 10:55 AM
some sort of dhcp lease alert script/email/popup system? Predatorian Linux - Server 2 10-21-2009 12:26 PM
DHCP server seems to not give up lease... custangro Linux - Networking 4 09-29-2008 03:54 PM
DHCP Server lease list mahesh_sonawane Linux - Networking 1 10-05-2006 09:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration