8

The IT guy gave me an IP address outside of the DHCP dynamic pool range (I do not have a DHCP reservation). I'd like to set linux client's IP staticly, but still have it pull the DNS servers and domain name from DHCP.

Searches have only turned up hundreds of "DHCP VS STATIC IP!!!111" results, or people trying somehow to "protect" their network using DHCP.

I'm sure this can be done, I'm just not sure how to go about it. I should be able to do a DHCPINFORM then use the returned settings with my static IP. I see option dhcp-message-type in man dhcp-options, but I'm not sure where that goes. So (1) how do I get dhclient to use that option and (2) how do I hook this into the ifup scripts? (I'm going to have to do this on both an Ubuntu and a CentOS machine)

6
  • 3
    Why didn't you ask the admin for a reservation, instead of a static address?
    – Zoredache
    Apr 20, 2012 at 23:42
  • See this related question. serverfault.com/questions/127369/…. Setup, a reservation, set a fixed address in your client config in case the server is unavailable.
    – Zoredache
    Apr 20, 2012 at 23:48
  • You have answered your own question by mentioning that what you really need is a reservation. "It is vain to do with more what can be done with less."
    – Skyhawk
    Apr 21, 2012 at 0:01
  • This is a "how do I", not a "what should I do" question. You're all right, a reservation would be better, however I'd still like to know how to do this.
    – Codebling
    Apr 21, 2012 at 16:19
  • Could someone please explain why this is off topic? I don't see how a question about network infrastructure is off topic. Do I seriously need to rephrase the question as "how do I set up WPADP on my network?"
    – Codebling
    Apr 21, 2012 at 16:27

1 Answer 1

6

If you have a static IP, you usually configure all the things you get from DHCP manually. This includes DNS and other entries. Your administrator can give you the appropriate values. This is the preferred configuration for servers and other systems which need to work even if DHCP is down.

Alternately, your administrator can configure DHCP to provide your static IP address as a reservation. This will provide you the fixed address whenever you plug into that network, but allow you to obtain a different IP address when you plug into other networks. This works well for portable systems which need a static address. On many networks, your IP address will be essentially static unless you off the network for a long period of time even without a reservation.

As you are running Linux you can configure your static IP address in addition to the IP address provided by DCHP. Many DHCP clients allow this to be configured. On Debian (Ubuntu) based systems you can configure the IP address using a post-up statement to the DHCP setup in /etc/network/interfaces. A stanza like this:

auto eth0
iface eth0 inet dhcp
     post-up addr add 192.0.2.200 dev eth0
1
  • So in the 3rd case my NIC would have 2 IPs. So I'd have all the static settings plus everything from DHCP..That could work. Thanks!
    – Codebling
    Apr 21, 2012 at 16:34

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