My /etc/resolv.conf is getting reset every time i restart the network

Issues related to configuring your network
Post Reply
smidhunraj
Posts: 1
Joined: 2018/10/09 11:39:30

My /etc/resolv.conf is getting reset every time i restart the network

Post by smidhunraj » 2018/10/09 11:43:34

This is my /etc/resolv.conf on CentOS 7

Code: Select all

# Generated by NetworkManager
search example.com
nameserver 10.0.2.3
~                   
This is my /etc/sysconfig/network-scripts/ifcfg-eth0

Code: Select all

DEVICE=eth0
BOOTPROTO=dhcp
DEFROUTE="yes"
ONBOOT="yes"
TYPE=Ethernet
PERSISTENT_DHCLIENT="yes"
ZONE=public
DNS="192.168.33.11"
PROXY_METHOD=none
BROWSER_ONLY=no
IPADDR=192.168.33.11
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
Whenever i try to restart the network using systemctl restart network after adding nameserver 192.168.33.11 it gets reset to the one on above. What changes should I make to ifcfg-eth0 so that i my new nameserver doesn't get erased even on restart.

tunk
Posts: 444
Joined: 2017/02/22 15:08:17

Re: My /etc/resolv.conf is getting reset every time i restart the network

Post by tunk » 2018/10/09 12:46:50

BOOTPROTO=dhcp
Try to set it to BOOTPROTO=none, and maybe remove PERSISTENT_DHCLIENT="yes".

User avatar
jlehtone
Posts: 2018
Joined: 2007/12/11 08:17:33
Location: Finland

Re: My /etc/resolv.conf is getting reset every time i restart the network

Post by jlehtone » 2018/10/09 14:38:49

Code: Select all

# Generated by NetworkManager
Do you think that comment originates from network.service?

There are NetworkManager.service and network.service. They are not mutually exclusive, but the coexistence is somewhat strained. The NetworkManager is the default. It is usable.

Can we assume that you have explicitly chosen to disable the NM? (By the config we see that such assumption is false.)

You try to add config for one service, but let the other service "do its thing", which does not include caring about (right or wrong) config of the other service.


You have a DHCP server out there, somewhere. It does offer some DNS server for you. You don't like that. You prefer a server in entirely different subnet. Do we have to assume that you have no control on the DHCP server? That there are differences on the DNS servers?

Post Reply