In this section, we will take a look at DNS in the Linux
ping
command. Checking the reachability of the IP Addr on the Network.$ ping 172.17.0.64
PING 172.17.0.64 (172.17.0.64) 56(84) bytes of data.
64 bytes from 172.17.0.64: icmp_seq=1 ttl=64 time=0.384 ms
64 bytes from 172.17.0.64: icmp_seq=2 ttl=64 time=0.415 ms
$ ping web
ping: unknown host web
/etc/hosts
file to resolve by their hostname.$ cat >> /etc/hosts
172.17.0.64 web
# Ctrl + c to exit
/etc/hosts
file.$ ping web
PING web (172.17.0.64) 56(84) bytes of data.
64 bytes from web (172.17.0.64): icmp_seq=1 ttl=64 time=0.491 ms
64 bytes from web (172.17.0.64): icmp_seq=2 ttl=64 time=0.636 ms
$ ssh web
$ curl http://web
/etc/resolv.conf
.$ cat /etc/resolv.conf
nameserver 127.0.0.53
options edns0
/etc/nsswitch.conf
file.$ cat /etc/nsswitch.conf
hosts: files dns
networks: files
$ ping wwww.github.com
ping: www.github.com: Temporary failure in name resolution
/etc/resolv.conf
file.$ cat /etc/resolv.conf
nameserver 127.0.0.53
nameserver 8.8.8.8
options edns0
$ ping www.github.com
PING github.com (140.82.121.3) 56(84) bytes of data.
64 bytes from 140.82.121.3 (140.82.121.3): icmp_seq=1 ttl=57 time=7.07 ms
64 bytes from 140.82.121.3 (140.82.121.3): icmp_seq=2 ttl=57 time=5.42 ms
$ nslookup www.google.com
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: www.google.com
Address: 172.217.18.4
Name: www.google.com
$ dig www.google.com
; <<>> DiG 9.11.3-1 ...
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8738
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;www.google.com. IN A
;; ANSWER SECTION:
www.google.com. 63 IN A 216.58.206.4
;; Query time: 6 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)