wolf-joe / ts-dns

Telescope DNS,灵活快速的DNS分组转发器
MIT License
316 stars 31 forks source link

默认ttl为什么 #14

Closed liang-hiwin closed 4 years ago

liang-hiwin commented 4 years ago

`~ lines 1-18/18 (END)...skipping... ● ts-dns.service - ts-dns Loaded: loaded (/etc/systemd/system/ts-dns.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2020-04-20 17:36:15 CST; 59s ago Main PID: 12497 (ts-dns) Tasks: 7 (limit: 4915) CGroup: /system.slice/ts-dns.service └─12497 /root/ts-dns/ts-dns -c /root/ts-dns/ts-dns-full.toml

Apr 20 17:36:15 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[12497]: time="2020-04-20T17:36:15+08:00" level=error msg="find fastest ipv4 failed" Apr 20 17:36:18 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[12497]: time="2020-04-20T17:36:18+08:00" level=error msg="find fastest ipv4 failed" Apr 20 17:36:18 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[12497]: time="2020-04-20T17:36:18+08:00" level=error msg="find fastest ipv4 failed" Apr 20 17:36:37 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[12497]: time="2020-04-20T17:36:37+08:00" level=error msg="query dns error: read udp 127.0.0.1:33367->127.0.0.1:5301: i/o timeout" Apr 20 17:37:07 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[12497]: time="2020-04-20T17:37:07+08:00" level=error msg="query dns error: read udp 127.0.0.1:46867->127.0.0.1:5301: i/o timeout" Apr 20 17:37:08 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[12497]: time="2020-04-20T17:37:08+08:00" level=error msg="find fastest ipv4 failed" Apr 20 17:37:09 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[12497]: time="2020-04-20T17:37:09+08:00" level=error msg="find fastest ipv4 failed" Apr 20 17:37:09 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[12497]: time="2020-04-20T17:37:09+08:00" level=error msg="find fastest ipv4 failed" Apr 20 17:37:13 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[12497]: time="2020-04-20T17:37:13+08:00" level=error msg="find fastest ipv4 failed" Apr 20 17:37:13 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[12497]: time="2020-04-20T17:37:13+08:00" level=error msg="find fastest ipv4 failed" ~ ~ `

liang-hiwin commented 4 years ago

`root@iZwz9d1rjhrzzxa4lsoi93Z:~# dig baidu.com @127.0.0.1 -p 5301

; <<>> DiG 9.10.3-P4-Debian <<>> baidu.com @127.0.0.1 -p 5301 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53681 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ;baidu.com. IN A

;; ANSWER SECTION: baidu.com. 600 IN A 39.156.69.79 baidu.com. 600 IN A 220.181.38.148

;; Query time: 40 msec ;; SERVER: 127.0.0.1#5301(127.0.0.1) ;; WHEN: Mon Apr 20 17:41:13 CST 2020 ;; MSG SIZE rcvd: 70

root@iZwz9d1rjhrzzxa4lsoi93Z:~#`

liang-hiwin commented 4 years ago

Screenshot_20200420-174446

wolf-joe commented 4 years ago

DNS解析记录的TTL值由域名的拥有者在权威服务器上设置。而在ts-dns中,解析记录的TTL值继承自上游DNS服务器,并在缓存时不断递减,表现为倒计时。

wolf-joe commented 4 years ago

建议在粘贴代码类的文本内容时用markdown里的代码块将内容包裹起来,如

