dnsmasq 不分发 IP 地址

dnsmasq 不分发 IP 地址

我正在尝试了解网络,具体来说,我目前正在尝试创建一个在连接到我的主路由器的 NAT 后面运行的专用网络。

我的想法如下:

                                 +---------------------------------------------------+
                                 |10.0.0.0/24                                        |
                                 |                               +-------+           |
                          +------+---------------------------+   |Switch |   +-----+ |
                          |Raspberry Pi                      |   |       +---+     | |
                          |                                  |   |       |   +-----+ |
                          |                              eth1+---+       |           |
    +-----------------+   |                          10.0.0.1|   |       |           |
    |Router           |   |                                  |   |       |   +-----+ |
    |192.168.100.1    +---+eth0              dnsmasq settings|   |       +---+     | |
+---+dhcp:            |   |192.168.100.5   range: 10.0.0.2/24|   |       |   +-----+ |
    |192.168.100.2/24 |   |              gateway:    10.0.0.1|   +-------+           |
    |                 |   |                                  |                       |
    +-----+------+----+   +------+---------------------------+                       |
          |      |               |                                                   |
          |      |               +---------------------------------------------------+
          |      |
          |      +------------------------------------+ Other devices
          |
          |       +---------------+
          |       |pi-hole        |
          +-------+192.168.100.3  |
                  |               |
                  +---------------+

现在我想我已经正确设置了树莓派。配置如下:

/etc/dnsmasq.conf

domain=local.pi
local=/local.pi/

no-hosts
addn-hosts=/etc/hosts.d

localise-queries

no-poll
no-resolv
cache-size=10000

log-async
log-queries=extra
log-facility=/var/log/dnsmasq/dnsmasq.log

local-ttl=2

server=192.168.100.3
server=9.9.9.9

domain-needed
bogus-priv

interface=eth1
dhcp-authoritative
dhcp-range=10.0.0.2,10.0.0.254,1h
dhcp-option=option:router,10.0.0.1
dhcp-leasefile=/etc/dhcp.leases

然而,dnsmasq 似乎没有分发任何 IP 地址,如日志所示:

Sep 30 22:37:25 dnsmasq[3296]: started, version 2.76 cachesize 10000
Sep 30 22:37:25 dnsmasq[3296]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify
Sep 30 22:37:25 dnsmasq-dhcp[3296]: DHCP, IP range 10.0.0.2 -- 10.0.0.254, lease time 1h
Sep 30 22:37:25 dnsmasq[3296]: using nameserver 9.9.9.9#53
Sep 30 22:37:25 dnsmasq[3296]: using nameserver 192.168.100.3#53
Sep 30 22:37:25 dnsmasq[3296]: using local addresses only for domain local.pi
Sep 30 22:37:33 dnsmasq-dhcp[3296]: no address range available for DHCP request via eth1

当客户端请求 IP 时,最后一条消息会不断重复。以下是 tcpdump 的输出:

# tcpdump -v
tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
23:14:53.372604 IP (tos 0x0, ttl 64, id 17534, offset 0, flags [none], proto UDP (17), length 384)
   0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from b8:27:eb:64:2b:f2 (oui Unknown), length 356, xid 0x37bc3a64, secs 11906, Flags [none]
   Client-Ethernet-Address b8:27:eb:64:2b:f2 (oui Unknown)
   Vendor-rfc1048 Extensions
     Magic Cookie 0x63825363
     DHCP-Message Option 53, length 1: Discover
     Client-ID Option 61, length 7: ether b8:27:eb:64:2b:f2
     SLP-NA Option 80, length 0""
     NOAUTO Option 116, length 1: Y
     MSZ Option 57, length 2: 1472
     Vendor-Class Option 60, length 56: "dhcpcd-6.11.5:Linux-4.14.34-hypriotos-v7+:armv7l:BCM2835"
     Hostname Option 12, length 14: "test-client"
     T145 Option 145, length 1: 1
     Parameter-Request Option 55, length 15:
       Subnet-Mask, Classless-Static-Route, Static-Route, Default-Gateway
       Domain-Name-Server, Hostname, Domain-Name, MTU
       BR, NTP, Lease-Time, Server-ID
       RN, RB, Option 119
23:15:07.057241 IP (tos 0x0, ttl 64, id 26091, offset 0, flags [none], proto UDP (17), length 384)
   0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 00:e0:4c:23:c2:22 (oui Unknown), length 356, xid 0x1b0502bb, secs 8250, Flags [none]
   Client-Ethernet-Address 00:e0:4c:23:c2:22 (oui Unknown)
   Vendor-rfc1048 Extensions
     Magic Cookie 0x63825363
     DHCP-Message Option 53, length 1: Discover
     Client-ID Option 61, length 7: ether 00:e0:4c:23:c2:22
     SLP-NA Option 80, length 0""
     NOAUTO Option 116, length 1: Y
     MSZ Option 57, length 2: 1472
     Vendor-Class Option 60, length 56: "dhcpcd-6.11.5:Linux-4.14.34-hypriotos-v7+:armv7l:BCM2835"
     Hostname Option 12, length 14: "gateway"
     T145 Option 145, length 1: 1
     Parameter-Request Option 55, length 15:
       Subnet-Mask, Classless-Static-Route, Static-Route, Default-Gateway
       Domain-Name-Server, Hostname, Domain-Name, MTU
       BR, NTP, Lease-Time, Server-ID
       RN, RB, Option 119#
^C
2 packets captured
2 packets received by filter
0 packets dropped by kernel

我缺少什么?最终目标是 10.0.0.0/24 范围内的所有网络都将通过 nat 连接到互联网的其余部分。

相关内容