How do I set a permanent nameserver value in the resolv.conf file?

General support questions
Post Reply
zetret
Posts: 6
Joined: 2017/06/17 16:36:07

How do I set a permanent nameserver value in the resolv.conf file?

Post by zetret » 2017/06/18 20:20:15

Good Evening

My resolv.conf file has the following entry;

Code: Select all

; generated by /usr/sbin/dhclient-script
nameserver <my_gateway_IP>
I don't want the name server to be my gateway IP. If I change it, it gets reset every time on reboot. I am confused by this. I searched for this, and someone said setting hooks fixes this, but that didn't work for me. How do I set a permanent nameserver value in the resolv.conf file?

Also, what's the recommended way to get my hostname to an FQDN?

Thanks

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How do I set a permanent nameserver value in the resolv.conf file?

Post by TrevorH » 2017/06/18 23:16:05

Your current nameserver is being given to you by your DHCP server - which is probably on your router. So it hands you your ip address and then tells dhclient that the gateway is itself and the nameserver should be set to itself too. You can probably find a setting somewhere in your router to adjust this - either stop it from sending out the nameserver altogether or change it to one of your choosing. If you cannot or do not want to, then you can also add PEERDNS=no to the /etc/sysconfig/network-scripts/ifcfg-$interface file. That will leave you free to edit /etc/resolv.conf and have your changes persist.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

mfroes
Posts: 1
Joined: 2017/09/25 00:58:08

Re: How do I set a permanent nameserver value in the resolv.conf file?

Post by mfroes » 2017/09/25 01:15:16

Hi I am having the same issue when using the latest centos7.
I have set the peerdns=no but still on network restart and computer reboot the domain comes back into the resolv.conf. Am I doing anything wrong here?


# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Automatically generated by the vm import process
DEVICE=eth0
PEERDNS=no
ONBOOT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
NM_CONTROLLED=no
#
# cat /etc/resolv.conf
; generated by /usr/sbin/dhclient-script
search test.dns.me
nameserver 172.20.0.2
#
# systemctl restart network
#
# cat /etc/resolv.conf
; generated by /usr/sbin/dhclient-script
search ap-southeast-2.compute.internal
nameserver 172.20.0.2

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How do I set a permanent nameserver value in the resolv.conf file?

Post by TrevorH » 2017/09/25 13:09:29

Try adding SEARCH=test.dns.me
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Post Reply