即使接口已启动,DNSMASQ 也拒绝以“未知接口错误”启动

即使接口已启动,DNSMASQ 也拒绝以“未知接口错误”启动

这是一个我在互联网上其他地方找不到的奇怪问题,暗示这可能是我搞砸了,但是什么?

尝试启动dnsmasq.service,无论是在启动时还是在所有网络服务可用且工作时从用户会话启动,都会失败并出现unknown interface enp2s0错误......除非系统的整个其余部分声称它已启动。

andrzej@andrzej-PC ~ $ sudo systemctl start dnsmasq
Job for dnsmasq.service failed because the control process exited with 
error code. See "systemctl status dnsmasq.service" and "journalctl -xe" for details.
andrzej@andrzej-PC ~ $ systemctl status dnsmasq
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
   Loaded: loaded (/lib/systemd/system/dnsmasq.service; disabled; 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 Mon 2017-07-10 02:09:41 CEST; 3s ago
  Process: 5551 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=
  Process: 5548 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUC

Jul 10 02:09:41 andrzej-PC systemd[1]: Starting dnsmasq - A lightweight DHCP and
Jul 10 02:09:41 andrzej-PC dnsmasq[5548]: dnsmasq: syntax check OK.
Jul 10 02:09:41 andrzej-PC dnsmasq[5551]: dnsmasq: unknown interface enp2s0
Jul 10 02:09:41 andrzej-PC systemd[1]: dnsmasq.service: Control process exited, 
Jul 10 02:09:41 andrzej-PC systemd[1]: Failed to start dnsmasq - A lightweight D
Jul 10 02:09:41 andrzej-PC systemd[1]: dnsmasq.service: Unit entered failed stat
Jul 10 02:09:41 andrzej-PC systemd[1]: dnsmasq.service: Failed with result 'exit

正确,除了:

andrzej@andrzej-PC ~ $ ifconfig
enp2s0    Link encap:Ethernet  HWaddr /*correct address*/  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:921 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:147421 (147.4 KB)

和同样的ip addr

2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether /*same*/ brd ff:ff:ff:ff:ff:ff

最后:

andrzej@andrzej-PC ~ $ cat /sys/class/net/enp2s0/operstate
up

什么?哦,我的配置文件如下所示:

port=0
interface=enp2s0
dhcp-range=192.168.0.50,192.168.0.150,12h
dhcp-boot=/install/netboot/pxelinux.0
dhcp-option-force=209,install/netboot/pxelinux.cfg
dhcp-option-force=210,/
dhcp-option-force=66,192.168.0.1
enable-tftp
tftp-root=/mnt

答案1

修改DNSMasq服务描述

sudo nano /lib/systemd/system/dnsmasq.service

更改 Requires 和 After,以便在接口启动后启动。

Requires=network-online.target
After=network-online.target

答案2

我遇到了同样的情况 - dnsmasq 拒绝在用于 PXE 的辅助 eth 接口上启动,背靠背(无交换机)连接到另一台计算机。

一旦我建立了链接(一些网络流量,NIC 灯亮起),dnsmasq 就开始正常了。

我知道这不是很科学,但它对我有用(Ubuntu 20.04)

答案3

系统重新启动有帮助 - dnsmasq 启动没有问题。配置为与 dnsmasq 一起使用的接口的设备配置可能尚未生效

答案4

当您使用 Linux 时,您可以启用动态绑定。根据文档:

启用混合网络模式--bind-interfaces 和默认值。 Dnsmasq 绑定各个接口的地址,允许多个 dnsmasq 实例,但如果出现新的接口或地址,它会自动侦听这些接口或地址(受任何访问控制配置的约束)。这使得动态创建的接口以与默认接口相同的方式工作。实现此选项需要非标准网络 API,并且仅在 Linux 下可用。在其他平台上它会回退到--bind-interfaces模式。

记得删除绑定接口

参考:https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

相关内容