顯示具有 DNS 標籤的文章。 顯示所有文章
顯示具有 DNS 標籤的文章。 顯示所有文章

2025年10月17日 星期五

[研究]DNS 網址對應 IP 變更後,在 Internet 生效要多久?為什麼?

[研究]DNS 網址對應 IP 變更後,在 Internet 生效要多久?為什麼?

2025-10-17

DNS 網址對應 IP 變更後,在 Internet 生效要多久?為什麼?

ChatGPT

所需時間取決於幾個關鍵因素。以下是詳細說明:

🕒 一、主要影響生效時間的因素

1️⃣ TTL(Time To Live)值

  • TTL 是最關鍵的因素。
  • 每筆 DNS 記錄(A、AAAA、CNAME…)都會設定 TTL 秒數,代表「快取多久」。
  • 當 DNS Client(或中間的 DNS 伺服器)查到這筆記錄後,會在 TTL 期間內「不再重查」權威伺服器。

TTL 設定 生效時間影響
86400 秒 (1天) 最慢可能要 24 小時才全網更新
3600 秒 (1小時) 約 1 小時內陸續生效
300 秒 (5分鐘) 幾分鐘內生效(最快)

所以,若預期要更換 IP,建議 提前降低 TTL 到 300 秒 或 600 秒,等變更完成後再調回長值。

****************************************
2️⃣ DNS 快取層級

DNS 有多層快取,每層都可能影響生效時間:
層級 位置 說明
使用者端快取 作業系統 (Windows/macOS/Linux) 或瀏覽器 例如 Windows DNS Cache、Chrome 內建快取
本地 DNS Resolver ISP 或公司內部 DNS 常會快取 TTL 時間內的紀錄
公用 DNS Google (8.8.8.8)、Cloudflare (1.1.1.1) 也遵守 TTL,但有時會有短暫延遲清除
權威 DNS 你的網域託管商 變更後立即更新,這是源頭,但其他層要等 TTL 過期才會重新查詢

****************************************
3️⃣ DNS 傳播與全球同步

  • 全球不同地區的 DNS 伺服器各自快取結果,因此會有「傳播延遲」(propagation delay)。

  • 一般來說,1 小時~24 小時 內會陸續同步完成。

  • 在 TTL 設很長(如 86400 秒)的情況下,部分使用者仍會暫時解析到舊 IP。

****************************************

🌐 二、實務觀察的時間範圍

狀況 典型生效時間
TTL 設為 5 分鐘 通常 5~15 分鐘內全網更新
TTL 設為 1 小時 約 1~3 小時內更新
TTL 設為 24 小時 最慢要等到 24 小時(甚至 48 小時)

****************************************

⚙️ 三、檢查 DNS 是否已更新

你可以用以下工具檢查不同地區是否已生效:

🔹 https://www.whatsmydns.net/

(可查全球 DNS 傳播狀況)

🔹 Windows:

nslookup example.com   
ipconfig /flushdns

🔹 macOS/Linux:

dig example.com
sudo dscacheutil -flushcache   

****************************************

📘 四、為什麼會「延遲生效」

因為 DNS 系統是分散式快取架構,為了效率,全球 DNS 都會暫存解析結果。

當 IP 變更時,舊的快取要等到 TTL 過期,才會被捨棄並重新查詢新 IP,因此更新不是即時的。

✅ 結論重點:

  • DNS IP 變更在 Internet 生效時間 = TTL 時間 + 各層快取清除延遲
  • 一般為 幾分鐘到 24 小時不等,具體取決於你設定的 TTL 值。

(完)

相關

網域名稱註冊並設定 DNS 後,多久才能開始使用?
https://twnoc.net/support/Knowledgebase/Article/View/2/2

甚麼是 DNS 傳播
https://www.digicert.com/tw/faq/dns/what-is-dns-propagation

中華電信 - ISP 級的 DNS 服務
https://prodns.hinet.net/


2025年5月16日 星期五

[研究]DNS Server連線測試與版本檢查

