Comments (22)
没看明白什么意思。
苹果电脑,要监听本地和局域网 bind 两次就是了。
bind :53@lo0 # 会去找网卡名是 lo0 的 Ipv4 地址
bind :53@en0 # 会去找网卡名是 en0 的 Ipv4 地址
我自己 mac 电脑,就是这么写的。
from smartdns-rs.
使用以下配置之后,看日志可以正常本地回环和局域网地址了。
bind :8053@lo0 # 会去找网卡名是 lo0 的 Ipv4 地址
bind :8053@en0 # 会去找网卡名是 en0 的 Ipv4 地址
使用dig查询本地回环地址时,dig www.baidu.com @127.0.0.1 -p 8053
,可以正常获得smartdns的回应,
但是使用局域网地址查询时,dig www.baidu.com @192.168.2.180 -p 8053
,却无法获得smartdns回应。
from smartdns-rs.
防火墙?
from smartdns-rs.
smartdns已放行
from smartdns-rs.
嗯,我找时间查下原因。
from smartdns-rs.
我这里都正常啊
1679924901:DEBUG:smartdns:260: binding UDP to 172.19.0.4:53
1679924901:INFO: listening for UDP on 172.19.0.4:53
1679924901:DEBUG:smartdns:260: binding UDP to 127.0.0.1:53
1679924901:INFO: listening for UDP on 127.0.0.1:53
1679924901:DEBUG:smartdns:282: binding TCP to [::]:53
1679924901:INFO: listening for TCP on [::]:53
1679924901:INFO:
1679924901:INFO: _____ _ _____ _ _ _____
1679924901:INFO: / ____| | | | __ \| \ | |/ ____|
1679924901:INFO: | (___ _ __ ___ __ _ _ __| |_ | | | | \| | (___
1679924901:INFO: \___ \| '_ ` _ \ / _` | '__| __| | | | | . ` |\___ \
1679924901:INFO: ____) | | | | | | (_| | | | |_ | |__| | |\ |____) |
1679924901:INFO: |_____/|_| |_| |_|\__,_|_| \__| |_____/|_| \_|_____/
1679924901:INFO:
1679924901:INFO: awaiting connections...
1679924901:INFO: server starting up
1679924955:DEBUG:smartdns::dns_server:131: query received: 20904 name: www.baidu.com. type: A class: IN A client: 127.0.0.1:59298
1679924955:DEBUG:smartdns::dns_server:131: query received: 21414 name: www.baidu.com. type: AAAA class: IN AAAA client: 127.0.0.1:59298
1679924955:DEBUG:smartdns::dns_client:291: initialize name server [Group: mainland]
1679924955:DEBUG:smartdns::dns_mw_ns:104: query name: www.baidu.com. type: A via [Group: mainland]
1679924955:DEBUG:smartdns::dns_mw_ns:104: query name: www.baidu.com. type: AAAA via [Group: mainland]
1679924955:DEBUG:smartdns::dns_mw_ns:291: The fastest ip of www.baidu.com. is 110.242.68.4
1679924955:DEBUG:smartdns::dns_mw_ns:291: The fastest ip of www.baidu.com. is 110.242.68.4
1679924955:DEBUG:smartdns::dns_mw_ns:291: The fastest ip of www.baidu.com. is 110.242.68.3
1679924955:DEBUG:smartdns::dns_mw_ns:291: The fastest ip of www.baidu.com. is 110.242.68.4
1679924955:DEBUG:smartdns::dns_server:273: error resolving: Forward resolution error: no record found for Query { name: Name("www.baidu.com."), query_type: AAAA, query_class: IN }
1679924963:DEBUG:smartdns::dns_server:131: query received: 62062 name: www.baidu.com. type: AAAA class: IN AAAA client: 172.19.0.4:43655
1679924963:DEBUG:smartdns::dns_server:131: query received: 61510 name: www.baidu.com. type: A class: IN A client: 172.19.0.4:43655
1679924963:DEBUG:smartdns::dns_mw_ns:104: query name: www.baidu.com. type: A via [Group: mainland]
1679924963:DEBUG:smartdns::dns_mw_ns:104: query name: www.baidu.com. type: AAAA via [Group: mainland]
1679924963:DEBUG:smartdns::dns_mw_ns:291: The fastest ip of www.baidu.com. is 110.242.68.4
1679924963:DEBUG:smartdns::dns_mw_ns:291: The fastest ip of www.baidu.com. is 110.242.68.4
1679924963:DEBUG:smartdns::dns_mw_ns:291: The fastest ip of www.baidu.com. is 110.242.68.4
1679924963:DEBUG:smartdns::dns_server:273: error resolving: Forward resolution error: no record found for Query { name: Name("www.baidu.com."), query_type: AAAA, query_class: IN }
1679924963:DEBUG:smartdns::dns_mw_ns:291: The fastest ip of www.baidu.com. is 110.242.68.4
/ # nslookup www.baidu.com 127.0.0.1
Server: 127.0.0.1
Address: 127.0.0.1:53
Non-authoritative answer:
Name: www.a.shifen.com
Address: 110.242.68.4
Non-authoritative answer:
/ # nslookup www.baidu.com 172.19.0.4
Server: 172.19.0.4
Address: 172.19.0.4:53
Non-authoritative answer:
Non-authoritative answer:
Name: www.a.shifen.com
Address: 110.242.68.4
from smartdns-rs.
我这里都正常啊
@PikuZheng 你也是 mac 电脑?
from smartdns-rs.
osx?明天试
from smartdns-rs.
osx默认是不允许回环的,即 绑定192.168.2.180后,允许局域网其他电脑访问192.168.2.180,但自身不能通过这个ip访问自己。检查sysctl net.inet.ip.forwarding
from smartdns-rs.
局域网中的其他电脑也无法通过本机IP(192.168.2.180)查询dns,一样超时。
这里改端口了,因为也有个问题:mac端smartdns运行终止之后,无法再次使用终止前的端口,所以得改端口后再测速。
经sudo lsof -i:port
查看后,无法运行的端口也没有占用。
dig www.baidu.com @192.168.2.180 -p 8050
; <<>> DiG 9.14.10 <<>> www.baidu.com @192.168.2.180 -p 8050
;; global options: +cmd
;; connection timed out; no servers could be reached
ping 192.168.2.180
正在 Ping 192.168.2.180 具有 32 字节的数据:
来自 192.168.2.180 的回复: 字节=32 时间=41ms TTL=64
来自 192.168.2.180 的回复: 字节=32 时间=60ms TTL=64
来自 192.168.2.180 的回复: 字节=32 时间=67ms TTL=64
来自 192.168.2.180 的回复: 字节=32 时间=2ms TTL=64
192.168.2.180 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 2ms,最长 = 67ms,平均 = 42ms
from smartdns-rs.
你用了其他会修改路由的软件吗?例如用了 tun/tap
from smartdns-rs.
证实该现象存在,应该和防火墙有关
from smartdns-rs.
我这重启,并用 brew upgrade smartdns
更新版本后,再用其他机器访问,就弹窗提示要不要通过防火墙,选择允许就正常了。
可能是先前没点击允许通过防火墙?
from smartdns-rs.
啊这 我是下载的release运行的,手动加的这个程序进防火墙。
brew会对应用签名吧?应该是差在这里了。
但是还有一个问题,是smartdns结束运行后不能再次监听同一个端口。
这应该是两个不同的事情。一个是防火墙问题,另一个是进程问题。
from smartdns-rs.
关了不能再监听同一个端口,令人费解,很早之前遇到过,后来使用 127.0.0.1
,没用 0.0.0.0
就好像再也没有遇到过。好像是 macos 独有的问题,完全没解决思路啊。
还有个问题也是费解的?就是如果监听 0.0.0.0 系统会用 ipv6 兼容的类似 ffffff.127.0.0.1 地址访问,这样程序收的到 request ,但是 response 发出去客户端收不到。
from smartdns-rs.
但是还有一个问题,是smartdns结束运行后不能再次监听同一个端口
这问题重现的步骤是:
- 监听局域网 ip ,
- 远程机器访问,
- 弹窗提示防火墙是否允许,不点击允许,也不点击拒绝,忽略弹窗。(关键步骤)
- 关闭程序,再也不能绑定原来端口
- 解决办法,重启电脑。
好像没得解决了,这是 mac 系统的原因,防火墙选择允许,就不会出现不能再绑定同一个接口了。
@PikuZheng 你再确认下?是不是只有这步骤百分百重现?
from smartdns-rs.
大概是 macos 系统本身的 bug。
这个其他语言写的也有类似的问题 Address already in use
ethereum/go-ethereum#18443
https://stackoverflow.com/questions/25586327/bizarre-firewall-related-socket-leak-on-mac-os-x
https://stackoverflow.com/questions/20956836/how-do-i-not-destroy-an-udp-port-when-binding-a-socket
from smartdns-rs.
我测试的步骤和楼主的类似。将smartdns加入到防火墙允许后。运行smartdns。
此时如果没有传入连接,一切正常。如果有传入连接(但是smartdns没有收到数据),smartdns退出后,netstat仍显示端口占用。
from smartdns-rs.
该问题重现的步骤是在macOS上使用自行编译和release版本:
监听局域网 ip ,
远程机器访问,
自行编译和release版本都无防火墙弹窗。远程机器无收到回应,smartdns无log输出,此时关闭程序,可以绑定原来端口;
手动添加自行编译和release版本通过防火墙,远程机器无收到回应,smartdns无log输出,此时关闭程序,不能绑定原来端口,解决办法,重启电脑。
设置rr-ttl-min 300,但连续两次查询的ttl值都不对。
dig www.baidu.com @127.0.0.1 -p 8055
; <<>> DiG 9.10.6 <<>> www.baidu.com @127.0.0.1 -p 8055
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57479
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.baidu.com. IN A
;; ANSWER SECTION:
www.a.shifen.com. 64 IN A 120.232.145.185
;; Query time: 98 msec
;; SERVER: 127.0.0.1#8055(127.0.0.1)
;; WHEN: Fri Mar 31 19:24:29 CST 2023
;; MSG SIZE rcvd: 63
dig www.baidu.com @127.0.0.1 -p 8055
; <<>> DiG 9.10.6 <<>> www.baidu.com @127.0.0.1 -p 8055
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1356
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.baidu.com. IN A
;; ANSWER SECTION:
www.a.shifen.com. 179 IN A 120.232.145.144
;; Query time: 46 msec
;; SERVER: 127.0.0.1#8055(127.0.0.1)
;; WHEN: Fri Mar 31 19:24:30 CST 2023
;; MSG SIZE rcvd: 63
from smartdns-rs.
@HFSstaff ttl 的问题,已修复,并添加了单元测试。你可以验证下
smartdns-rs/src/dns_mw_addr.rs
Lines 184 to 192 in 9234d0d
from smartdns-rs.
重启后端口被占用,设置socketopt的reuseaddr来解决
from smartdns-rs.
@HFSstaff pymumu 已在 #116 修复,请验证一下。
from smartdns-rs.
Related Issues (20)
- cname记录缺失? HOT 16
- edns是如何弄 HOT 3
- 使用容器好像异常高 HOT 47
- 没有任何 ipv6 查询结果 HOT 20
- Windows下路径识别问题 HOT 1
- 查询 PTR 记录会导致查询超时 HOT 8
- 能否做这个进阶玩法(dot/doq) HOT 5
- If max-reply-ip-num is set to 1, an empty record will be returned if the CNAME record is set for the domain name. HOT 2
- 0.7.1 版本,在win7_32位系统,提示,与您运行的windows版本不兼容,无法运行。 HOT 2
- macOS 14.2.1 下 cargo build --release失败 HOT 2
- OpenWrt编译版本查询任意域名返回局域网内IP HOT 2
- edns配置不生效 HOT 2
- 查询单栈域名没有缓存吗?DNS request timed out. timeout was 2 seconds. HOT 1
- hosts-file没有生效吗?hosts-file C:/Windows/System32/drivers/etc/hosts HOT 1
- 局域网linux设备无法访问smartdns?;; connection timed out; no servers could be reached,防火墙已经关闭了,可以ping到. HOT 1
- [Bug Report] 域名预先获取功能逻辑问题 HOT 9
- service install安装成服务能否指定conf文件? HOT 1
- 增加DNS优先级功能 HOT 2
- geosite 的支持 HOT 1
- 请求增加mdns-lookup功能 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smartdns-rs.