dhcp, resolv.conf and dhclient

I have a (RHEL 6) VM that needs a DHCP IP. I’ve added search options into resolv.conf manually but every time dhcp renews its lease, these are overwritten. I also want it to request a specific IP address. Turns out dhclient config files are handy:

1. Don’t use NetworkManager:

chkconfig NetworkManager off
service NetworkManager stop

Set NM_CONTROLLED=no in ifcfg-eth0

2. Edit (create if it doesn’t exist) the file: /etc/dhcp/dhclient-eth0.conf (or whatever interface you’re configuring) to contain something like:

send dhcp-requested-address XXX.XXX.XXX.XXX;
prepend domain-search "foo.bar.com","bar.com";

3. Test new config

ifdown eth0
ifup eth0

dhclient.conf and dhcp-options man pages for more.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s