Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to assign the DNS servers to a Virtual Machine via DHCP, but I want the machine to have a static IP address. I cannot use a reservation and go through the usual DHCP process because the VM gets cloned to other datacenters and

  1. the MAC address will change
  2. I want the DNS to be assigned without having to fix the DHCP server configuration.

I think I can use DCHPINFORM messages, but I did not find how (I am using an Ubuntu 12.04 image, btw)

Thanks in advance for any hint.

share|improve this question
    
So you want to be able to set the IP of the DNS server statically and have that information automatically propagated to the DHCP server for distribution to dynamic clients? Is that an accurate description of what you're trying to do? –  rnxrx May 29 '12 at 16:07
    
no it's not :) I want to set the IP address of a certain machine statically, and make it ask for the DNS servers using DHCP, without being assigned an IP address over DHCP. I think this should be possible using DHCPINFORM messages. –  garph0 May 29 '12 at 16:20

2 Answers 2

up vote 1 down vote accepted

Got it - thanks for the clarification. There are a few ways to do this, but the easiest might just be to take a look at the script called by the DHCP client (/sbin/dhclient-script, oddly enough). This script is passed a series of values, including the IP address of the lease. Edit the script to prevent it from actually setting the IP - possibly based on a conditional to look for the presence of a defined permanent IP. You could take as much - or as little - info from DHCP as you'd like.

share|improve this answer
    
Thanks for the idea, but I'm not sure that this is going to work as expected: the server would still think that the machine got a lease: what happens with dynamic DNS updates from DHCP? I think that the DNS would register a dynamic entry with the wrong IP. –  garph0 May 29 '12 at 21:23
    
You could send a fake hostname with the DHCP registration and then use nsupdate (called from the post-bind script) to push the real hostname with your fixed IP... Overall it's not pretty, but the right answer would tend to be a static lease on the server side. –  rnxrx May 29 '12 at 21:30
    
Ok, I am accepting this because it's the closest thing to a solution :) Should someone be interested, we decided to clone the VM using a script that will spawn a new machine, wait for it to be up and running, then connect to it and configure as needed. –  garph0 Jun 1 '12 at 15:05

Another option, not sure if its viable since you say the machine is cloned but why not configure a static MAC address on the VM config? That solves your DHCP reservation lease issue, right?

share|improve this answer
    
that would mean having two machines, possibly on the same network, with the same mac address –  garph0 May 29 '12 at 21:21
    
OK, it wasn't real clear from your post if the multiple data centers shared the same network subnet or not. You said it would change but that was a given with a dynamic MAC address. –  Brent Pabst May 29 '12 at 22:07

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.