B.A.T.M.A.N ad-hoc WiFi 节点无法相互 ping 通

B.A.T.M.A.N ad-hoc WiFi nodes cannot ping each other

我正在努力将 2 台 linux 机器连接到一个由 B.A.T.M.A.N ( batman-adv ) 管理的临时 WiFi 网络,每台机器都带有这个 USB Dongle:https://www.tp-link.com/us/home-networking/usb-adapter/archer-t2u-nano/

当 运行 时,此脚本显示两个设备都加入了同一个 ad-hoc/IBSS 网络。

我为两个 'bat0' 设备静态分配了 IP 地址和路由。但是,我无法 ping 通或以其他方式使用两个设备之间的连接。

我做错了什么以及如何在连接的客户端和服务器之间使用 Linux 中的网状网络?谢谢。

我的 'server' 节点配置了这个脚本:

#!/bin/bash

# Cleanup
/sbin/ip link set wlan0 down
/sbin/ip addr flush dev wlan0
/usr/sbin/iw wlan0 set type managed
/sbin/rmmod batman-adv
/sbin/ip link set mtu 1500 dev wlan0

# Ensure batman present
/sbin/modprobe batman-adv

# Setup adhoc mode
/sbin/ip link set mtu 1560 dev wlan0
/usr/sbin/iw wlan0 set type ibss
/sbin/ip link set wlan0 up
#/usr/sbin/iw dev wlan0 ibss join My-Mesh 5180 fixed-freq 02:12:34:56:78:9A
/usr/sbin/iw dev wlan0 ibss join My-Mesh 5180

# Configure batman server
batctl if add wlan0
/sbin/ip link set bat0 up
batctl gw_mode server

# Assign Ip Address
/sbin/ip addr add 10.254.239.1/24 broadcast 10.254.239.255 dev bat0
/sbin/ip route add 10.254.239.0/24 dev bat0

# List device properties
sleep 5
batctl if
/usr/sbin/iw dev
/usr/sbin/iw dev wlan0 link

该脚本的输出显示如下:

wlan0: active
phy#0
        Interface wlan0
                ifindex 6
                wdev 0x1
                addr 98:48:27:e1:b4:a1
                ssid My-Mesh
                type IBSS
                channel 36 (5180 MHz), width: 20 MHz, center1: 5180 MHz
                txpower 20.00 dBm
Joined IBSS 02:11:87:f2:30:87 (on wlan0)
        SSID: My-Mesh
        freq: 5180

ifconfig 和 dmesg 都显示为客户端配置的蝙蝠侠:

bat0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.254.239.2  netmask 255.255.255.0  broadcast 10.254.239.255
        inet6 fe80::d4b3:31ff:fea4:b056  prefixlen 64  scopeid 0x20<link>
        ether d6:b3:31:a4:b0:56  txqueuelen 1000  (Ethernet)
        RX packets 410  bytes 17220 (17.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 19  bytes 846 (846.0 B)
        TX errors 0  dropped 62 overruns 0  carrier 0  collisions 0

[ 2223.705686] batman_adv: B.A.T.M.A.N. advanced 2021.0 (compatibility version 15) loaded
[ 2223.718444] batman_adv: bat0: Adding interface: wlx984827e1b29c
[ 2223.718448] batman_adv: bat0: Interface activated: wlx984827e1b29c

ifconfig 和 dmesg 都显示 batman 正在为服务器配置:

bat0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 10.254.239.1  netmask 255.255.255.0  broadcast 10.254.239.255
        ether ea:ca:36:20:2f:8c  txqueuelen 1000  (Ethernet)
        RX packets 432  bytes 18144 (17.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 15  bytes 738 (738.0 B)
        TX errors 0  dropped 1109 overruns 0  carrier 0  collisions 0

[ 2189.342306] batman_adv: B.A.T.M.A.N. advanced 2021.4-dirty (compatibility version 15) loaded
[ 2189.581796] batman_adv: bat0: Adding interface: wlan0
[ 2189.581848] batman_adv: bat0: Interface activated: wlan0

我的 'client' 节点配置了这个脚本:

#!/bin/bash

# Cleanup
DEV="wlx984827e1b29c"
/sbin/ip link set ${DEV} down
/sbin/ip addr flush dev ${DEV}
/usr/sbin/iw ${DEV} set type managed
/sbin/rmmod batman-adv
/sbin/ip link set mtu 1500 dev ${DEV}

# Ensure batman present
/sbin/modprobe batman-adv

# Setup adhoc mode
/sbin/ip link set mtu 1560 dev ${DEV}
/usr/sbin/iw ${DEV} set type ibss
/sbin/ip link set ${DEV} up
#/usr/sbin/iw dev ${DEV} ibss join My-Mesh 5180 fixed-freq 02:12:34:56:78:9A
/usr/sbin/iw dev ${DEV} ibss join My-Mesh 5180

# Configure batman server
/usr/sbin/batctl if add ${DEV}
/sbin/ip link set bat0 up
/usr/sbin/batctl gw_mode client

# Set the mesh-bridge IP
# Assign Ip Address
/sbin/ip addr add 10.254.239.2/24 broadcast 10.254.239.255 dev bat0
/sbin/ip route add 10.254.239.0/24 dev bat0

# Info
sleep 5
batctl if
/usr/sbin/iw dev
/usr/sbin/iw dev ${DEV} link

该脚本的输出显示这些消息:

wlx984827e1b29c: active
phy#0
    Interface wlx984827e1b29c
        ifindex 3
        wdev 0x1
        addr 98:48:27:e1:b2:9c
        ssid My-Mesh
        type IBSS
        channel 36 (5180 MHz), width: 20 MHz, center1: 5180 MHz
        txpower 20.00 dBm
Joined IBSS 02:11:87:f2:30:87 (on wlx984827e1b29c)
    SSID: My-Mesh
    freq: 5180

Linux batctl 命令从服务器和客户端的角度都显示没有连接的节点。

服务器:

batctl o
[B.A.T.M.A.N. adv 2021.4-dirty, MainIF/MAC: wlan0/98:48:27:e1:b4:a1 (bat0/ea:ca:36:20:2f:8c BATMAN_IV)]
   Originator        last-seen (#/255) Nexthop           [outgoingIF]

客户:

batctl o
[B.A.T.M.A.N. adv 2021.0, MainIF/MAC: wlx984827e1b29c/98:48:27:e1:b2:9c (bat0/d6:b3:31:a4:b0:56 BATMAN_IV)]
   Originator        last-seen (#/255) Nexthop           [outgoingIF]

我无法从服务器 ping 客户端:

ping 10.254.239.2
PING 10.254.239.2 (10.254.239.2) 56(84) bytes of data.
From 10.254.239.1 icmp_seq=1 Destination Host Unreachable
From 10.254.239.1 icmp_seq=2 Destination Host Unreachable
From 10.254.239.1 icmp_seq=3 Destination Host Unreachable

我也无法从客户端 ping 服务器:

ping 10.254.239.1
PING 10.254.239.1 (10.254.239.1) 56(84) bytes of data.
From 10.254.239.2 icmp_seq=1 Destination Host Unreachable
From 10.254.239.2 icmp_seq=2 Destination Host Unreachable
From 10.254.239.2 icmp_seq=3 Destination Host Unreachable

答案确实是您需要一个真正在驱动程序堆栈中正确实现 Ad-Hoc/IBSS 网络的 WiFi 无线电。