LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-06-2017, 07:53 PM   #1
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Rep: Reputation: 174Reputation: 174
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.

TIA,

Ken
 
Old 04-06-2017, 08:47 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,826

Rep: Reputation: 3610Reputation: 3610Reputation: 3610Reputation: 3610Reputation: 3610Reputation: 3610Reputation: 3610Reputation: 3610Reputation: 3610Reputation: 3610Reputation: 3610
Might be a number or ways to do that. All of them complex I'd think. No single statement that I know of would do that.

You might be able to change how leases are managed at server versus client so that server holds the lease longer.

Might be able to write some script to manage leases based on some action.

Might be able to rotate mac addresses on client and manage per mac on server.

I forget how the windows server course had you do it.

Bet there are other ways.

Most people are looking to keep ip's.
 
1 members found this post helpful.
Old 04-06-2017, 10:16 PM   #3
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
Thanks jefro,

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
 
Old 04-07-2017, 11:22 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,424
Blog Entries: 4

Rep: Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838
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.
 
Old 04-07-2017, 12:05 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,015

Rep: Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684
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.

https://www.isc.org/wp-content/uploa...on-20-4-10.pdf

Last edited by michaelk; 04-07-2017 at 12:44 PM.
 
2 members found this post helpful.
Old 04-07-2017, 12:24 PM   #6
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
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.
 
Old 04-07-2017, 12:33 PM   #7
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
Thanks sundialsvcs,

I am doing that for a number of devices e.g. my laser printer. The entry in /etc/dhcp/dhcpd.conf
Code:
host Brother_HL5170DN {
 hardware ethernet 00:80:77:3A:75:C7; 
 fixed-address 10.42.0.101; 
}
Thanks michaelk,

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.

Thanks again all,

Ken
 
Old 04-07-2017, 12:56 PM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,015

Rep: Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684
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.
 
Old 04-07-2017, 01:03 PM   #9
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Code:
subnet 192.168.2.0 netmask 255.255.255.0 {
    range 192.168.2.20 192.168.2.40;
    option ntp-servers 192.168.2.250;
    option routers 192.168.2.254;
}
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 ...

Last edited by Emerson; 04-07-2017 at 01:04 PM.
 
Old 04-07-2017, 07:31 PM   #10
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
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).
 
Old 04-07-2017, 07:39 PM   #11
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,015

Rep: Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684Reputation: 5684
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how do you reserve ip addresses in a dhcp server baronobeefdip Linux - Networking 7 10-06-2011 11:50 AM
How to view DHCP Server Used ip addresses from GUI sridhar11 Red Hat 1 03-08-2008 08:26 PM
DHCP Server Not Assigning Addresses jimsproch Linux - Server 4 07-04-2007 10:18 AM
DHCP server delivers addresses in reverse order sagif Linux - Networking 3 02-14-2004 01:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:39 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