为什么我的网桥不传输 DHCP 广播数据包?

为什么我的网桥不传输 DHCP 广播数据包?

我正在尝试将通过以太网连接的 debian bullseye 台式机设置为 wifi 接入点。我想使用我的 ISP 路由器(freebox delta,FWIW)DHCP 东西。我已经按照说明在运行 LibreELEC 的 raspberry pi 4 上成功完成了同样的事情这里,但 libreelec 不使用网络管理器。由于我对网络方面的东西相当无知,所以我无法使用网络管理器重现类似的设置。

我发现了类似的问题这里,但说明相当少。我设法让它在 IPv6 上工作,但出于某种原因,我的 Android 手机没有 IPv4(我需要它)。

我正在使用nmtui并且以下是我所做的:

 ┌───────────────────────────┤ Edit Connection ├───────────────────────────┐
 │                                                                         │
 │         Profile name ethernet-wifi-bridge____________________           │
 │               Device nm-bridge_______________________________           │
 │                                                                         │
 │ + BRIDGE                                                      <Hide>    │
 │ | Slaves                                                                │
 │ | ┌───────────────────────────────────────────────┐                     │
 │ | │ Connexion Wi-Fi 1                           ↑ │ <Add>               │
 │ | │ Connexion Ethernet 1                        ▒ │                     │
 │ | │                                             █ │ <Edit...>           │
 │ | │                                             ▒ │                     │
 │ | │                                             ▒ │ <Delete>            │
 │ | │                                             ↓ │                     │
 │ | └───────────────────────────────────────────────┘                     │
 │ |         Aging time 300_______ seconds                                 │
 │ | [X] Enable IGMP snooping                                              │
 │ | [X] Enable STP (Spanning Tree Protocol)                               │
 │ |           Priority 32768_____                                         │
 │ |      Forward delay 15________ seconds                                 │
 │ |         Hello time 2_________ seconds                                 │
 │ |            Max age 20________ seconds                                 │
 │ | Group forward mask 0_________                                         │
 │ \                                                                       │
 │                                                                         │
 │ + IPv4 CONFIGURATION <Manual>                                 <Hide>    │
 │ |          Addresses 192.168.1.141/24_________ <Remove>                 │
 │ |                    <Add...>                                           │
 │ |            Gateway 192.168.1.254____________                          │
 │ |        DNS servers 80.67.169.12_____________ <Remove>                 │
 │ |                    80.67.169.40_____________ <Remove>                 │
 │ |                    <Add...>                                           │
 │ |     Search domains <Add...>                                           │
 │ |                                                                       │
 │ |            Routing (No custom routes) <Edit...>                       │
 │ | [ ] Never use this network for default route                          │
 │ | [ ] Ignore automatically obtained routes                              │
 │ | [ ] Ignore automatically obtained DNS parameters                      │
 │ |                                                                       │
 │ | [ ] Require IPv4 addressing for this connection                       │
 │ \                                                                       │
 │                                                                         │
 │ - IPv6 CONFIGURATION <Automatic>                              <Show>    │
 │                                                                         │
 │ [X] Automatically connect                                               │
 │ [X] Available to all users                                              │
 │                                                                         │
 │                                                           <Cancel> <OK> │
 └─────────────────────────────────────────────────────────────────────────┘

