Showing posts with label dnsmasq. Show all posts
Showing posts with label dnsmasq. Show all posts

Sunday, October 2, 2011

arch安装pdnsd作为dns缓存服务器(本地)

找到pdnsd了。在/etc/pdnsd.conf的server段,这样写:
server {
        label= "mydns";
        ip = 208.67.220.220, 8.8.8.8;  # Put your ISP's DNS-server address(es) here.
        timeout=4;         # Server timeout; this may be much shorter
        interval=30m;      # Check every 30 minutes.
        purge_cache=off;   # Keep stale cache entries in case the ISP's
}
然后再在global段,改写下面的选项
    min_ttl=96h;
    max_ttl=1w;
这样就可以咯,缓存的dns记录最少会保留96个小时,强哦。

Thursday, September 15, 2011

dnsmasq在arch下建立自己的dns本地缓存

~/myworksource/routerautorestart/Untitled.html  1 装好的arch+gnome shell配置的还可以了,就是firefox上网太慢。
 2 
 3 和win下使用ff根本无法相比,这个问题老早就接触过,在debian,ubuntu下都安装过dnsmasq 做本地dns缓存来解决。arch下是头一次。
 4 
 5 下面是方法:
 6 
 7 1,安装
 8 pacman -S dnsmasq
 9 
10 2,修改dns配置文件 /etc/dnsmasq.conf
11 在 listen-address= 后面添加 127.0.0.1
12 变成这样
13 listen-address=127.0.0.1
14 
15 3,不同于debian和ubuntu的一点就是现在arch使用了dhcpcd代替了dhclient,所以配置也就不一样了
16 arch dnsmaq wiki中提到了3中方法,我使用了第3种方法
17 在/etc/Networkmanager/dispatcher.d/中添加一个启动脚本myDNS
18 myDNS脚本内容如下
19 #!/bin/bash
20 #
21 # Override /etc/resolv.conf and tell
22 # NetworkManagerDispatcher to go pluck itself.
23 #
24 # scripts in the /etc/NetworkManager/dispatcher.d/ directory
25 # are called alphabetically and are passed two parameters:
26 # $1 is the interface name, and $2 is "up" or "down" as the
27 # case may be.
28 #
29 # Here, no matter what interface or state, override the
30 # created resolver config with my config.
31 #
32 #cp -f /etc/resolv.conf.myDNSoverride /etc/resolv.conf
33 # 不要改变我删除我原来的/etc/resolv.conf,在第一行添加nameserver 127.0.0.1
34 # Creates a copy of resolv.conf with "nameserver 127.0.0.1" as first line.
35 cat - /etc/resolv.conf <<<"nameserver 127.0.0.1"  > /etc/resolv.conf.new
36 cp -f /etc/resolv.conf.new /etc/resolv.conf
37 
38 3,修改/etc/rc.conf 使dnsmasq在开机就以DAEMONS运行
39 DAEMONS=(networkmanager dnsmasq ...)
40 
41 然后重新启动,察看你的域名解析时间是不是加快了
42 $dig google.com | grep Query