dnsmasq 的 resolv 设置


  • AlightweightDHCPandcachingDNSserver...dnsmasq[6120]:dnsmasq:syntaxcheckOK.dnsmasq[6133]:started,version2.76cachesize150dnsmasq[6133]:compiletimeoptions:IPv6GNU-getoptDBusi18nIDNDHCPDHCPv6no-LuaTFTPconntrackipsetau
  • systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server... 
    dnsmasq[6120]: dnsmasq: syntax check OK. 
    dnsmasq[6133]: started, version 2.76 cachesize 150 
    dnsmasq[6133]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify 
    dnsmasq[6133]: no servers found in /run/dnsmasq/resolv.conf, will retry 
    dnsmasq[6133]: read /etc/hosts - 5 addresses 
    systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server. 


    安装 dnsmasq 之后发现无法解析域名了,nslookup 显示请求被拒绝。dnsmasq 的日志显示如上,提示读取/run/dnsmasq/resolv.conf
    中的域名服务器,但文件为空,搜索发现有直接修改该文件的方案,但在测试后发现该文件每次重启 dnsmasq 服务的时候都会重新生成,修改无法保存。



    dnsmasq 在默认安装的情况下被设置为若 resolvconf 已安装的话,则与 resolvconf 集成。这就意味着 dnsmasq 将其监听的地址(127.0.0.1)发送给 resolvconf,并使用 resolvconf 的可用域名服务器列表生成自己的上游域名服务器列表。dnsmasq 的 resolvconf 钩子脚本/etc/resolvconf/update.d/dnsmasq
    生成/var/run/dnsmasq/resolv.conf
    。这个脚本在每次 resolvconf 运行的时候触发。



    需要编辑etc/default/dnsmasq
    文件,并设置IGNOR_RESOLVCONF=yes
    ,这样的话 dnsmasq 就不会直接查找/var/run/dnsmasq/resolv.conf
    中的内容了。



    /etc/init.d/dnsmasq
    :


    # RESOLV_CONF: 
    # If the resolvconf package is installed then use the resolv conf file 
    # that it provides as the default.Otherwise use /etc/resolv.conf as 
    # the default. 

    # If IGNORE_RESOLVCONF is set in /etc/default/dnsmasq or an explicit 
    # filename is set there then this inhibits the use of the resolvconf-provided 
    # information. 

    # Note that if the resolvconf package is installed it is not possible to 
    # override it just by configuration in /etc/dnsmasq.conf, it is necessary 
    # to set IGNORE_RESOLVCONF=yes in /etc/default/dnsmasq. 
    if [ ! "$RESOLV_CONF" ] &;&; 
    [ "$IGNORE_RESOLVCONF" != "yes" ] &;&; 
    [ -x /sbin/resolvconf ] 
    then 
    RESOLV_CONF=/run/dnsmasq/resolv.conf 
    fi 

  • 免责声明!

    本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



     
    粤ICP备18138465号  © 2018-2025 CODEPRJ.COM