[研究]DNS Server連線測試與版本檢查

2025-05-16

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

DNS Server 連線測試

telnet  168.95.1.1  53 測試連 HiNet DNS Server

下圖,可以連
telnet  168.95.1.1  53 測試連 Google DNS Server
下圖,可以連


telnet  127.0.0.1 測試連 Windows Server 2025 Standard 安裝 DNS Server



********************************************************************************
DNS Server 版本測試 (用 nmap)

測試 HiNET DNS Server,看不出 DNS Server 種類與版本

C:\>nmap -sU -sV -p 53 168.95.1.1
Starting Nmap 7.95 ( https://nmap.org ) at 2025-05-16 08:58 ¥x¥_?D·CRE?!
Nmap scan report for dns.hinet.net (168.95.1.1)
Host is up (0.0060s latency).

PORT   STATE SERVICE VERSION
53/udp open  domain  Unbound

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 0.30 seconds

C:\>

測試 Google DNS Server,看不出 DNS Server 種類與版本

C:\>nmap -sU -sV -p 53 8.8.8.8
Starting Nmap 7.95 ( https://nmap.org ) at 2025-05-16 08:57 ¥x¥_?D·CRE?!
Nmap scan report for dns.google (8.8.8.8)
Host is up (0.28s latency).

PORT   STATE SERVICE VERSION
53/udp open  domain  (generic dns response: NOTIMP)
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port53-UDP:V=7.95%I=7%D=5/16%Time=68268D91%P=i686-pc-windows-windows%r(
SF:DNSVersionBindReq,1E,"\0\x06\x81\x82\0\x01\0\0\0\0\0\0\x07version\x04bi
SF:nd\0\0\x10\0\x03")%r(DNS-SD,79,"\0\0\x80\x83\0\x01\0\0\0\x01\0\0\t_serv
SF:ices\x07_dns-sd\x04_udp\x05local\0\0\x0c\0\x01\0\0\x06\0\x01\0\x01Q\x10
SF:\0@\x01a\x0croot-servers\x03net\0\x05nstld\x0cverisign-grs\x03com\0x\xb
SF:3\xd5n\0\0\x07\x08\0\0\x03\x84\0\t:\x80\0\x01Q\x80")%r(NBTStat,32,"\x80
SF:\xf0\x80\x92\0\x01\0\0\0\0\0\0\x20CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\0\0!
SF:\0\x01");

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 26.52 seconds

C:\>

測試連 Windows Server 2025 Standard 安裝 DNS Server (關閉 Windows Defender 防火牆後),看不出 DNS Server 種類與版本

C:\>ping 192.168.128.144

Ping 192.168.128.144 (使用 32 位元組的資料):
回覆自 192.168.128.144: 位元組=32 時間<1ms TTL=128
回覆自 192.168.128.144: 位元組=32 時間<1ms TTL=128
回覆自 192.168.128.144: 位元組=32 時間<1ms TTL=128
回覆自 192.168.128.144: 位元組=32 時間<1ms TTL=128

192.168.128.144 的 Ping 統計資料:
    封包: 已傳送 = 4,已收到 = 4, 已遺失 = 0 (0% 遺失),
大約的來回時間 (毫秒):
    最小值 = 0ms,最大值 = 0ms,平均 = 0ms

C:\>
C:\>nmap -sU -sV -p 53 192.168.128.144
Starting Nmap 7.95 ( https://nmap.org ) at 2025-05-16 09:57 ¥x¥_?D·CRE?!
Nmap scan report for 192.168.128.144
Host is up (0.00s latency).

PORT   STATE SERVICE VERSION
53/udp open  domain  (generic dns response: NOTIMP)
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port53-UDP:V=7.95%I=7%D=5/16%Time=68269B9B%P=i686-pc-windows-windows%r(
SF:DNS-SD,2E,"\0\0\x80\x82\0\x01\0\0\0\0\0\0\t_services\x07_dns-sd\x04_udp
SF:\x05local\0\0\x0c\0\x01")%r(NBTStat,32,"\x80\xf0\x80\x82\0\x01\0\0\0\0\
SF:0\0\x20CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\0\0!\0\x01");
MAC Address: 00:0C:29:7A:E1:DA (VMware)

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 25.32 seconds

C:\>

測試連 Rocky Linux 9.5 安裝 DNS Server (bind) (防火牆開放 port 53)

C:\>nmap -sU -sV -p 53 192.168.128.132
Starting Nmap 7.95 ( https://nmap.org ) at 2025-05-16 10:07 ¥x¥_?D·CRE?!
Nmap scan report for 192.168.128.132
Host is up (0.00013s latency).

PORT   STATE SERVICE VERSION
53/udp open  domain  ISC BIND 9.16.23 (RedHat Linux)
MAC Address: 00:0C:29:31:18:E0 (VMware)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 0.33 seconds

C:\>


********************************************************************************

DNS Server 版本測試 (用 Rocky Linux 9.5 上 dig)

[user1@localhost ~]$ dig -v
DiG 9.16.23-RH
[user1@localhost ~]$ 
[user1@localhost ~]$ dig @8.8.8.8 version.bind txt chaos

; <<>> DiG 9.16.23-RH <<>> @8.8.8.8 version.bind txt chaos
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 25255
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;version.bind.			CH	TXT

;; Query time: 8 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri May 16 10:13:31 CST 2025
;; MSG SIZE  rcvd: 41

[user1@localhost ~]$ dig @168.95.1.1 version.bind txt chaos

; <<>> DiG 9.16.23-RH <<>> @168.95.1.1 version.bind txt chaos
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 15344
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;version.bind.			CH	TXT

;; Query time: 7 msec
;; SERVER: 168.95.1.1#53(168.95.1.1)
;; WHEN: Fri May 16 10:14:28 CST 2025
;; MSG SIZE  rcvd: 41

[user1@localhost ~]$ dig @127.0.0.1 version.bind txt chaos

; <<>> DiG 9.16.23-RH <<>> @127.0.0.1 version.bind txt chaos
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52033
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: d0adaffc131a62320100000068269faa5b90de87e8ec3faf (good)
;; QUESTION SECTION:
;version.bind.			CH	TXT

;; ANSWER SECTION:
version.bind.		0	CH	TXT	"9.16.23-RH"

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri May 16 10:15:06 CST 2025
;; MSG SIZE  rcvd: 92

[user1@localhost ~]$ dig @168.95.1.1 version txt chaos

; <<>> DiG 9.16.23-RH <<>> @168.95.1.1 version txt chaos
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 19202
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;version.			CH	TXT

;; Query time: 2 msec
;; SERVER: 168.95.1.1#53(168.95.1.1)
;; WHEN: Fri May 16 10:15:47 CST 2025
;; MSG SIZE  rcvd: 36

[user1@localhost ~]$ dig @8.8.8.8 version txt chaos

; <<>> DiG 9.16.23-RH <<>> @8.8.8.8 version txt chaos
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 64846
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;version.			CH	TXT

;; Query time: 6 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri May 16 10:16:30 CST 2025
;; MSG SIZE  rcvd: 36

[user1@localhost ~]$ 



(完)

相關

2022年12月16日 星期五

[研究]查某網域 DNS 中郵件伺服器被攔截阻擋資訊

[研究]查某網域 DNS 中郵件伺服器被攔截阻擋資訊

2022-12-16

https://dnschecker.org/



Mail Server 發現被 xbl.spamhaus.org 和 dnsbl.spfbl.net 攔截阻擋。

或直接使用下面進行查詢。

IP Blacklist Check - Email Blacklist Checker
https://dnschecker.org/ip-blacklist-checker.php

(完)

2021年4月26日 星期一

[研究] 一般主機與 AD+DNS Server 主機的 DNS設定

[研究] 一般主機與 AD+DNS Server 主機的 DNS設定 

2021-04-26




********************************************************************************




(下圖) 注意,主要的 DNS Server 要盡量排在上方。

(完)