Dnsmasq安装后不能启动

使用Dnsmasq作为DNS服务器在小型的环境中还是比较实用的,同时还可以提供DHCP服务,但是本人在CentOS系统中安装完后,发现不能成功启动,原因时53端口被占用。但我刚装好的CentOS系统居然不能启动,真是日了个狗了。
稍微排查下得出是libvirt中使用了dnsmasq服务来来为其内部网络提供dns服务,网上很多人说修改脚本先与libvirt启动,但本人认为这个问题不应该在CentOS中出现,还用不着非上这些旁门左道的时候,仔细查找资料终于找到了libvirt的官方文档的解决方案,原文连接:https://wiki.libvirt.org/page/Libvirtd_and_dnsmasq
 
英文描述为:
 
Libvirtd and dnsmasq
 
Running your own dnsmasq with libvirtd
 
On linux host servers, libvirtd uses dnsmasq to service the virtual networks, such as the default network. A new instance of dnsmasq is started for each virtual network, only accessible to guests in that specific network.
 
If you are running your own "global" dnsmasq, then this can cause your own dnsmasq to fail to start (or for libvirtd to fail to start its dnsmasq and the given virtual network). This happens because both instances of dnsmasq might try to bind to the same port number on the same network interfaces.
 
You have to change the global /etc/dnsmasq.conf as follows:
 
Either:

interface=eth0

or

listen-address=192.168.0.1

(Replace interface or listen-address with the interfaces or addresses you want your global dnsmasq to answer queries on).
 
And uncomment this line to tell dnsmasq to only bind specific interfaces, not try to bind all interfaces:

bind-interfaces

 
说白了就是指定监听端口或者IP,因为libvirt使用virtbr0端口和192.168.122.1这个默认地址来监听53端口,因此我们自己使用基本上都不会是这两。另外,需要注意一定要反注释掉“bind-interfacce”才能是设定的端口和IP地址生效。

上一篇:安装部署KVM


下一篇:Centos7.4安装kvm虚拟机(使用virt-manager管理)