Wifi

在 FreeBSD 上配置無線網路:路由器顯示無線設備已連接,但無法 ping

  • August 24, 2017

我的問題與此類似。

我在 FreeBSD 10.3-STABLE 上配置我的 Broadcom BCM4311 802.11b/g 設備,如下所示:

sudo kldload if_bwn 
sudo kldload bwn_v4_ucode 
sudo kldload bwn_v4_lp_ucode 
#
# Now, interface `bwn0` is available
#
sudo ifconfig wlan0 create wlandev bwn0 
sudo ifconfig wlan0 up # at this moment, laptop WiFi LED light turns on
sudo ifconfig wlan0 scan # I can see my wireless router SSID
sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf 
sudo ifconfig wlan0 list sta 
sudo dhclient wlan0 
#
# Optionally, rather than dhclient run:
#
sudo ifconfig wlan0 inet 192.168.1.103 netmask 0xffffff00

ifconfig顯示關聯的無線網路狀態:

$ ifconfig
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
   options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE>
   ether 00:15:c5:ad:63:9c
   inet 192.168.1.101 netmask 0xffffff00 broadcast 192.168.1.255 
   nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
   media: Ethernet autoselect (100baseTX <full-duplex>)
   status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
   options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
   inet6 ::1 prefixlen 128 
   inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 
   inet 127.0.0.1 netmask 0xff000000 
   nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
bwn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
   ether 00:18:f3:38:a0:36
   nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
   media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
   status: associated
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
   ether 00:18:f3:38:a0:36
   inet 192.168.1.103 netmask 0xffffff00 broadcast 192.168.1.255 
   nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
   media: IEEE 802.11 Wireless Ethernet OFDM/48Mbps mode 11g
   status: associated
   ssid Mine channel 11 (2462 MHz 11g) bssid e8:de:27:6b:3e:67
   country US authmode WPA2/802.11i privacy ON deftxkey UNDEF
   TKIP 2:128-bit txpower 30 bmiss 7 scanvalid 60 bgscan bgscanintvl 300
   bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS wme roaming MANUAL
$ 

我通過以下方法斷開筆記型電腦乙太網電纜以檢查與路由器的無線連接:

無線路由器顯示我的筆記型電腦列在“目前連接的無線客戶端”中:

ID  MAC
1   00:18:F3:38:A0:36

無線路由器有一個診斷 ping 工具,我可以通過它 ping 到我的筆記型電腦,當我這樣做時,timed out會收到消息:

IP Address/Domain Name: 192.168.1.103

Request timed out

從我的筆記型電腦我ping到路由器:

$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
ping: sendto: No route to host
ping: sendto: No route to host
ping: sendto: No route to host
ping: sendto: No route to host
ping: sendto: No route to host
^C
--- 192.168.1.1 ping statistics ---
5 packets transmitted, 0 packets received, 100.0% packet loss
$ 

arp -an輸出:

$ arp -an
? (192.168.1.103) at 00:18:f3:38:a0:36 on wlan0 permanent [ethernet]
? (192.168.1.1) at e8:de:27:6b:3e:67 on bge0 expires in 803 seconds [ethernet]
? (192.168.1.101) at 00:15:c5:ad:63:9c on bge0 permanent [ethernet]
$ 

netstat -r輸出:

$ netstat -r
Routing tables

Internet:
Destination        Gateway            Flags      Netif Expire
default            192.168.1.1        UGS        bge0
localhost          link#2             UH          lo0
192.168.1.0        link#4             U         wlan0
192.168.1.101      link#1             UHS         lo0
192.168.1.103      link#4             UHS         lo0

Internet6:
Destination        Gateway            Flags      Netif Expire
::                 localhost          UGRS        lo0
localhost          link#2             UH          lo0
::ffff:0.0.0.0     localhost          UGRS        lo0
fe80::             localhost          UGRS        lo0
fe80::%lo0         link#2             U           lo0
fe80::1%lo0        link#2             UHS         lo0
ff01::%lo0         localhost          U           lo0
ff02::             localhost          UGRS        lo0
ff02::%lo0         localhost          U           lo0
$ 

dmesg從創建wlan0介面到dhclient命令的輸出:

wlan0: Ethernet address: 00:18:f3:38:a0:36
bwn0: firmware version (rev 410 patch 2160 date 0x751a time 0x7c0a)
wlan0: ieee80211_new_state_locked: pending INIT -> SCAN transition lost
bwn0: status of RF switch is changed to OFF
bwn0: please turn on the RF switch
bwn0: firmware version (rev 410 patch 2160 date 0x751a time 0x7c0a)
bwn0: status of RF switch is changed to OFF
bwn0: please turn on the RF switch
wlan0: link state changed to UP
bwn0: need multicast update callback
bwn0: need multicast update callback
bwn0: need multicast update callback

配置文件

我不使用/etc/rc.conf,我手動完成所有操作。我使用以下wpa_supplicant配置:

$ cat /etc/wpa_supplicant.conf 
network={
   ssid="Mine"
   psk=79a174594e2ec3563ff4c35c1a82a006b19df646fa020aaf53078d34d09ed962
}
$

我想知道是否有人可以伸出援助之手。


更新:

現在,我/etc/rc.conf這樣使用:

#
# Kernel modules to load after local disks are mounted
#
kld_list="linux nvidia if_bwn bwn_v4_ucode bwn_v4_lp_ucode fuse"
#
# DELL LATITUDE | D820
#
hostname="D820"
#
# $ sudo ifconfig wlan0 create wlandev bwn0
#
wlans_bwn0="wlan0"
#
# $ sudo ifconfig wlan0 up
# $ sudo ifconfig wlan0 scan
# $ sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
# $ sudo dhclient wlan0
#
wpa_supplicant_conf_file="/etc/wpa_supplicant.conf"
ifconfig_wlan0="WPA DHCP"
#
# gnome3-lite desktop environment services
#
#dbus_enable="YES"
#hald_enable="YES"
#gdm_enable="YES" # GDM will start automatically when the system boots
#gnome_enable="YES"
#linux_enable="YES"
##
## To enable the tor server
##
#tor_enable="YES"
##
## web proxy of choice
##
#polipo_enable="YES"
#privoxy_enable="YES"
##
##For Linux compatibility to be enabled at boot time
##
linux_enable="YES"

當您啟動筆記型電腦並通過 配置有線bge0介面時dhclient,它成為預設路由(如 輸出中最右邊的列所示netstat -r)。當您稍後配置無線bwn0介面並斷開有線介面時,它並未設置為預設路由。當您嘗試訪問網路(或回復請求)時,流量正在嘗試使用bge0但已斷開連接。

重新啟動您的筆記型電腦,您只需配置無線介面就不會出現此問題。

如果你將來想從有線轉向無線,我相信你可以做到以下幾點:

route change default -iface wlan0
route change default 192.168.1.1

這會將預設路由介面設置為無線介面,這會重置路由器地址,因此我們在第二行重新添加它。

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