dnsmasq:无法绑定 DHCP 服务器套接字:地址已在使用中

dnsmasq:无法绑定 DHCP 服务器套接字:地址已在使用中

我有一个盒子设置为 PXE 服务器。提供 DHCP 租用的接口是 eno3。已安装 dnsmasq 并提供 tftp 服务 ** 未安装 bind - Ubunutu 18.04 **

Error: dnsmasq: failed to bind DHCP server socket: Address already in use

但是,netstat 表明 dnsmasq 已控制端口 67。(DHCP)

有人可以告诉我为什么会出现此错误吗?

netplan yaml、ifconfig、netstat -aunp 和 dnsmasq 在此运行错误:

root@pxebooter:~# dnsmasq
dnsmasq: failed to bind DHCP server socket: Address already in use

root@pxebooter:~# more /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
      version: 2
#     renderer: networkd
      ethernets:
        eno1:
            addresses: [10.1.9.199/24]
            gateway4: 10.1.9.254
            nameservers:
                    addresses: [205.171.3.65,205.171.2.65]
            dhcp4: false
        eno2:
            addresses: [10.1.100.11/24]
            gateway4: 10.1.100.100
            dhcp4: false
            optional: false

        eno3:
            addresses: [10.1.200.1/24]
            gateway4: 10.1.200.1
            dhcp4: false
            optional: false

root@pxebooter:~# ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.1.9.199  netmask 255.255.255.0  broadcast 10.1.9.255
        inet6 fe80::1618:77ff:fe60:c571  prefixlen 64  scopeid 0x20<link>
        ether 14:18:77:60:c5:71  txqueuelen 1000  (Ethernet)
        RX packets 7695  bytes 1124240 (1.1 MB)
        RX errors 0  dropped 742  overruns 0  frame 0
        TX packets 2133  bytes 228533 (228.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 94

eno2: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 14:18:77:60:c5:72  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 95

eno3: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 14:18:77:60:c5:73  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 97

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 130  bytes 10266 (10.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 130  bytes 10266 (10.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@pxebooter:~# grep -v '^#' /etc/dnsmasq.conf
port=0
interface=eno3
dhcp-range=100.1.200.50,10.1.200.150,12h
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/home/pxe
tftp-no-fail
dhcp-lease-max=99
dhcp-leasefile=/home/pxe/leases
dhcp-authoritative
dhcp-script=/bin/echo

root@pxebooter:~# netstat -aunp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp    15360      0 127.0.0.53:53           0.0.0.0:*                           1356/systemd-resolv
udp    33600      0 0.0.0.0:67              0.0.0.0:*                           1877/dnsmasq
udp        0      0 0.0.0.0:69              0.0.0.0:*                           1877/dnsmasq
udp6       0      0 :::69                   :::*                                1877/dnsmasq

root@pxebooter:~# tftp localhost
tftp> get test.txt
Received 17 bytes in 0.0 seconds
tftp> quit

root@pxebooter:~# dnsmasq
dnsmasq: failed to bind DHCP server socket: Address already in use
root@pxebooter:~# dnsmasq -h

答案1

嗯,这很尴尬。

eno3无法绑定到网络地址的原因是我的网络地址错误。我应该先看看系统日志。

Aug 14 10:47:52 pxebooter systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
Aug 14 10:49:02 pxebooter dnsmasq-dhcp[2769]: DHCP range 10.1.200.150 -- 100.1.200.50 is not consistent with netmask 255.255.255.0
Aug 14 10:49:02 pxebooter dnsmasq-dhcp[2769]: no address range available for DHCP request via eno3

显然 10.xxx 和 100.xxx 不在 /24 子网掩码范围内。

我不想承认我因为没有注意到多了一个零而浪费了多少时间。

感谢大家的帮助。

答案2

dnsmasq已经在运行,并且正在侦听端口 67,这就是您收到该消息的原因。如果您停止该dnsmasq服务,您将能够手动运行它。

答案3

您需要做的就是将 dnsmasq.conf 文件移动到根文件夹或 dnsmasq.d 文件夹。您可以尝试这两个文件夹,在我的情况下,将文件移动到 dnsmasq.d 文件夹是有效的。干杯:)

相关内容