If you want to override the dhcp provided dns server, to a custom internal dns server, then you need to make the configuration via NetworkManager.
Announcement
You can find all my latest posts on medium.You can follow along with this article using our dns demo vagrant environment.
Let’s say your custom dns server’s ip address is 192.170.10.100, then before you do any configurations to start using it, first you should test to see that you can connect to it:
[root@dns-client ~]# nc -v 192.170.10.100 53 Ncat: Version 6.40 ( http://nmap.org/ncat ) Ncat: Connected to 192.170.10.100:53.
If that works, then the next thing to do is manually test the dns server by seding a test query:
[root@dns-client ~]# dig @192.170.10.100 sherc.sg-host.com ; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7_4.2 <<>> @192.170.10.100 sherc.sg-host.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59367 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;sherc.sg-host.com. IN A ;; ANSWER SECTION: sherc.sg-host.com. 9510 IN A 77.104.171.177 ;; AUTHORITY SECTION: sherc.sg-host.com. 81510 IN NS ns2.ukm11.siteground.biz. sherc.sg-host.com. 81510 IN NS ns1.ukm11.siteground.biz. ;; ADDITIONAL SECTION: ns2.ukm11.siteground.biz. 9510 IN A 77.104.171.111 ns1.ukm11.siteground.biz. 9510 IN A 77.104.132.42 ;; Query time: 0 msec ;; SERVER: 192.170.10.100#53(192.170.10.100) ;; WHEN: Sat Apr 07 13:09:17 UTC 2018 ;; MSG SIZE rcvd: 146
To configure your client to point to the new dns server, you need to edit /etc/resolv.conf
. This file content in turn is managed via NetworkManager. Any existing dns IP addresses comes from the DHCP protocol. Therefore to edit this files content, we have to do it using NetworkManager. To override dchp's provided dns addresses, you can do it either via the NetworkManager's gnome gui:
$ nm-connection-editor
or via the nmcli interactive terminal. We'll demo the nmcli approach. First we get a list of active connections:
$ nmcli connection show
First we disable dhcp setting the dns address:
$ nmcli connection modify System\ enp0s8 ipv4.ignore-auto-dns yes
Then for the chosen connection run the command (use tab+tab to help create this command):
$ nmcli connection modify System\ enp0s8 ipv4.dns '192.170.10.100'
Behind the scenes this will end up changing adding a 'DNS1' setting to the corresponding /etc/sysconfig/network-scripts/ifcfg-*
file.
[post-content post_name=rhsca-quiz]
/etc/resolv.conf
# the content of this is managed via NetworkManager
$ nm-connection-editor
$ nmcli connection show
$ nmcli connection modify {connection-name} ipv4.ignore-auto-dns yes
$ nmcli connection modify {connection-name} ipv4.dns '192.170.10.100'
answer
answer
answer
answer