只有在插入以太网电缆时才能访问无线接口

pse*_*ser 5 wifi debian realtek

我正面临一个快要让我发疯的问题。我正在运行 Debian Linux 发行版,目前正在尝试与我的无线网络建立连接(WPA2 安全性,已安装 wpa_supplicant)。无线加密狗连接到网络,但它只响应 ping 并让我在插入以太网电缆时从另一台计算机通过 SSH 连接。拔下以太网连接后,它仍然可以通过无线连接访问,但它不起作用直到建立了与有线网络的连接。我不确定我的配置是否有问题...

“ifconfig wlan0”的输出:

wlan0     IEEE 802.11bgn  ESSID:"*censored*"  Nickname:"<WIFI@REALTEK>"
          Mode:Managed  Frequency:2.457 GHz  Access Point: *censored*  
          Bit Rate:72.2 Mb/s   Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:****-****-****-****-****-****-****-****   Security mode:open
          Power Management:off
          Link Quality=89/100  Signal level=58/100  Noise level=0/100
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
Run Code Online (Sandbox Code Playgroud)

/etc/network/interfaces 的内容

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet static
    address 192.168.178.130
    netmask 255.255.255.0

allow-hotplug wlan0
iface wlan0 inet static
    wpa-ssid "*censored*"
    wpa-key-mgmt WPA-PSK
    wpa-group TKIP CCMP
    wpa-psk *censored*
    address 192.168.178.131
    netmask 255.255.255.0
    gateway 192.168.178.1
Run Code Online (Sandbox Code Playgroud)

pqn*_*net 1

您不应该对 wlan0 和 eth0 使用相同的网络地址(在您的情况下192.168.178.0/24),这会混淆您的路由,并且很可能也会混淆网络脚本。如果两个接口都连接到同一网络,您应该设置网络绑定(Debian 文档在这里,示例在这里

# apt-get install ifenslave
Run Code Online (Sandbox Code Playgroud)

然后在/etc/network/interfaces

auto lo
iface lo inet loopback

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-ssid "*censored*"
    wpa-key-mgmt WPA-PSK
    wpa-group TKIP CCMP
    wpa-psk *censored*
    wpa-bridge bond0 # fixes mac address of outgoing packets so that they are consistent
    bond-master bond0
    bond-mode active-backup 
    bond-miimon 100 # checks link status every 100 msec
    bond-give-a-chance 10 # when wlan comes up wait up to 10 seconds for it to 

allow-hotplug bond0
iface bond0 inet static
    address 192.168.178.130
    netmask 255.255.255.0
    gateway 192.168.178.1
    bond-slaves eth0 # automatically brings up eth0 and slaves it to this bond
    bond-mode active-backup # uses primary if available, otherwise fallback to other
    bond-primary eth0 # priority to use eth0 when available
    bond-miimon 100
Run Code Online (Sandbox Code Playgroud)