linux修改DNS本地缓存

  sre

1.安装dnsmasq;
2.设定dnsmasq接管本机的DNS解析请求,修改/etc/dnsmasq.conf,确保listen-address=127.0.0.1;
3.修改dhclient的配置,确保prepend domain-name-servers 127.0.0.1;
4.修改resolv.conf的配置,确保nameserver 127.0.0.1排第1;
5.重启dnsmasq服务。
验证:

DevOps nova # dig pkgs.org

; <<>> DiG 9.10.3-P4-Ubuntu <<>> pkgs.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60235 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2 ;; QUESTION SECTION: ;pkgs.org. IN A ;; ANSWER SECTION: pkgs.org. 600 IN A 144.76.64.139 ;; AUTHORITY SECTION: pkgs.org. 83756 IN NS ns2.pkgs.org. pkgs.org. 83756 IN NS ns.pkgs.org. ;; ADDITIONAL SECTION: ns.pkgs.org. 82424 IN A 144.76.64.139 ns2.pkgs.org. 36910 IN A 193.201.116.2 ;; Query time: 67 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Thu Nov 24 11:55:39 CST 2016 ;; MSG SIZE rcvd: 109 DevOps nova # dig pkgs.org ; <<>> DiG 9.10.3-P4-Ubuntu <<>> pkgs.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29324 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1280 ;; QUESTION SECTION: ;pkgs.org. IN A ;; ANSWER SECTION: pkgs.org. 595 IN A 144.76.64.139 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Thu Nov 24 11:55:44 CST 2016 ;; MSG SIZE rcvd: 53

LEAVE A COMMENT

Captcha Code