在 Centos 8(或 Fedora)中创建桥接 WiFi AP(热点)

Pas*_*rri 6 wifi fedora access-point bridge centos8

我正在尝试使用 NetworkManager 在 Centos 8 系统上创建桥接 WiFi 热点。该机器是 Dell EPC3000,配有两个内置 GigE 和 ath10k 无线适配器,以及一个 LTE WWAN。

创建 NAT 热点效果很好:

nmcli con add type wifi ifname wlp4s0 con-name wlp4s0 autoconnect yes ssid test
nmcli con modify wlp4s0 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli con modify wlp4s0ap wifi-sec.key-mgmt wpa-psk
nmcli con modify wlp4s0ap wifi-sec.psk "password"
nmcli con up wlp4s0ap 
Run Code Online (Sandbox Code Playgroud)

这会将私有 IP 分配给 wlp4s0 接口,调用 dhcp 的 dnsmasq 并为热点创建正确的 iptables 配置。

现在我的想法是取消 NAT 并将 wifi 接口桥接到辅助 GigE,通过其远程 DHCP 和其他服务为该网段的 wifi 客户端提供服务。

创建网桥并奴役 wlp4s0 和辅助 GigE 工作正常,而 AP 保持正常运行并设置信标(始终使用 nmcli)

# bridge link
4: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 100
5: wlp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 100
Run Code Online (Sandbox Code Playgroud)

当 wlp4s0ap 连接从属于 br0 时,它可以预见地会丢失其 IPv4 设置。br0 网桥工作正常,就像我在其上启用 DHCP 一样,它从桥接的 GigE 网段获取 IPv4/v6。

现在,人们可能会认为网桥配置不会影响(dbus 控制的)维护接入点的 wpa_supplicant。但是,每当桥接 wlp4s0 接口时,wpa_supplicant 都会在完成 EAPOL 握手时中途停止 WPA 身份验证:

hostapd_logger: STA 84:c7:ea:39:9b:28 - start authentication
WPA: 84:c7:ea:39:9b:28 WPA_PTK entering state INITIALIZE
wpa_driver_nl80211_set_key: ifindex=5 (wlp4s0) alg=0 addr=0x55d8a39e0bb0 key_idx=0 set_tx=1 seq_len=0 key_len=0
   addr=84:c7:ea:39:9b:28
