dnsmasq-无法绑定 DHCP 服务器套接字:地址已被使用-DHCP 代理

dnsmasq-无法绑定 DHCP 服务器套接字:地址已被使用-DHCP 代理

我在使用 dnsmasq 时遇到了一些问题。我尝试使用路由器提供的现有 dhcp 来创建 pxe 服务器,但 dnsmasq 却给出错误。

/etc/dnsmasq.conf:

port=0
log-dhcp
dhcp-range=192.168.0.0,proxy
dhcp-boot=pxelinux.0
pxe-service=x86PC,'Network Boot',pxelinux
enable-tftp
tftp-root=/tftpboot

错误 :

● dnsmasq.service - DNS caching server.
   Loaded: loaded (/usr/lib/systemd/system/dnsmasq.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sat 2022-05-07 14:50:57 CEST; 1s ago
  Process: 22959 ExecStart=/usr/sbin/dnsmasq -k (code=exited, status=2)
 Main PID: 22959 (code=exited, status=2)

mai 07 14:50:57 host.dynamic.voo.be systemd[1]: Started DNS caching server..
mai 07 14:50:57 host.dynamic.voo.be dnsmasq[22959]: dnsmasq: failed to bind DHCP server socket: Address already in use
mai 07 14:50:57 host.dynamic.voo.be dnsmasq[22959]: failed to bind DHCP server socket: Address already in use
mai 07 14:50:57 host.dynamic.voo.be systemd[1]: dnsmasq.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
mai 07 14:50:57 host.dynamic.voo.be dnsmasq[22959]: FAILED to start up
mai 07 14:50:57 host.dynamic.voo.be systemd[1]: dnsmasq.service: Failed with result 'exit-code'.

接口配置:

2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 10:e7:c6:16:55:8b brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.100/24 brd 192.168.0.255 scope global noprefixroute eno1
       valid_lft forever preferred_lft forever
    inet6 2a02:2788:7d4:66b::9/128 scope global dynamic noprefixroute 
       valid_lft 912066sec preferred_lft 307266sec
    inet6 2a02:2788:7d4:66b:aca7:f9f4:3c57:9d62/64 scope global dynamic noprefixroute 
       valid_lft 1209592sec preferred_lft 604792sec
    inet6 fe80::7f8c:47f6:d123:7c38/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

我的路由器上的 dhcp 参数:

ip of my router : 192.168.0.1
1st address : 192.168.0.10
last address : 192.168.0.99
release time in sec : 604800

问候,

火柴人

答案1

本质上,我没有发现您的设置或配置存在任何实际问题。我已经测试了 dnsmasq 是否能够使用提供的 .conf 文件正常启动,它可以:

root@debian11-template:~# systemctl status dnsmasq.service
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
     Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-05-09 00:50:29 CEST; 6s ago
    Process: 13153 ExecStartPre=/etc/init.d/dnsmasq checkconfig (code=exited, status=0/SUCCESS)
    Process: 13160 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS)
    Process: 13168 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS)
   Main PID: 13167 (dnsmasq)
      Tasks: 1 (limit: 1129)
     Memory: 576.0K
        CPU: 28ms
     CGroup: /system.slice/dnsmasq.service
             └─13167 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service --trust-anchor=.,20326,8,2,e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8e>

May 09 00:50:29 debian11-template systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
May 09 00:50:29 debian11-template dnsmasq[13167]: started, version 2.85 DNS disabled
May 09 00:50:29 debian11-template dnsmasq[13167]: compile time options: IPv6 GNU-getopt DBus no-UBus i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset auth cryptohash DNSSEC loop-detect inotify dumpfile
May 09 00:50:29 debian11-template dnsmasq-dhcp[13167]: DHCP, proxy on subnet 192.168.1.0
May 09 00:50:29 debian11-template dnsmasq-tftp[13167]: TFTP root is /tftpboot
May 09 00:50:29 debian11-template systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
root@debian11-template:~# cat /etc/dnsmasq.conf
port=0
log-dhcp
dhcp-range=192.168.1.0,proxy
dhcp-boot=pxelinux.0
pxe-service=x86PC,'Network Boot',pxelinux
enable-tftp
tftp-root=/tftpboot
root@debian11-template:~# ss -tlnp|grep dnsm
root@debian11-template:~# ss -tlnp|grep dns
root@debian11-template:~# ss -ulnp|grep dns
UNCONN 0      0            0.0.0.0:4011      0.0.0.0:*    users:(("dnsmasq",pid=13167,fd=5))
UNCONN 0      0            0.0.0.0:67        0.0.0.0:*    users:(("dnsmasq",pid=13167,fd=4))
UNCONN 0      0            0.0.0.0:69        0.0.0.0:*    users:(("dnsmasq",pid=13167,fd=7))
UNCONN 0      0               [::]:69           [::]:*    users:(("dnsmasq",pid=13167,fd=8))

请注意,dhcp-range 已经调整以适合我的 IP 子网。

相关内容