Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加固定解析 #25

Closed
kuyagic opened this issue Sep 16, 2014 · 13 comments
Closed

增加固定解析 #25

kuyagic opened this issue Sep 16, 2014 · 13 comments
Labels

Comments

@kuyagic
Copy link

kuyagic commented Sep 16, 2014

能否增加一个配置文件 类似hosts的.可以用来解析一些内网ip....

@clowwindy
Copy link
Contributor

直接改 ChinaDNS 所在机器的 hosts 即可。

@kuyagic
Copy link
Author

kuyagic commented Sep 16, 2014

实测好像没有效果...

root@zmbox:~# cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 zmbox
10.0.3.100 sync.dd.local

The following lines are desirable for IPv6 capable hosts

::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
root@zmbox:# ps -ef | grep china
root 23303 1 0 12:43 pts/10 00:00:00 /usr/sbin/chinadns -l /etc/chinadns/iplist.txt -c /etc/chinadns/chnroute.txt -p 53
root 24318 10865 0 16:14 pts/10 00:00:00 grep --color=auto china
root@zmbox:
# dig @127.0.0.1 sync.dd.local

; <<>> DiG 9.9.5-3-Ubuntu <<>> @127.0.0.1 sync.dd.local
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 65195
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;sync.dd.local. IN A

;; AUTHORITY SECTION:
. 10663 IN SOA a.root-servers.net. nstld.verisign-grs.com. 2014091501 1800 900 604800 86400

;; Query time: 4013 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Sep 16 16:14:27 CST 2014
;; MSG SIZE rcvd: 117

@clowwindy
Copy link
Contributor

你用的这个不是 python 版吧。openwrt 用 dnsmasq 设置 chinadns 为上级 dns 即可。然后用 dnsmasq 设置内网解析。

@kuyagic
Copy link
Author

kuyagic commented Sep 16, 2014

多谢.我去多挂一层....

@kuyagic
Copy link
Author

kuyagic commented Sep 16, 2014

好像 dnsmasq 不支持非标准端口的 上游dns 服务器的??? 我google 未果...求大大帮助

@aa65535
Copy link

aa65535 commented Sep 16, 2014

@kuyagic dnsmasq 配置文件里写 server=127.0.0.1#5353 就行了(5353是端口号)。
另外改 hosts 后记得是重启生效吧。

@kuyagic
Copy link
Author

kuyagic commented Sep 16, 2014

@aa65535 好像我dnsmasq.conf 里这么写了 好像还是无效的.我也觉得很神奇....待我再研究下...

@aa65535
Copy link

aa65535 commented Sep 16, 2014

@kuyagic 要用 chinadns 做上游就不要其他的 server= 参数了。
另外看一下 chinadns 监听的端口是不是 5353 ,
另外需要把 init script 里的 iptables 那里去掉。

@kuyagic
Copy link
Author

kuyagic commented Sep 16, 2014

@aa65535 init script 里的iptables 已经去掉
server= 应该就一个吧.
chinadns 监听端口是5353

@kuyagic
Copy link
Author

kuyagic commented Sep 16, 2014

@aa65535
我upstream 文件里 记录了 a.com 为1.1.1.1 和 server=127.0.0.1#5353的
然后执行下面的命令 和输出

root@zmbox:/etc/dnsmasq.d# dig a.com

; <<>> DiG 9.9.5-3-Ubuntu <<>> a.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19644
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;a.com. IN A

;; ANSWER SECTION:
a.com. 0 IN A 1.1.1.1

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Sep 16 16:58:51 CST 2014
;; MSG SIZE rcvd: 39

root@zmbox:/etc/dnsmasq.d# dig www.twitter.com

; <<>> DiG 9.9.5-3-Ubuntu <<>> www.twitter.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46349
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

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

;; ANSWER SECTION:
www.twitter.com. 13686 IN A 37.61.54.158

;; Query time: 8 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Sep 16 16:58:56 CST 2014
;; MSG SIZE rcvd: 60

root@zmbox:/etc/dnsmasq.d# dig +cmd www.twitter.com @127.0.0.1 -p 5353

; <<>> DiG 9.9.5-3-Ubuntu <<>> +cmd www.twitter.com @127.0.0.1 -p 5353
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16190
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1

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

;; ANSWER SECTION:
www.twitter.com. 536 IN CNAME twitter.com.
twitter.com. 21 IN A 199.59.150.39
twitter.com. 21 IN A 199.59.149.230
twitter.com. 21 IN A 199.59.148.10
twitter.com. 21 IN A 199.59.149.198

;; Query time: 80 msec
;; SERVER: 127.0.0.1#5353(127.0.0.1)
;; WHEN: Tue Sep 16 16:59:15 CST 2014
;; MSG SIZE rcvd: 122

@clowwindy
Copy link
Contributor

把你的 /etc/dnsmasq.conf 和 /etc/dnsmasq.d/ 下每个文件都贴出来看看。

@kuyagic
Copy link
Author

kuyagic commented Sep 16, 2014

dnsmasq.conf 就一行有效代码
conf-dir=/etc/dnsmasq.d

dnsmasq.d 下 有2个文件

lxc 内容如下

Tell any system-wide dnsmasq instance to make sure to bind to interfaces

instead of listening on 0.0.0.0

WARNING: changes to this file will get lost if lxc is removed.

bind-interfaces
except-interface=lxcbr0

upstream 内容如下
server=127.0.0.1#5353
address=/a.com/1.1.1.1

@clowwindy

@kuyagic
Copy link
Author

kuyagic commented Sep 16, 2014

@clowwindy
@aa65535
在dnsmasq.conf 里启用了 no-resolv 后就可以了

谢谢各位大大

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants