Contents

Network DNS

Ping to PC A

/network-dns/network-hosts.png

Ping to IP

1
2
3
4
ping 192.168.1.11

Reply from 192.168.1.11: bytes=32 time=4ms TTL=117
Reply from 192.168.1.11: bytes=32 time=4ms TTL=117

Ping to Name

1
2
3
ping db

ping: unknown host db

Config /etc/hosts

Private Name

In PC B

1
2
3
hostname

host-2

In PC A

Ping to Name
1
2
3
ping db

ping: unknown host db
Append to /etc/hosts
1
echo "192.168.1.11    db" >> /etc/hosts
Ping to Name Again
1
2
3
4
5
ping db

PING db (192.168.1.11) 56(84) bytes of data.
64 bytes from db (192.168.1.11): icmp_seq=1 ttl=64 time=0.052 ms
64 bytes from db (192.168.1.11): icmp_seq=2 ttl=64 time=0.079 ms

Public Domain

Ping to Google

1
2
3
4
5
6
ping www.google.com

PING www.google.com (172.217.174.100): 56 data bytes
64 bytes from 172.217.174.100: icmp_seq=0 ttl=116 time=61.795 ms
64 bytes from 172.217.174.100: icmp_seq=1 ttl=116 time=32.837 ms
64 bytes from 172.217.174.100: icmp_seq=2 ttl=116 time=83.736 ms

Append to /etc/hosts

1
echo "192.168.1.11    db" >> /etc/hosts

Ping to Google Again

1
2
3
4
5
ping www.google.com

PING www.google.com (192.168.1.11) 56(84) bytes of data.
64 bytes from www.google.com (192.168.1.11): icmp_seq=1 ttl=64 time=0.052 ms
64 bytes from www.google.com (192.168.1.11): icmp_seq=2 ttl=64 time=0.079 ms

Name Resolution

Name Resolution
Below system and hosts, it can make to connect each PC.
But, there are big problem!
If you need to add or change /etc/hosts, you have to change the /etc/hosts file each PC.

System Diagram

/network-dns/network-name-resolution.png

/etc/hosts

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
192.168.1.10  web
192.168.1.11  db
192.168.1.12  nfs
192.168.1.21  db-1
192.168.1.22  nfs-1
192.168.1.23  web-1
192.168.1.51  db-2
192.168.1.53  nfs-2
192.168.1.72  web-2
192.168.1.73  db-3
192.168.1.74  nfs-3
192.168.1.75  web-3
192.168.1.94  db-4
192.168.1.96  nfs-4
192.168.1.101  web-4

DNS

Domain Name System
I notice to you the problem of Name Resolution System.
DNS is a solution to manage hosts in a system.

DNS Diagram

/network-dns/network-dns.png

DNS Server Config

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
192.168.1.10  web
192.168.1.11  db
192.168.1.12  nfs
192.168.1.21  db-1
192.168.1.22  nfs-1
192.168.1.23  web-1
192.168.1.51  db-2
192.168.1.53  nfs-2
192.168.1.72  web-2
192.168.1.73  db-3
192.168.1.74  nfs-3
192.168.1.75  web-3
192.168.1.94  db-4
192.168.1.96  nfs-4
192.168.1.101  web-4

DNS Client Config

/etc/resolv.conf

1
2
3
cat /etc/resolv.conf

nameserver 192.168.1.100

/etc/nsswitch.conf

1
cat /etc/nsswitch.conf
1
2
3
...
hosts:          files dns
...

Domain Names

Domain System Example

Request apps.google.com

1
2
3
4
5
ping apps.google.com

PING www3.l.google.com (216.58.220.142): 56 data bytes
64 bytes from 216.58.220.142: icmp_seq=0 ttl=116 time=37.414 ms
64 bytes from 216.58.220.142: icmp_seq=1 ttl=116 time=44.157 ms

DNS Record Types

TypeDescriptionExample
AIPv4192.168.1.1
AAAIPv62001:0db8:85a3:0000:0000:8a2e:0370:7334
CNAMEDomain Nametest.web-server.com,test.api-server.com

Tools

nslookup

1
nslookup www.google.com
1
2
3
4
5
6
7
8
Server:		192.168.65.2
Address:	192.168.65.2#53

Non-authoritative answer:
Name:	www.google.com
Address: 216.58.220.132
Name:	www.google.com
Address: 2404:6800:4004:810::2004

dig

1
dig www.google.com
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
; <<>> DiG 9.16.1-Ubuntu <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56513
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.google.com.			IN	A

;; ANSWER SECTION:
www.google.com.		250	IN	A	172.217.31.164

;; Query time: 6 msec
;; SERVER: 192.168.65.2#53(192.168.65.2)
;; WHEN: Sat May 29 08:36:57 UTC 2021
;; MSG SIZE  rcvd: 48