How to configure DHCP server not to reuse IP addresses?
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
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.
How to configure DHCP server not to reuse IP addresses?
I have a CentOS 7.3 box which I am using for a DHCP server for my home LAN. So far, so good. I have reserved IP addresses assigned to my physical devices (printer, servers, PCs). I use VMs frequently (VMWare) and except for one special case I do not care what IP address they are assigned. They are generally configured as bridged so they get an address from the DHCP server. While doing some testing I decided to attempt to obtain a different address on one of the VMs. I did a dhclient -r and then stopped and started the network. I got back the same address as it was the lowest one available on the DHCP server (I think).
If I do a release/renew or release/reboot on my router I get a new/different address from my ISP. Apparently it understands "release" to mean "I don't like this address any more, take it and shove it :-) Seriously, I suspect something is programmed into their DHCP to cause it to ignore "released" IP addresses and assign the next available address to the client - even if the client had the recently released address.
My question is... How to I configure my CentOS DHCP to do something similar? Do not reuse an address until you have cycled though the whole available range - then start over from the bottom. I suspect there is a parameter in /etc/dhcp/dhcpd.conf but after reading though the man page I am a bit overwhelmed and nothing has popped out that seems to meed my need.
I tend to keep the IPs on my LAN so I can find my other machines - I have a naming scheme. On the other hand on the Internet...
When I got my first DSL service many years ago I had a router which could be configured to email the log file when it was filled. This combined with the ISP providing an SMTP service which did not require credentials when accessed from the ISP's network allowed me to email the logs to myself for study. I wrote a program to parse out the logs and generate statistics on what had been blocked. Just out of curiosity.
One evening the emails started to roll in one after another. I grabbed some and ran them through my analysis routine. I got 3000 + bogus hits in about 10 minutes - all from the same address and on the same port. Turns out the port was the one assigned to CUPS. It appeared that someone configured their printer to MY IP address. I did a release/renew on the router which gave me a new address and stopped the avalanche of printer traffic. Since then I go in every night and grab a new address - sort of a housekeeping thing just to impede advertisers a little if nothing else.
Which brings me to funny anecdote #2. A bank, to remain nameless, decided that my account had been hacked (t wasn't) and after a battle royal with them trying to find out what was going on... One of their "security" staff noticed that each time I logged onto my account it was from a different location in North Carolina, South Carolina or Virginia. So my account must have been hacked. This was obviously the result of getting a different IP address (and geo-location) each night. It seemed beyond their mental capacity to imagine that I might actually TRAVEL between 3 contiguous states and connect occasionally while I was on the road. Oh well.
As to configuring my home DHCP... I was hoping there was a simple setting available. It is not something I NEED so I guess I will table it for now.
Thanks again,
Ken
p.s. Funny anecdote #3 - True story - many many years ago the company's mainframe provided a bank of modems for remote access - good for checking on jobs late at night etc. They were arranged in a similar fashion to the DHCP address scheme. When you dialed in you got the lowest numbered modem which was open. One evening I got a page about a job issue. When I tried to dial in I could not connect (found out the next day it was a bad modem). I tried and tried and tried... Finally I called data center operations. The solution was for one of them to try and dial in - which took the bad modem "off hook" while I then dialed in and got the next, working modem
You can configure DHCP servers (including those in routers) to assign fixed IP-addresses to certain devices based on their "MAC address" (network-interface hardware ID). The server recognizes "this particular device," always assigns this device the designated IP, and withdraws this IP from its pool so that it will never be assigned to any other device for any length of time.
This is important for, for example, port-forwarding. You have to be able to be sure that the IP-address you're forwarding to always refers to a particular machine or network-attached device, and this is the way that you do it.
Last edited by sundialsvcs; 04-07-2017 at 11:24 AM.
The link might help get a better understanding of how addresses are assigned. The newer version of the ISC dhcpd server does not assign addresses in numerical order any more. As jefro stated you might be able to achieve your goal by changing the lease files and MAC.
Thanks for the link, michaelk.
I make very limited use of DHCP, my server has only a range of 20 addresses to lease. Everything that can be wired is wired and has static addresses. Makes life easier.
An great read. More than I will ever need to know about DHCP but I will keep it handy.
An excellent point Emerson. I guess I could do without a DHCP server. I have 10 physical devices, all of which have reserved addresses. These of course could be hard coded. As to my VMs - I could use VMWare's NAT feature and share the connection on the host.
I mostly use address reservation versus a static address. About the same effort to configure devices either way IMHO. I also use dnsmasq for a local DNS / DHCP server.
I keep DHCP server running only for some wireless devices as phones. Most of my computers do not have DHCP client installed. It will save perhaps only 1 MB of RAM usage, but if it is not needed ...
You folks are starting to bum me out. I was so proud when I got my DHCP server up and running. You have pointed out, quite correctly I admit, that I do not really need it
My first "network" consisted of a home made server running Samba on Red Hat 7 (not RHEL but the original Red Hat Linux) and operating as a file and print server. Attached to it by way of a 10/100 switch were a couple of Windoze PCs. All the addresses were hard coded. When I eventually got a high speed Internet connection and a router - with DHCP - I though I had made the big time Sort of like a REAL network!
I DO appreciate all the input to my original question. I think I will leave well enough alone for now. My system is working and the non reissue of IP addresses was more of a curiosity than an need.
Regards,
Ken
p.s. I tend to use "reserved address" and "static address" interchangeably - perhaps incorrectly. My devices each get the desired address when they ask DHCP server (based on MAC).
Indeed, a reserved address is static but is still using DHCP to acquire it versus an address that is assigned via a configuration file on the system itself.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.