(我手动设置了 IPv4 地址和网关,因为运行 libreELEC 的 Pi 上需要这个,但我也尝试过自动设置,但效果并没有好转)。


 ┌─┌─────────────────────────┤ Edit Connection ├──────────────────────────┐┐
 │ │                                                                      │
 │ │         Profile name Connexion Wi-Fi 1_______________________        │
 │ │               Device wlp4s0 (B0:A4:60:FB:70:6B)______________        │
 │ │                                                                      │
 │ │ + WI-FI                                                       <Hide> │
 │ │ |               SSID caradubouchik___________________________        │
 │ │ |               Mode <Access Point>                                  │
 │ │ |            Channel <Automatic>                                     │
 │ │ |                                                                    │
 │ │ |           Security <WPA & WPA2 Personal>                           │
 │ │ |           Password ________________________________________        │
 │ │ |                    [ ] Show password                               │
 │ │ |                                                                    │
 │ │ |              BSSID ________________________________________        │
 │ │ | Cloned MAC address ________________________________________        │
 │ │ |                MTU __________ (default)                            │
 │ │ \                                                                    │
 │ │                                                                      │
 │ │ + BRIDGE PORT                                                 <Hide> │
 │ │ |           Priority 32________                                      │
 │ │ |          Path cost 100_______                                      │
 │ │ | [ ] Hairpin mode                                                   │
 │ │ \                                                                    │
 │ │ [X] Automatically connect                                            │
 │ │ [X] Available to all users                                           │
 │ │                                                                      │
 │ │                                                        <Cancel> <OK> │
 └─└──────────────────────────────────────────────────────────────────────┘

(密码是隐藏的,但我设置了一个)


 ┌─┌─────────────────────────┤ Edit Connection ├──────────────────────────┐┐
 │ │                                                                      │
 │ │         Profile name Connexion Ethernet 1____________________        │
 │ │               Device enp5s0 (A8:A1:59:66:94:3E)______________        │
 │ │                                                                      │
 │ │ - ETHERNET                                                    <Show> │
 │ │                                                                      │
 │ │ + BRIDGE PORT                                                 <Hide> │
 │ │ |           Priority 32________                                      │
 │ │ |          Path cost 100_______                                      │
 │ │ | [ ] Hairpin mode                                                   │
 │ │ \                                                                    │
 │ │ [X] Automatically connect                                            │
 │ │ [X] Available to all users                                           │
 │ │                                                                      │
 │ │                                                        <Cancel> <OK> │
 └─└──────────────────────────────────────────────────────────────────────┘

这是nmcli输出:

nm-bridge: connecté à ethernet-wifi-bridge
        "nm-bridge"
        bridge, 6A:D1:FD:B4:58:75, sw, mtu 1500
        ip4 par défaut, ip6 par défaut
        inet4 192.168.1.141/24
        route4 192.168.1.0/24
        route4 0.0.0.0/0
        inet6 2a01:e0a:a57:a150:59e7:1659:650b:928c/64
        inet6 fe80::75d6:ad05:8657:f3b0/64
        route6 2a01:e0a:a57:a150::/64
        route6 ::/0
        route6 fe80::/64

enp5s0: connecté à Connexion Ethernet 1
        "Realtek Matisse GPP Bridge"
        ethernet (r8169), A8:A1:59:66:94:3E, hw, mtu 1500
        master nm-bridge

wlp4s0: connecté à Connexion Wi-Fi 1
        "Intel 6 AX200"
        wifi (iwlwifi), B0:A4:60:FB:70:6B, hw, mtu 1500
        master nm-bridge

DNS configuration:
        servers: 80.67.169.12 80.67.169.40
        interface: nm-bridge

        servers: 2001:910:800::12 2001:910:800::40
        interface: nm-bridge

以下是我的 Android 设备显示的内容:

Android 网络详细信息

为什么我的 Android 手机没有 IPv4?我猜是 nmtui 的复选框和/或文本字段出了问题,但我不知道是哪一个。谢谢您的帮助!

编辑:感谢@user1686,我将问题标题改为更具体的内容。因此,网桥不会将 BOOTP/DHCP 请求从 wifi 传输到以太网设备,这由以下人员证明:

~> sudo tcpdump -n -e -i wlp4s0 | grep DHCP
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on wlp4s0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
08:43:53.751959 a0:78:17:7f:86:71 > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 342: 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from a0:78:17:7f:86:71, length 300
08:43:53.751971 a0:78:17:7f:86:71 > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 342: 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from a0:78:17:7f:86:71, length 300
[...]
# simultaneously:
~> sudo tcpdump -n -e -i enp5s0 | grep DHCP
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on enp5s0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
[nothing]

