@mritd
2016-09-01T10:16:01.000000Z
字数 1172
阅读 2938
Linux DNS Docker
yum install -y dnsmasq
# 编辑配置文件vim /etc/dnsmasq.conf
主要配置如下
# 上游 DNS 定义resolv-file=/etc/resolv.dnsmasq.conf# 取消从本地 hosts 读取no-hosts# 监听地址listen-address=127.0.0.1,192.168.1.106# 指定本地 dns host 配置addn-hosts=/etc/dnsmasq.hosts# 设置 dns 缓存大小cache-size=150
配置 dns 解析
# 增加本地回环echo 'nameserver 127.0.0.1' >> /etc/resolv.conf# 增加本地 hostscp /etc/hosts /etc/dnsmasq.hosts# 添加上游 DNS 服务器echo 'nameserver 8.8.8.8' >> /etc/resolv.dnsmasq.confecho 'nameserver 192.168.1.1' >> /etc/resolv.dnsmasq.conf
首先启动 dnsmasq
systemctl enable dnsmasqsystemctl start dnsmasqsystemctl status dnsmasq
使用 dig 命令测试即可
dig @192.168.1.106 www.baidu.com; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.3 <<>> @192.168.1.106 www.baidu.com; (1 server found);; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4980;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1;; OPT PSEUDOSECTION:; EDNS: version: 0, flags:; udp: 4096;; QUESTION SECTION:;www.baidu.com. IN A;; ANSWER SECTION:www.baidu.com. 490 IN CNAME www.a.shifen.com.www.a.shifen.com. 201 IN A 61.135.169.125www.a.shifen.com. 201 IN A 61.135.169.121;; Query time: 5 msec;; SERVER: 192.168.1.106#53(192.168.1.106);; WHEN: 二 8月 30 16:00:21 EDT 2016;; MSG SIZE rcvd: 101
Your browser does not support the video tag.