Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The DHCP-provided IP on my laptop changes periodically. It runs CentOS 6.5 and uses NetworkManager.

My desktop, running Sabayon, on the same network, does not have this problem.

How can I get NetworkManager to renew an existing DHCP lease instead of getting a new one?

share|improve this question
1  
NEVER disconnect your network connection. EVER. –  BigHomie Feb 14 at 21:38
    
Well, sometimes I do need to take the laptop elsewhere, but in this case I'm not disconnecting anything. The IP address just sometimes changes. –  Chris Feb 18 at 3:10

3 Answers 3

The dhclient that NetworkManager calls should be the same irregardless.

On my Fedora 19 system I'm getting the following command run via NetworkManager when I allow it to connect:

/sbin/dhclient -d -sf /usr/libexec/nm-dhcp-client.action     \
  -pf /var/run/dhclient-wlp3s0.pid                           \
  -lf /var/lib/NetworkManager/dhclient-5117671a-6bc3-4f6f-a3c0-54e615efe85c-wlp3s0.lease \
  -cf /var/lib/NetworkManager/dhclient-wlp3s0.conf wlp3s0

You can go through and check the setup of dhclient by looking at the various configuration files it's making use of via the command line.

Statically assigning IPs by MAC

I'll mention this even though @DopeGhoti did as well, but, in general, you typically take your systems' MAC addresses and configure your DHCP server so that it statically assigns the same IP addresses to the same MAC addresses. This gives you the best of both worlds, where you can centrally manage this assignment, but still not have to manually configure it on each host.

But in your case it sounds strange to me that the client isn't simply renewing the same IP that it previously had. That's normally the default behavior in DHCP client/server setups so I would suspect that something isn't configured quite right on your DHCP client.

Example

This is just to illustrate what I'm suggesting, realize you'd have to do something similar, configuring your network in whatever device happens to be providing your DHCP service. If you we're running your own DHCP server you could do something like this per host in your /etc/dhcpd.conf:

host grinchy {
   hardware ethernet 00:26:C7:85:A7:20;  # wifi (thinkpad 410)
  fixed-address grinchy.bubba.net;
  # fixed-address 192.168.1.19;
}

Doing it this way the host requires no knowledge of the networking configuration, but could still be given a consistent, static, IP.

share|improve this answer

The proper term is a Lease Reservation. This is where you set a specific address on your DHCP server for a MAC address. This is NOT like a static IP in the sense that, if there are no more addresses, and your computer isn't using that one, it WILL BE given to another machine if needed. So, in essence, with DHCP, there is no way to 'guarantee' one particular address, but then again that's what DNS is for :-)

share|improve this answer
    
You can't do that from a dhcp server, only the client. Dhcp servers will only do lease reservations. Also, The proper method is to either set a lease reservation or assign static IPs on the client, setting aside space in the subnet outside the dhcp range. static IPs should NEVER be assigned from the dhcp range. –  BigHomie Feb 15 at 0:25
    
I've updated the comment, but I will also clarify. Static IPs being assigned from within the DHCP scope is bad practice. Period. Any Network admin worth their salt will tell you that. Using static IPs unecessarily (i.e., for misc clients, servers/printers are a different story) is also bad practice. For example, what if these are laptops, and a user just happens to take their machine somewhere else and connects to a different network? Lease Reservations are fine when needed, I'm not denying that, but statics are a different story. –  BigHomie Feb 15 at 0:41
    
@slm show me a dhcp server's config where you can assign a static IP that is not a lease reservation, and I will gladly delete my answer. –  BigHomie Feb 15 at 0:44
    
let us continue this discussion in chat –  BigHomie Feb 15 at 1:35
    
What DNS is for? LOL! Will DNS re-start your disrupted TCP streams? –  Kaz Feb 15 at 2:01

The best way to guarantee the same IP at all times for a given host is to set up a MAC Address IP reservation in the DHCP server. Get the MAC address if your laptop, then go to your DHCP server, and assign a specific IP address to be issued to a host requesting from that MAC address.

share|improve this answer
    
Yes, I could do this. I was hoping there was a fix to make my laptop behave properly so I wouldn't have it. –  Chris Feb 18 at 3:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.