```shell
root@iZwz9d1rjhrzzxa4lsoi93Z:~# dig baidu.com @127.0.0.1 -p 5301

; <<>> DiG 9.10.3-P4-Debian <<>> baidu.com @127.0.0.1 -p 5301
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53681
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
liang-hiwin commented 4 years ago
显示这个怎么解决 "level=error msg="find fastest ipv4 failed" "
wolf-joe commented 4 years ago

请给出相应group的配置

wolf-joe commented 4 years ago

配置文件中的tcp_ping_port = 120代表ts-dns在测速时会连接DNS查询结果IP的120号TCP端口。这个端口不属于IANA规定的常用端口号,意味着极少有服务器会开放这个端口,结果就是连接失败、find fastest ipv4 failed。如果要使用TCP测速,推荐将这个值设置为更常见的80443

liang-hiwin commented 4 years ago

配置文件中的tcp_ping_port = 120代表ts-dns在测速时会连接DNS查询结果IP的120号TCP端口。这个端口不属于IANA规定的常用端口号,意味着极少有服务器会开放这个端口,结果就是连接失败、find fastest ipv4 failed。如果要使用TCP测速,推荐将这个值设置为更常见的80443


我的127.0.0.1:5301是没问题的但是怎么会i/o超时呢

root@iZwz9d1rjhrzzxa4lsoi93Z:~# systemctl status ts-dns
● ts-dns.service - ts-dns
   Loaded: loaded (/etc/systemd/system/ts-dns.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2020-04-20 19:54:50 CST; 21s ago
 Main PID: 3328 (ts-dns)
    Tasks: 6 (limit: 4915)
   CGroup: /system.slice/ts-dns.service
           └─3328 /root/ts-dns/ts-dns -c /root/ts-dns/ts-dns-full.toml

Apr 20 19:54:50 iZwz9d1rjhrzzxa4lsoi93Z systemd[1]: Started ts-dns.
Apr 20 19:54:50 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[3328]: time="2020-04-20T19:54:50+08:00" level=warning msg="enable concurrent dns in group clean"
Apr 20 19:54:50 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[3328]: time="2020-04-20T19:54:50+08:00" level=warning msg="find fastest ipv4 in group clean"
Apr 20 19:54:50 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[3328]: time="2020-04-20T19:54:50+08:00" level=warning msg="listen on :5356/udp"
Apr 20 19:54:51 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[3328]: time="2020-04-20T19:54:51+08:00" level=error msg="find fastest ipv4 failed"
Apr 20 19:54:51 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[3328]: time="2020-04-20T19:54:51+08:00" level=error msg="find fastest ipv4 failed"
Apr 20 19:55:00 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[3328]: time="2020-04-20T19:55:00+08:00" level=error msg="query dns error: read udp 127.0.0.1:35627->127.0.0.1:5301: i/o timeout"
Apr 20 19:55:00 iZwz9d1rjhrzzxa4lsoi93Z ts-dns[3328]: time="2020-04-20T19:55:00+08:00" level=error msg="query dns error: read udp 127.0.0.1:39501->127.0.0.1:5301: i/o timeout"
liang-hiwin commented 4 years ago
root@iZwz9d1rjhrzzxa4lsoi93Z:~# dig qq.com @127.0.0.1 -p 5301

; <<>> DiG 9.10.3-P4-Debian <<>> qq.com @127.0.0.1 -p 5301
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34223
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;qq.com.                                IN      A

;; ANSWER SECTION:
qq.com.                 600     IN      A       58.250.137.36
qq.com.                 600     IN      A       125.39.52.26
qq.com.                 600     IN      A       58.247.214.47

;; Query time: 4 msec
;; SERVER: 127.0.0.1#5301(127.0.0.1)
;; WHEN: Mon Apr 20 19:58:50 CST 2020
;; MSG SIZE  rcvd: 83

root@iZwz9d1rjhrzzxa4lsoi93Z:~# dig www.moe123.net @127.0.0.1 -p 5301

; <<>> DiG 9.10.3-P4-Debian <<>> www.moe123.net @127.0.0.1 -p 5301
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6626
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;www.moe123.net.                        IN      A

;; ANSWER SECTION:
www.moe123.net.         600     IN      A       120.27.200.236

;; Query time: 42 msec
;; SERVER: 127.0.0.1#5301(127.0.0.1)
;; WHEN: Mon Apr 20 19:59:16 CST 2020
;; MSG SIZE  rcvd: 59

root@iZwz9d1rjhrzzxa4lsoi93Z:~# dig www.xinhuanet.com @127.0.0.1 -p 5301

; <<>> DiG 9.10.3-P4-Debian <<>> www.xinhuanet.com @127.0.0.1 -p 5301
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20326
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;www.xinhuanet.com.             IN      A

;; ANSWER SECTION:
www.xinhuanet.com.      583     IN      CNAME   www.xinhuanet.lxsvc.cn.
www.xinhuanet.lxsvc.cn. 1786    IN      CNAME   cc0000xh.h.tel.lxsvc.cn.
cc0000xh.h.tel.lxsvc.cn. 105    IN      A       42.81.100.139
cc0000xh.h.tel.lxsvc.cn. 105    IN      A       42.81.100.13

;; Query time: 0 msec
;; SERVER: 127.0.0.1#5301(127.0.0.1)
;; WHEN: Mon Apr 20 20:00:08 CST 2020
;; MSG SIZE  rcvd: 143

root@iZwz9d1rjhrzzxa4lsoi93Z:~#
liang-hiwin commented 4 years ago

}J%R)2E6LNCFZ69Y7MO 9~N

liang-hiwin commented 4 years ago

I/o超时的DNS完全可以解析,但是不懂为什么出错 O871NIU}_{2T$OQD$Z BZQG

wolf-joe commented 4 years ago

传输层级别的issue反馈请移步miekg/dnsgolang/go。顺便一提,即使是由localhost发出的UDP数据包也不保证100%送达。