ip addr也许和中有些东西可看route -n?这是 Raspberry Pi 上的输出,其中桥正确地将 DHCP 请求从 wifi 传输到以太网,供参考:

rasptv:~ # ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP8000> mtu 1500 qdisc mq master br0 qlen 1000
    link/ether dc:a6:32:59:0b:9a brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP8000> mtu 1500 qdisc fq_codel master br0 qlen 1000
    link/ether dc:a6:32:59:0b:9c brd ff:ff:ff:ff:ff:ff
    inet6 fe80::dea6:32ff:fe59:b9c/64 scope link 
       valid_lft forever preferred_lft forever
6: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue qlen 1000
    link/ether dc:a6:32:59:0b:9a brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.104/24 brd 192.168.1.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 2a01:e0a:a57:a150:dea6:32ff:fe59:b9a/64 scope global dynamic 
       valid_lft 86278sec preferred_lft 86278sec
    inet6 fe80::64b2:93ff:fe03:c901/64 scope link 
       valid_lft forever preferred_lft forever
7: tether: <BROADCAST,MULTICAST,UP,LOWER_UP8000> mtu 1500 qdisc noqueue qlen 1000
    link/ether ae:5e:80:f9:59:f1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.1/24 brd 192.168.0.255 scope global tether
       valid_lft forever preferred_lft forever
    inet6 fe80::ac5e:80ff:fef9:59f1/64 scope link 
       valid_lft forever preferred_lft forever
rasptv:~ # route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.254   0.0.0.0         UG    0      0        0 br0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 tether
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 br0

这是在非 DHCP 传输机器上的情况:

~> sudo ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master nm-bridge state UP group default qlen 1000
    link/ether a8:a1:59:66:94:3e brd ff:ff:ff:ff:ff:ff
3: wlp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master nm-bridge state UP group default qlen 1000
    link/ether b0:a4:60:fb:70:6b brd ff:ff:ff:ff:ff:ff
4: nm-bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 6a:d1:fd:b4:58:75 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.141/24 brd 192.168.1.255 scope global noprefixroute nm-bridge
       valid_lft forever preferred_lft forever
    inet6 2a01:e0a:a57:a150:59e7:1659:650b:928c/64 scope global dynamic noprefixroute 
       valid_lft 86360sec preferred_lft 86360sec
    inet6 fe80::75d6:ad05:8657:f3b0/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
5: br-61d11f468acb: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:0d:6a:ed:12 brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 brd 172.18.255.255 scope global br-61d11f468acb
       valid_lft forever preferred_lft forever
6: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:c9:d9:55:1d brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
7: br-feed140e8225: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:00:ed:09:58 brd ff:ff:ff:ff:ff:ff
    inet 172.21.0.1/16 brd 172.21.255.255 scope global br-feed140e8225
       valid_lft forever preferred_lft forever
 ~> sudo route -n
Table de routage IP du noyau
Destination     Passerelle      Genmask         Indic Metric Ref    Use Iface
0.0.0.0         192.168.1.254   0.0.0.0         UG    425    0        0 nm-bridge
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.18.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-61d11f468acb
172.21.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-feed140e8225
192.168.1.0     0.0.0.0         255.255.255.0   U     425    0        0 nm-bridge

Docker 已安装在这里,但我认为它与此问题无关,是吗?我需要设置此tether接口吗?任何帮助表示感谢!

答案1

感谢 r/techsupport subreddit 的 discord 频道,我通过添加重启持久 iptables 规则实现了此功能。

> cat /etc/NetworkManager/dispatcher.d/99-bridge 
#!/bin/sh

INTERFACE=$1
ACTION=$2

if [ "$INTERFACE" = "nm-bridge" ]; then
  if [ "$ACTION" = "up" ]; then
    iptables -A FORWARD -i nm-bridge -j ACCEPT
  fi
fi

相关内容