<div id="main"><article class="hentry" role="article"><div class="entry-content"> <p>现在的UBUNTU桌面发行版已经自带了dnsmasq,如何再配置自己的DNS配置?</p>
<!-- more -->
<ul id="markdown-toc"> <li><a href="#ubuntudnsmasq">UBUNTU桌面版中的dnsmasq</a></li> <li><a href="#dnsmasq">叠床架屋?——启用dnsmasq服务</a></li> <li><a href="#dns">简单的DNS配置</a></li> <li><a href="#section">参考</a></li> </ul>
<h2 id="ubuntudnsmasq">UBUNTU桌面版中的dnsmasq</h2>
<p>不记得从哪个版本开始,大概是13.04以后,UBUNTU的网络设置工具会自带一下dnsmasq工具,用于适应各种不同网卡的DNS配置。可以看到进程信息类似:</p>
<pre><code>nobody 2138 1197 0 09:50 ? 00:00:00 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/run/sendsigs.omit.d/network-manager.dnsmasq.pid --listen-address=127.0.1.1 --conf-file=/var/run/NetworkManager/dnsmasq.conf --cache-size=0 --proxy-dnssec --enable-dbus=org.freedesktop.NetworkManager.dnsmasq --conf-dir=/etc/NetworkManager/dnsmasq.d </code></pre>
<p>这个dnsmasq的作用,是把NetWorkManager中的DNS服务器配置作为上级DNS,在127.0.1.1这个地址虚拟一个本地DNS服务。而UBUNTU会把本机的/etc/resolv.conf中的内容改为:</p>
<pre><code># Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 127.0.1.1 search router </code></pre>
<h2 id="dnsmasq">叠床架屋?——启用dnsmasq服务</h2>
<p>由于这个dnsmasq是属于dnsmasq-base包的,只有运行程序,没有安装配置文件和开机启动服务,因此可以通过配置dnsmasq服务来再启动一个本地简易DNS,同时还继承原有配置。</p>
<p>首先需要安装dnsmasq包,即:</p>
<pre><code>sudo apt-get install dnsmasq </code></pre>
<p>此软件包包括/etc/dnsmasq.conf,/etc/dnsmasq.d,/etc/init.d/dnsmasq等配置文件,实现了开机从配置文件启动。</p>
<h2 id="dns">简单的DNS配置</h2>
<p>配置格式为:address=/域名/IP地址</p>
<p>域名可以使用“泛域名”,如下面的配置:</p>
<pre><code>address=/.squirrel.org/127.0.0.1 </code></pre>
<p>这一配置将所有squirrel.org和它的下级域名都解析为127.0.0.1了。</p>
<h2 id="section">参考</h2>
<p>http://www.cnblogs.com/sink_cup/archive/2012/08/17/router_dnsmasq_android_hosts.html <p class=’post-footer’> 原文链接地址: <a href="http://pangyi.github.io/blog/20150223/zai-ubuntu14ban-ben-shang-shi-yong-dnsmasqpei-zhi-zi-ding-yi-de-jian-yi-dnsfu-wu/">http://pangyi.github.io/blog/20150223/zai-ubuntu14ban-ben-shang-shi-yong-dnsmasqpei-zhi-zi-ding-yi-de-jian-yi-dnsfu-wu/</a><br> written by <a href="http://pangyi.github.io">PangYi</a> posted at <a href="http://pangyi.github.io">http://pangyi.github.io</a> </p></p> </div></article></div>