Sunday 3 May 2015

Configuring Centos with a DHCP Reservation

Sigh.. I'm sure I struggled with this the last time I had to do it. Hence I am writing a little note for next time!

The scenario:

  • Windows 2003 Server running a DHCP server
  • Centos 6.4 VM I want to automatically allocate a static address to. Essentially I don't want to hard-code the IP address/DNS server addresses in the VM's config. I want it to get these automatically from DHCP but as the VM will act as a server I need the IP to be static and for the machine to be locatable via DNS.
So initially Centos is installed and the machine boots with whatever default address got allocated to it. Right click the connection icon at the top left of the screen and choose Connection Information. You will get this screen:

Select and copy the hardware address. Logon to the windows 2003 machine where the DHCP server is running and run the DHCP configuration tool for Administrative Tools.

Open the scope, right click reservations and add a reservation like this (sorry I blotted out the domain name).


Paste in the hardware address and delete the colons (:).

The description doesn't matter. Leave the DNS settings as default.

Now go back to centos, right click the connection icon, choose Edit Connections, select the  System Eth0 connection and click edit.

For some reason when  I first installed the system, the network interface was configured NOT to start at boot time. This is pretty annoying as you have to connect to the console to get the machine running. Set it to connect automatically

Initially I thought I had to set the DHCP client ID. After many reboots I figured out if I set this it wouldn't work! If I just set it to blank the DHCP server gives the machine the right address and we are all good. Apply the changes, enter your root password and let it save.

In the Windows DHCP config tool, find the current reservation for the machine, right click and select delete. If you really want to be sure restart the DHCP server (right click the node below DHCP, choose All Tasks and restart). Then in Centos click the network icon, click System eth0, wait for the spinning to stop and then check the connection settings again. It now should have the configured IP.

Then I found that for whatever reason the DNS still doesn't automatically get this new entry even though the DHCP server is supposed to update it.

On Windows 2003 server, open the DNS management tool from Administrative tools, open the forward lookup zone and open your zone. Right click and choose New Host (A). Enter the name of the host (just the short part so centosdev in my case). Enter the IP address. I left the 'Create associated pointer (PTR) record checked but I got an error when I hit add host saying it couldn't. It still works so I'm not worried. This is probably because I am running on a non-routable address range.

My client computer (i.e. the computer I am accessing the centos server with) is a Windows 7 machine. I did a ipconfig /renew and then I was able to ping the new computer by name and I was able to access it via VNC.

No comments:

Post a Comment