[rhelv6-list] resolv.conf being overwritten by NetworkManager

Red Hat Enterprise Linux 6 (Santiago) discussion mailing-list rhelv6-list at redhat.com
Tue Mar 19 19:30:22 UTC 2013


On Fri, Mar 16, 2012 at 3:34 PM, Musayev, Ilya <imusayev at webmd.net> wrote:

> Uncertain how the change came about, i can only add a suggestion, instead
> of changing each ifcfg-ethX file, you can do:
> Place following code in /etc/dhclient-enter-hooks file:
> # vi /etc/dhclient-enter-hooks
> Append code:
> make_resolv_conf(){
>         :
> }
> Or slightly brutal approach "chattr +i /etc/resolv.conf" - this needs to
> be use as a last resort
>

Actually, the solution in RHEL6 (and even upstream) is even easier than
this.  Whether you're using NetworkManager or the network init, "dhclient"
is usually the default program managing the actual interfaces.

So in the files:
 - /etc/dhcp/dhclient.conf (default for all interfaces)
 - /etc/dhcp/dhclient-<if>.conf (for a specific interface)

You can use the following option modifiers.
 - default - set a local default, which is overriden by DHCP provided
option, unless not provided by DHCP
 - supersede - always override the DHCP provided option with the local
supercede
 - prepend - insert a local prepend, which is in the list prior to the DHCP
provided option, for those options that allow multiple values
 - append - add a local append, which is in the list after the DHCP
provided option, for those options that allow multiple values

E.g.,

  #
  # /etc/dhcp/dhclient.conf
  # System-wide defaults for all DHCP interfaces
  #
  # Set to Google's servers, unless DHCP provided
  default domain-name-servers 8.8.8.8 ;
  # Use Google's servers after the DHCP provided
  append domain-name-servers 8.8.8.8 ;
  # Insert another domain first in search order, before DHCP provided
  prepend domain-search "mycorp.com" ;
  # Always set my subdomain name, period, drop the DHCP provided
  supercede domain-name "mynet.mycorp.com"

And your /etc/resolv.conf should be modified appropriately, even _run-time_
when a new DHCP lease is granted, as these are set in the "dhclient"
configuration files.

-- bjs

References:
- man 5 dhclient.conf (the option modifiers)
- man 5 dhcp-options (the options themselves)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/rhelv6-list/attachments/20130319/3526cf3d/attachment.htm>


More information about the rhelv6-list mailing list