2

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.

2
  • 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, 2012 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, 2012 at 16:20

2 Answers 2

1

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.

3
  • 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, 2012 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, 2012 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, 2012 at 15:05
-1

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?

2
  • that would mean having two machines, possibly on the same network, with the same mac address
    – garph0
    May 29, 2012 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. May 29, 2012 at 22:07

You must log in to answer this question.

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