iT邦幫忙

第 12 屆 iThome 鐵人賽

0
自我挑戰組

30天菜鳥學 Linux 系列 第 42

第42篇-學習 DNS Server - 2

今天學習進度還是 鳥哥的 Linux 私房菜 -- DNS Server

/etc/nsswitch.conf :設定查詢主機名稱的順序,像我的就是 passwd 優先

test@test:~$ cat /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         files systemd
group:          files systemd
shadow:         files
gshadow:        files

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

名稱檢吸器/etc/hosts,可以知道為何 localhost 對應 127.0.0.1 這個IP

test@test:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 test

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

鳥哥建議 DNS 伺服器的 IP 可以設定 2 個,但不要超過 3 個
可以在 /etc/resolv.conf 做設定

test@test:~$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0
search mshome.net

測試 DNS 方式

test@test:~$  host yahoo.com.tw
yahoo.com.tw has address 212.82.100.150
yahoo.com.tw has address 98.136.103.23
yahoo.com.tw has address 74.6.136.150
yahoo.com.tw mail is handled by 10 mx-tw.mail.gm0.yahoodns.net.


host -a 方式

test@test:~$ host -a yahoo.com.tw
Trying "yahoo.com.tw"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26368
;; flags: qr rd ra; QUERY: 1, ANSWER: 11, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;yahoo.com.tw.			IN	ANY

;; ANSWER SECTION:
yahoo.com.tw.		0	IN	A	98.136.103.23
yahoo.com.tw.		0	IN	A	74.6.136.150
yahoo.com.tw.		0	IN	A	212.82.100.150
yahoo.com.tw.		0	IN	NS	ns2.yahoo.com.
yahoo.com.tw.		0	IN	NS	ns3.yahoo.com.
yahoo.com.tw.		0	IN	NS	ns1.yahoo.com.
yahoo.com.tw.		0	IN	NS	ns5.yahoo.com.
yahoo.com.tw.		0	IN	NS	ns4.yahoo.com.
yahoo.com.tw.		0	IN	SOA	hidden-master.yahoo.com. hostmaster.yahoo-inc.com. 2020081800 3600 900 604800 600
yahoo.com.tw.		0	IN	MX	10 mx-tw.mail.gm0.yahoodns.net.
yahoo.com.tw.		0	IN	TXT	"v=spf1 redirect=_spf.mail.yahoo.com"

Received 339 bytes from 127.0.0.53#53 in 312 ms

test@test:~$ nslookup yahoo.com.tw
Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	yahoo.com.tw
Address: 212.82.100.150
Name:	yahoo.com.tw
Address: 98.136.103.23
Name:	yahoo.com.tw
Address: 74.6.136.150

反解、正解測試

# 反解
test@test:~$ nslookup
> 120.114.100.20
20.100.114.120.in-addr.arpa	name = mail-out-r2.ksu.edu.tw.
20.100.114.120.in-addr.arpa	name = mail.ksu.edu.tw.
20.100.114.120.in-addr.arpa	name = mail-smtp-proxy.ksu.edu.tw.

# 正解
> mail.ksu.edu.tw
Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	mail.ksu.edu.tw
Address: 120.114.100.20

紀錄 : 下一篇學習 鳥哥的 Linux 私房菜 -- DNS Server - 從 dig 指令開始


上一篇
第41篇-嘗試建立 java 環境並運行 helloworld
下一篇
第43篇-IT邦 的 DNS 、憑證都快過期了?!
系列文
30天菜鳥學 Linux 59
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言