Debian

無線介面只有在插入乙太網電纜時才能訪問

  • April 6, 2019

我正面臨一個即將讓我發瘋的問題。我正在執行 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

/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

您不應該為 wlan0 和 eth0 (在您的情況下192.168.178.0/24)使用相同的網路地址,這會混淆您的路由,並且很可能也會混淆網路腳本。如果兩個介面都連接到同一個網路,您應該設置一個網路綁定(Debian 文件在這裡,範例在這裡

# apt-get install ifenslave

然後在/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

引用自:https://unix.stackexchange.com/questions/153060