Quantcast
Channel: Jimmy He – OracleBlog
Viewing all articles
Browse latest Browse all 129

解决openwrt中关于某些域名无法解析的问题

$
0
0

之前刷的一个openwrt的路由,虽然能很方便的登陆google和百度,但是发现不少网站还是登陆不上去,连我自己的博客也无法登陆。

检查连一下,发现是我的博客的域名无法解析。

root@OpenWrt:/etc/dnsmasq.d# dig oracleblog.org

; <<>> DiG 9.9.4 <<>> oracleblog.org
;; global options: +cmd
;; connection timed out; no servers could be reached
root@OpenWrt:/etc/dnsmasq.d# 
root@OpenWrt:/etc/dnsmasq.d#
root@OpenWrt:/etc/dnsmasq.d#
root@OpenWrt:/etc/dnsmasq.d#
root@OpenWrt:/etc/dnsmasq.d# dig youtube.com

; <<>> DiG 9.9.4 <<>> youtube.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21312
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

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

;; ANSWER SECTION:
youtube.com.            613     IN      A       216.58.221.238

;; Query time: 33 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Feb 01 15:05:10 CST 2019
;; MSG SIZE  rcvd: 56

root@OpenWrt:/etc/dnsmasq.d#

那就是一个域名解析的问题了,由于我是通过dnsmasq进行域名解析,在我的/etc/dnsmasq.d目录下,已经有连需要特别解析的配置,那么剩下的就是一般的域名走默认配置。

检查了一下,发现没有配置no-resolv和server。把/etc/dnsmasq.conf添加如下,就可以解决了(见第6行~12行):

# for targets which are names from DHCP or /etc/hosts. Give host
# "bert" another name, bertrand
# The fields are &lt;cname&gt;,&lt;target&gt;
#cname=bertand,bert
conf-dir=/etc/dnsmasq.d
#Add by Jimmy BEGIN HERE 
no-poll
no-resolv
all-servers
cache-size=5000
server=114.114.114.114
#Add by Jimmy END HERE

root@OpenWrt:/etc/dnsmasq.d# dig oracleblog.org

; <<>> DiG 9.9.4 <<>> oracleblog.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24044
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;oracleblog.org.                        IN      A

;; ANSWER SECTION:
oracleblog.org.         300     IN      A       45.76.217.207

;; Query time: 259 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Feb 01 16:24:10 CST 2019
;; MSG SIZE  rcvd: 59

root@OpenWrt:/etc/dnsmasq.d#


Viewing all articles
Browse latest Browse all 129