安装一个本地dns服务器加速对域名的解析,其实也加速不了多少。只是为了学习一下。

详细步骤我是跟着archlinux wiki 来做的。

步骤简化如下:

1

yaourt -S dnsmasq

2

** 2.1 sudo cp -v dnsmasq.conf{,.orig}**

** 2.2 sudo vim dnsmasq.conf**

** 2.3 找到下面语句并修改如下**

resolv-file=/etc/dnsmasq.resolv.conf

    addn-hosts=/etc/dnsmasq.hosts

    local=/localnet/

    no-dhcp-interface=eth0

    conf-dir=/etc/dnsmasq.d

** 3**

sudo cp -v resolv.conf dnsmasq.resolv.conf

`resolv.conf’ -> `dnsmasq.resolv.conf’

sudo mkdir /etc/dnsmasq.d

sudo touch /etc/dnsmasq.hosts

4

sudo /etc/rc.d/dnsmasq start

启动之后效果还是挺明显的

启动前

=>$sudo rc.d/dnsmasq stop

:: Stopping DNS/DHCP daemon  

=>$dig archlinux.org | grep “Query time”

;; Query time: 516 msec

=>$sudo rc.d/dnsmasq restart

:: Stopping DNS/DHCP daemon                                                                                        [FAIL] 

:: Starting DNS/DHCP daemon 

=>$dig archlinux.org | grep “Query time”

;; Query time: 7 msec

{codewalker}<=Fri Mar 09-09:04 PM=>

==>/etc<==

=>$dig baidu.com

; <<>> DiG 9.9.0 <<>> baidu.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6355

;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 13, ADDITIONAL: 9

;; OPT PSEUDOSECTION:

; EDNS: version: 0, flags:; udp: 4096

;; QUESTION SECTION:

;baidu.com. IN A

;; ANSWER SECTION:

baidu.com. 214 IN A 123.125.114.144

baidu.com. 214 IN A 220.181.111.85

baidu.com. 214 IN A 220.181.111.86

;; AUTHORITY SECTION:

com. 152241 IN NS i.gtld-servers.net.

com. 152241 IN NS j.gtld-servers.net.

com. 152241 IN NS f.gtld-servers.net.

com. 152241 IN NS a.gtld-servers.net.

com. 152241 IN NS m.gtld-servers.net.

com. 152241 IN NS l.gtld-servers.net.

com. 152241 IN NS d.gtld-servers.net.

com. 152241 IN NS k.gtld-servers.net.

com. 152241 IN NS e.gtld-servers.net.

com. 152241 IN NS h.gtld-servers.net.

com. 152241 IN NS c.gtld-servers.net.

com. 152241 IN NS g.gtld-servers.net.

com. 152241 IN NS b.gtld-servers.net.

;; ADDITIONAL SECTION:

a.gtld-servers.net. 48583 IN A 192.5.6.30

b.gtld-servers.net. 100848 IN A 192.33.14.30

e.gtld-servers.net. 80315 IN A 192.12.94.30

f.gtld-servers.net. 91976 IN A 192.35.51.30

g.gtld-servers.net. 90364 IN A 192.42.93.30

i.gtld-servers.net. 109962 IN A 192.43.172.30

j.gtld-servers.net. 110247 IN A 192.48.79.30

l.gtld-servers.net. 108146 IN A 192.41.162.30

;; Query time: 10 msec

;; SERVER: 127.0.0.1#53(127.0.0.1)

;; WHEN: Fri Mar  9 21:04:19 2012

;; MSG SIZE  rcvd: 438

{codewalker}<=Fri Mar 09-09:04 PM=>

==>/etc<==

=>$dig baidu.com

; <<>> DiG 9.9.0 <<>> baidu.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1157

;; flags: qr rd ra ad; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:

;baidu.com. IN A

;; ANSWER SECTION:

baidu.com. 209 IN A 123.125.114.144

baidu.com. 209 IN A 220.181.111.86

baidu.com. 209 IN A 220.181.111.85

;; Query time: 3 msec

;; SERVER: 127.0.0.1#53(127.0.0.1)

;; WHEN: Fri Mar  9 21:04:24 2012

;; MSG SIZE  rcvd: 75