nl80211: Set STA flags - ifname=wlp4s0 addr=84:c7:ea:39:9b:28 total_flags=0x66 flags_or=0x0 flags_and=0xfffffffe authorized=0
hostapd_logger: STA 84:c7:ea:39:9b:28 - unauthorizing port
WPA: 84:c7:ea:39:9b:28 WPA_PTK_GROUP entering state IDLE
WPA: 84:c7:ea:39:9b:28 WPA_PTK entering state AUTHENTICATION
WPA: 84:c7:ea:39:9b:28 WPA_PTK entering state AUTHENTICATION2
WPA: Assign ANonce - hexdump(len=32): 6c 11 09 50 95 fc 7d 80 80 a0 a9 a7 be eb 23 d3 ec 6e f4 ef 42 87 ca 45 5e 55 80 5b 54 c0 38 7e
WPA: 84:c7:ea:39:9b:28 WPA_PTK entering state INITPSK
Searching a PSK for 84:c7:ea:39:9b:28 prev_psk=(nil)
Searching a PSK for 84:c7:ea:39:9b:28 prev_psk=(nil)
WPA: 84:c7:ea:39:9b:28 WPA_PTK entering state PTKSTART
hostapd_logger: STA 84:c7:ea:39:9b:28 - sending 1/4 msg of 4-Way Handshake
WPA: Send EAPOL(version=2 secure=0 mic=0 ack=1 install=0 pairwise=1 kde_len=0 keyidx=0 encr=0)
WPA: Replay Counter - hexdump(len=8): 00 00 00 00 00 00 00 01
WPA: Use EAPOL-Key timeout of 100 ms (retry counter 1)
wlp4s0: hostapd_new_assoc_sta: reschedule ap_handle_timer timeout for 84:c7:ea:39:9b:28 (300 seconds - ap_max_inactivity)
wlp4s0: Event EAPOL_TX_STATUS (37) received
hostapd_logger: STA 84:c7:ea:39:9b:28 - EAPOL-Key timeout
WPA: 84:c7:ea:39:9b:28 WPA_PTK entering state PTKSTART
hostapd_logger: STA 84:c7:ea:39:9b:28 - sending 1/4 msg of 4-Way Handshake
WPA: Send EAPOL(version=2 secure=0 mic=0 ack=1 install=0 pairwise=1 kde_len=0 keyidx=0 encr=0)
WPA: Replay Counter - hexdump(len=8): 00 00 00 00 00 00 00 02
WPA: Use EAPOL-Key timeout of 1000 ms (retry counter 2)
wlp4s0: Event EAPOL_TX_STATUS (37) received
hostapd_logger: STA 84:c7:ea:39:9b:28 - EAPOL-Key timeout
WPA: 84:c7:ea:39:9b:28 WPA_PTK entering state PTKSTART
hostapd_logger: STA 84:c7:ea:39:9b:28 - sending 1/4 msg of 4-Way Handshake
WPA: Send EAPOL(version=2 secure=0 mic=0 ack=1 install=0 pairwise=1 kde_len=0 keyidx=0 encr=0)
WPA: Replay Counter - hexdump(len=8): 00 00 00 00 00 00 00 03
WPA: Use EAPOL-Key timeout of 1000 ms (retry counter 3)
wlp4s0: Event EAPOL_TX_STATUS (37) received
hostapd_logger: STA 84:c7:ea:39:9b:28 - EAPOL-Key timeout
WPA: 84:c7:ea:39:9b:28 WPA_PTK entering state PTKSTART
hostapd_logger: STA 84:c7:ea:39:9b:28 - sending 1/4 msg of 4-Way Handshake
WPA: Send EAPOL(version=2 secure=0 mic=0 ack=1 install=0 pairwise=1 kde_len=0 keyidx=0 encr=0)
WPA: Replay Counter - hexdump(len=8): 00 00 00 00 00 00 00 04
WPA: Use EAPOL-Key timeout of 1000 ms (retry counter 4)
wlp4s0: Event EAPOL_TX_STATUS (37) received
hostapd_logger: STA 84:c7:ea:39:9b:28 - EAPOL-Key timeout
WPA: 84:c7:ea:39:9b:28 WPA_PTK entering state PTKSTART
hostapd_logger: STA 84:c7:ea:39:9b:28 - PTKSTART: Retry limit 4 reached
Run Code Online (Sandbox Code Playgroud)

我知道这种桥接是大多数基于 Linux 的接入点的做法,我想知道 Centos 8 会采取什么不同的方式来破坏 wpa_supplicant。我还从 w1.fi git 编译了最新的 wpa_supplicant,但它的行为方式相同,可以与 NAT 完美配合,但会破坏网桥。

我还摆弄了 /sys/class/net/br0/bridge/group_fwd_mask 以确保没有 wifi 控制数据包被丢弃,没有效果。

还尝试了 NetworkManager 外部的通用(编译)hostapd 包(例如由 DD-WRT 接入点使用),但一旦我启用桥接,它也会破坏 WPA。

有什么建议下一步要尝试什么吗?

Pas*_*rri 2

我让桥接 AP 正常工作

  • 从源代码编译并安装 hostapd
  • 从 NetworkManager 取消管理 WiFi 接口(nmcli 开发集管理否)
  • 使用 NetworkManager 创建桥接接口并将第二个以太网添加为从属以太网
  • 禁用系统提供的 wpa_supplicant
  • 将“bridge=br0”添加到启动hostapd的hostapd.conf中

现在我认为 NetworkManager 和标准 wpa_supplicant 也应该可以实现这一点,但此解决方案目前有效。