■debian stretchで内蔵無線LANを使えるようにする。
$ lsb_release -d
Description: Debian GNU/Linux 9.1 (stretch)
■使用したマシン
$ echo -e "system-manufacturer\nsystem-product-name" | awk '{print "sudo dmidecode -s "$1}' | sh
Acer
V5-171
■無線LAN内蔵モデルなので[lspci]、USB接続なら[lsusb]。
[AR9462]のドライバが読み込まれて入れば使用可能であることが分かる。
$ sudo lspci | awk '/Wireless/'
03:00.0 Network controller: Qualcomm Atheros AR9462 Wireless Network Adapter (rev 01)
■さらに詳細を確認する。
[ndiswrapper]行の前に[Kernel driver]が無いのでデバイスドライバが読み込まれていない。
$ sudo lspci -vvv -s 03:00.0
03:00.0 Network controller: Qualcomm Atheros AR9462 Wireless Network Adapter (rev 01)
Subsystem: Foxconn International, Inc. AR9462 Wireless Network Adapter
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 11
Region 0: Memory at c0500000 (64-bit, non-prefetchable) [size=512K]
Expansion ROM at c0580000 [disabled] [size=64K]
Capabilities: [40] Power Management version 2
Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0+,D1+,D2+,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [50] MSI: Enable- Count=1/4 Maskable+ 64bit+
Address: 0000000000000000 Data: 0000
Masking: 00000000 Pending: 00000000
Capabilities: [70] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s unlimited, L1 <64us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset- SlotPowerLimit 10.000W
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
LnkCap: Port
ClockPM- Surprise- LLActRep- BwNot- ASPMOptComp-
LnkCtl: ASPM L1 Enabled; RCB 64 bytes Disabled- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Not Supported, TimeoutDis+, LTR-, OBFF Not Supported
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [100 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-
Capabilities: [140 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed- WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=ff
Status: NegoPending- InProgress-
Capabilities: [160 v1] Device Serial Number 00-00-00-00-00-00-00-00
Kernel modules: ndiswrapper
■[ndiswrapper]はWindowsドライバをLinuxで使用する仕組み。
$ apropos ^ndiswrapper
ndiswrapper (8) - Linux kernel module and user space tool to load and run Windows XP drivers for wireless cards
$ lsmod | grep ndiswrapper
ndiswrapper 282624 0
usbcore 249856 11 uvcvideo,usbhid,usb_storage,ehci_hcd,xhci_pci,ndiswrapper,ath3k,btusb,uas,xhci_hcd,ehci_pci
■該当のドライバは[ath9k]なので、モジュールを読み込ませる。
$ apt-file search ath9k.ko | awk '{print "ls -l "$NF" >/dev/null 2>&1 && echo "$0 }' | sh
linux-image-4.9.0-3-amd64: /lib/modules/4.9.0-3-amd64/kernel/drivers/net/wireless/ath/ath9k/ath9k.ko
$ sudo modprobe ath9k
$ lsmod | awk '/ath9k/'
ath9k 94208 0
ath9k_common 32768 1 ath9k
ath9k_hw 446464 2 ath9k,ath9k_common
ath 32768 3 ath9k_hw,ath9k,ath9k_common
mac80211 671744 1 ath9k
cfg80211 589824 4 mac80211,ath9k,ath,ath9k_common
$ sudo lspci -vvv -s 03:00.0 | awk '/Kernel/'
Kernel driver in use: ath9k
Kernel modules: ndiswrapper
$ sudo dmesg | awk '/AR9462/'
[233380.798796] ieee80211 phy0: Atheros AR9462 Rev:2 mem=0xffffa99b42280000, irq=17
$ echo ath9k | sudo tee -a /etc/modules
ath9k
■ネットワークインターフェイスの認識確認
$ sudo iwconfig wlan0
wlan0 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=16 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
$ ip a show dev wlan0 | sed -e 's/[0-9a-e][0-9a-e]:/XX:/g'
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether XX:XX:XX:fa:XX:cf brd ff:ff:ff:ff:ff:ff
■ESSIDのスキャン
$ sudo iwlist wlan0 scan | awk '/ESSID/'
ESSID:"\x00\x00\x00\x00\x00\x00\x00\x00"
ESSID:"Buffalo-G-15CE"
ESSID:"Buffalo-A-15CE"
ESSID:"Buffalo-G-F7F8"
■手動でESSIDとパスワードを設定
$ sudo iwconfig wlan0 essid "myESS-ID" key "s:mypassword"
■ESSIDとパスワードを設定ファイルに書き出し
$ sudo sh -c "sudo wpa_passphrase myESS-ID mypassword" | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null
■自動起動用の記述
$ sudo awk '/wlan0|^wpa/' /etc/network/interfaces
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
■自動起動用の記述を読み込むifupスクリプトでテスト。
$ sudo ifup wlan0
$ ip a show wlan0 | sed -e 's/[0-9a-e][0-9a-e]:/XX:/g'
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether XX:XX:XX:XX:XX:4b brd ff:ff:ff:ff:ff:ff
inet 10.26.7.90/24 brd 10.26.7.255 scope global wlan0
valid_lft forever preferred_lft forever
■一旦停止し、[networking.service]でwlan0が有効になることを確認。
$ sudo ifdown wlan0
$ sudo systemctl restart networking.service
$ sudo awk '/wlan0/&&/08:33:3/' /var/log/syslog
Oct 3 08:33:35 vmx-rdebian kernel: [237261.346560] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Oct 3 08:33:35 vmx-rdebian avahi-daemon[534]: Joining mDNS multicast group on interface wlan0.IPv4 with address 10.26.7.90.
Oct 3 08:33:35 vmx-rdebian avahi-daemon[534]: New relevant interface wlan0.IPv4 for mDNS.
Oct 3 08:33:35 vmx-rdebian avahi-daemon[534]: Registering new address record for 10.26.7.90 on wlan0.IPv4.