8

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?

2
  • 2
    NEVER disconnect your network connection. EVER.
    – MDMoore313
    Commented Feb 14, 2014 at 21:38
  • 2
    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
    Commented Feb 18, 2014 at 3:10

3 Answers 3

11

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 of 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.

1
  • 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
    Commented Feb 18, 2014 at 3:10
10

The dhclient that NetworkManager calls should be the same regardless.

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 on 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.

2

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.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .