V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
taobibi
V2EX  ›  DNS

Ubuntu 16 搭建的内网 Dnsmasq 缓存服务器一直启动失败

  •  
  •   taobibi · 2017-08-06 16:25:32 +08:00 · 8441 次点击
    这是一个创建于 2453 天前的主题,其中的信息可能已经有所发展或是发生改变。
    Ubuntu 16.04.3 LTS 安装的 Dnsmasq
    配置文件没发现有什么问题
    listen-address=192.168.0.4,127.0.0.1
    cache-size=1500
    no-resolv
    no-poll
    server=208.67.222.222#5353
    server=208.67.222.220#5353
    server=/cn/114.114.114.114
    server=223.5.5.5
    server=180.76.76.76




    状态提示

    ● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
    Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset:
    Drop-In: /run/systemd/generator/dnsmasq.service.d
    └─50-dnsmasq-$named.conf, 50-insserv.conf-$named.conf
    Active: failed (Result: exit-code) since Sun 2017-08-06 16:21:37 CST; 17s ago
    Process: 1646 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=
    Process: 1642 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUC

    Aug 06 16:21:37 localhost systemd[1]: Starting dnsmasq - A lightweight DHCP and
    Aug 06 16:21:37 localhost dnsmasq[1642]: dnsmasq: syntax check OK.
    Aug 06 16:21:37 localhost dnsmasq[1646]: dnsmasq: failed to create listening soc
    Aug 06 16:21:37 localhost systemd[1]: dnsmasq.service: Control process exited, c
    Aug 06 16:21:37 localhost systemd[1]: Failed to start dnsmasq - A lightweight DH
    Aug 06 16:21:37 localhost systemd[1]: dnsmasq.service: Unit entered failed state
    Aug 06 16:21:37 localhost systemd[1]: dnsmasq.service: Failed with result 'exit-
    17 条回复    2017-08-08 21:21:38 +08:00
    Counter
        1
    Counter  
       2017-08-06 16:33:50 +08:00 via iPhone
    关闭 selinux 再试一下
    zent00
        2
    zent00  
       2017-08-06 19:12:18 +08:00 via iPhone
    @Counter Ubuntu 哪来的时候 SELlinux
    whx20202
        4
    whx20202  
       2017-08-06 19:19:43 +08:00
    failed to create listening soc 谷歌下这一句试试
    taobibi
        5
    taobibi  
    OP
       2017-08-06 19:20:17 +08:00
    @Counter 乌班图没有关这个的命令?好像也没有这个
    whoops
        6
    whoops  
       2017-08-06 19:25:32 +08:00
    Aug 06 16:21:37 localhost dnsmasq[1646]: dnsmasq: failed to create listening soc
    这都报错了,不过没有显示完整
    应该是 Aug 06 16:21:37 localhost dnsmasq[1646]: dnsmasq: failed to create listening socket
    你直接运行 dnsmasq 看看具体报错内容


    或者如果你要监听所有地址把 listen-address=192.168.0.4,127.0.0.1 去掉看看
    ETiV
        7
    ETiV  
       2017-08-06 19:26:25 +08:00
    推荐配置文件里
    listen-address=0.0.0.0

    然后你这问题,先
    sudo netstat -lupn
    看看有没有 :53 在占用着,有的话,就 kill 掉最后那列的数字部分
    再启动 dnsmasq
    whoops
        8
    whoops  
       2017-08-06 19:28:16 +08:00
    才注意到你用的是默认端口,应该是你的权限不够,1024 端口下的需要用 root 权限,所以会报 failed to create listening socket
    whoops
        9
    whoops  
       2017-08-06 19:37:05 +08:00
    具体看报错日志,dnsmasq.service 安装时生成的,应该不是 root 权限问题,
    有可能就是三楼给出的链接,端口被占用了
    ecutuning
        10
    ecutuning  
       2017-08-06 22:55:26 +08:00
    很显然是因为 listen-address 的IP写错了。
    taobibi
        11
    taobibi  
    OP
       2017-08-07 17:12:46 +08:00
    @whoops 我执行命令前已经 sudo su 了。都是在 root 权限操作的
    l 刚刚 isten-address=0.0.0.0 改为试试
    taobibi
        12
    taobibi  
    OP
       2017-08-07 17:14:57 +08:00
    @whoops 会不会是中文版乌班图的 bug?
    taobibi
        13
    taobibi  
    OP
       2017-08-07 17:20:05 +08:00
    @ETiV
    sudo netstat -lupn
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
    udp 0 0 192.168.122.1:53 0.0.0.0:* 2586/dnsmasq
    udp 0 0 192.168.122.1:53 0.0.0.0:* 1557/named
    udp 0 0 172.19.66.239:53 0.0.0.0:* 1557/named
    udp 0 0 127.0.0.1:53 0.0.0.0:* 1557/named
    udp 0 0 127.0.0.53:53 0.0.0.0:* 1546/systemd-resolv
    udp 0 0 0.0.0.0:67 0.0.0.0:* 2586/dnsmasq
    udp 0 0 0.0.0.0:68 0.0.0.0:* 1438/dhclient
    udp 0 0 0.0.0.0:5355 0.0.0.0:* 1546/systemd-resolv
    udp6 0 0 :::53 :::* 1557/named
    udp6 0 0 :::5355 :::* 1546/systemd-resolv


    named 怎么卸载掉,好像占用 53 端口了
    whoops
        14
    whoops  
       2017-08-07 21:30:11 +08:00   ❤️ 1
    @taobibi
    named 就是 bind 啊,你 apt-get remove bind9 看看
    taobibi
        15
    taobibi  
    OP
       2017-08-08 08:06:13 +08:00
    @whoops 非常感谢,原来是这个原因,已经正常了。bind9 我没安装过啊?这个是系统默认的吗?我怕有问题 Ubuntu 还是新装了一场一次
    taobibi
        16
    taobibi  
    OP
       2017-08-08 09:46:46 +08:00
    @whoops 多问一句,如果局域网内其他电脑要使用这个 DNS,是不是还需要
    iptables -t nat
    配置?
    怎么个写法?
    whoops
        17
    whoops  
       2017-08-08 21:21:38 +08:00
    @whoops 你这种情况在同一个局域网的不需要配置 iptables 规则
    bind 是好多 linux 默认的域名服务程序,安装的时候不选不会安装的,如果安装了卸载掉就是了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1006 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 21:07 · PVG 05:07 · LAX 14:07 · JFK 17:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.