wlan0 桥接至 eth0 有效,但 eth0 无法上网

wlan0 桥接至 eth0 有效,但 eth0 无法上网

我正在尝试使用 hostapd 配置 Linux 机器,以使用 wlan0 接口作为接入点。eth0 是唯一连接到路由器的以太网端口。我能够连接到接入点,并且它可以访问互联网,但是当 hostapd 正在运行并且 wlan0 接口已启动时,我无法在机器本身上访问互联网(无法通过 SSH 进入机器,也无法更新 NTP)。

拓扑 br0 = eth0 + wlan0 && br0 stp = ON && linux ipv4_forward 已启用

网络过滤器 iptables 或 ebtables 规则均未生效(全部接受)

以下是/etc/网络/接口

auto lo br0
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual

iface br0 inet dhcp
bridge_ports eth0 wlan0
pre-up ifconfig eth0 0.0.0.0 up
pre-up ifconfig wlan0 0.0.0.0 up
pre-up brctl addbr br0
pre-up brctl addif br0 eth0
post-down ifconfig wlan0 0.0.0.0 down
post-down ifconfig eth0 0.0.0.0 down
post-down brctl delif br0 eth0
post-down brctl delbr br0

以下是输出brctl 显示

bridge name     bridge id               STP enabled     interfaces
br0             8000.00c0ca8ffbc5       yes             eth0
                                                        wlan0

以下是 /etc/hostapd/hostapd.conf 的内容

interface=wlan0
bridge=br0

driver=nl80211
country_code=US
hw_mode=a
beacon_int=100

#NON DFS CHAN:  36, 40, 44, 48, 149, 153, 157, 161
channel=149

ieee80211n=1
ieee80211ac=1
ht_capab=[HT20][HT40]

ssid=Raspberry
wpa_passphrase=friendlyap
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP

以下是ip 路由显示

default via 192.168.1.1 dev br0
default via 192.168.1.1 dev br0  metric 204
169.254.0.0/16 dev eth0  proto kernel  scope link  src 169.254.22.129  metric 202
192.168.1.0/24 dev br0  proto kernel  scope link  src 192.168.1.106  metric 204

输出是否配置

br0       Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet addr:192.168.1.106  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:119 errors:0 dropped:0 overruns:0 frame:0
          TX packets:108 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:9298 (9.0 KiB)  TX bytes:10357 (10.1 KiB)

eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet addr:169.254.22.129  Bcast:169.254.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:119 errors:0 dropped:0 overruns:0 frame:0
          TX packets:132 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:9298 (9.0 KiB)  TX bytes:17208 (16.8 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:7569 (7.3 KiB)

其中192.168.1.1是路由器的IP。

如果我运行以下命令,我就能访问盒子的 SSH 并更新 NTP。

ifconfig wlan0 down
service hostapd stop

我怀疑路由表不正确,或者其中一个条目的度量无效。感谢您的建议!

相关内容