■Debian bookwormで無線LANを使用する
$ lsb_release -d
No LSB modules are available.
Description: Debian GNU/Linux 12 (bookworm)
■対象のURLのディレクトリ構造に合わせて、sources.listに不足分を追加する
$ w3m -dump http://deb.debian.org/debian/dists/bookworm/
Index of /debian/dists/bookworm
[ICO] Name Last modified Size
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[PARENTDIR] Parent Directory -
[ ] ChangeLog 2023-10-07 08:45 1.4M
[ ] InRelease 2023-10-07 09:49 147K
[ ] Release 2023-10-07 09:30 146K
[ ] Release.gpg 2023-10-07 09:49 1.7K
[DIR] contrib/ 2023-10-07 09:30 -
[DIR] main/ 2023-10-07 09:30 -
[DIR] non-free-firmware/ 2023-10-07 09:30 -
[DIR] non-free/ 2023-10-07 09:30 -
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Apache Server at ftp.debian.org Port 80
$ grep non-free /etc/apt/sources.list
deb http://deb.debian.org/debian/ bookworm main non-free-firmware contrib non-free
deb-src http://deb.debian.org/debian/ bookworm main non-free-firmware contrib non-free
deb http://security.debian.org/debian-security bookworm-security main non-free-firmware contrib non-free
deb-src http://security.debian.org/debian-security bookworm-security main non-free-firmware contrib non-free
deb http://deb.debian.org/debian/ bookworm-updates main non-free-firmware contrib non-free
deb-src http://deb.debian.org/debian/ bookworm-updates main non-free-firmware contrib non-free
$ sudo apt-get update
$ sudo apt-get install -y firmware-iwlwifi
■物理NICしか認識していない
$ ls /sys/class/net/
br0 enp2s0 lo
■lspciによる認識はRealtek社の物理NICと無線LAN NICの両方がある
$ lspci | grep -i "network\|ethernet"
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)
03:00.0 Network controller: Realtek Semiconductor Co., Ltd. Device b852
■lspciによると、b852デバイスは[disabled]
$ sudo lspci -v | grep -A 10 "Device b852" | sed -e "s/-[0-9a-f][0-9a-f]/-XX/g"
[sudo] labunix のパスワード:
03:00.0 Network controller: Realtek Semiconductor Co., Ltd. Device b852
Subsystem: Realtek Semiconductor Co., Ltd. Device b852
Flags: fast devsel, IRQ 255, IOMMU group 11
I/O ports at e000 [disabled] [size=256]
Memory at fcd00000 (64-bit, non-prefetchable) [disabled] [size=1M]
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
Capabilities: [70] Express Endpoint, MSI 00
Capabilities: [100] Advanced Error Reporting
Capabilities: [148] Device Serial Number 00-XX-XX-XX-XX-XX-XX-XX
Capabilities: [158] Latency Tolerance Reporting
Capabilities: [160] L1 PM Substates
■デバイスが無効なので以下の結果は何もない
$ /sbin/iw list
■国の指定も無いようだ
$ /sbin/iw reg get
global
country 00: DFS-UNSET
(755 - 928 @ 2), (N/A, 20), (N/A), PASSIVE-SCAN
(2402 - 2472 @ 40), (N/A, 20), (N/A)
(2457 - 2482 @ 20), (N/A, 20), (N/A), AUTO-BW, PASSIVE-SCAN
(2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFDM, PASSIVE-SCAN
(5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW, PASSIVE-SCAN
(5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW, PASSIVE-SCAN
(5490 - 5730 @ 160), (N/A, 20), (0 ms), DFS, PASSIVE-SCAN
(5735 - 5835 @ 80), (N/A, 20), (N/A), PASSIVE-SCAN
(57240 - 63720 @ 2160), (N/A, 0), (N/A)
■物理NICと見比べると、致命的に足りないのは、電源管理(Power Management)とKernelドライバとその読み込みモジュールのようだ
$ sdiff -l -w 180 {p,w}nic
$ sudo lspci -v | grep -A 15 "Ether" | sed -e "s/-[0-9a-f][0-9a-f]/-XX/g" | $ sudo lspci -v | grep -A 10 "Device b852" | sed -e "s/-[0-9a-f][0-9a-f]/-XX/g"
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Ex | 03:00.0 Network controller: Realtek Semiconductor Co., Ltd. Device b852
Subsystem: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Giga | Subsystem: Realtek Semiconductor Co., Ltd. Device b852
Flags: bus master, fast devsel, latency 0, IRQ 30, IOMMU group 10 | Flags: fast devsel, IRQ 255, IOMMU group 11
I/O ports at f000 [size=256] | I/O ports at e000 [disabled] [size=256]
Memory at fce00000 (64-bit, non-prefetchable) [size=4K] | Memory at fcd00000 (64-bit, non-prefetchable) [disabled] [size=1M]
Memory at e0300000 (64-bit, prefetchable) [size=16K] <
Capabilities: [40] Power Management version 3 (
Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+ (
Capabilities: [70] Express Endpoint, MSI 01 | Capabilities: [70] Express Endpoint, MSI 00
Capabilities: [b0] MSI-X: Enable+ Count=4 Masked- <
Capabilities: [d0] Vital Product Data <
Capabilities: [100] Advanced Error Reporting (
Capabilities: [140] Virtual Channel | Capabilities: [148] Device Serial Number 00-XX-XX-XX-XX-XX-XX-XX
Capabilities: [160] Device Serial Number 01-XX-XX-XX-XX-XX-XX-XX | Capabilities: [158] Latency Tolerance Reporting
Capabilities: [170] Latency Tolerance Reporting | Capabilities: [160] L1 PM Substates
Kernel driver in use: r8169 <
Kernel modules: r8169 <
(
■現状のモジュール認識として、bluetoothと80211でフィルタする
「80211」は、IEEE802.11という無線LAN関連規格のこと
$ lsmod | grep -i "bluetooth"
bluetooth 958464 6 btrtl,btmtk,btintel,btbcm,btusb
ecdh_generic 16384 1 bluetooth
rfkill 36864 4 bluetooth,cfg80211
crc16 16384 2 bluetooth,ext4
$ lsmod | grep -i 80211
cfg80211 1134592 0
rfkill 36864 4 bluetooth,cfg80211
$ /usr/sbin/modinfo cfg80211 | grep -i regdom
parm: ieee80211_regdom:IEEE 802.11 regulatory domain code (charp)
■CRDAパッケージは存在しない
$ apt policy crda
N: パッケージ crda が見つかりません
$ env LANG=en apt policy crda
N: Unable to locate package crda
■CRDAは直接kernelがサポートしている
$ dpkg -l | awk '$1 ~ /ii/ && $0 ~ /linux-headers/'
ii linux-headers-6.1.0-13-amd64 6.1.55-1 amd64 Header files for Linux 6.1.0-13-amd64
ii linux-headers-6.1.0-13-common 6.1.55-1 all Common header files for Linux 6.1.0-13
$ apt-cache search linux-headers-$(uname -r);apt-cache show linux-headers-$(uname -r) | grep ^Depends
linux-headers-6.1.0-13-amd64 - Header files for Linux 6.1.0-13-amd64
Depends: linux-headers-6.1.0-13-common (= 6.1.55-1), linux-kbuild-6.1 (>= 6.1.55-1), linux-compiler-gcc-12-x86
$ grep CRDA_SUPPORT $(find /usr/src/ -type f)
/usr/src/linux-headers-6.1.0-13-amd64/include/generated/autoconf.h:
/usr/src/linux-headers-6.1.0-13-amd64/include/generated/rustc_cfg:--cfg=CONFIG_CFG80211_CRDA_SUPPORT
/usr/src/linux-headers-6.1.0-13-amd64/include/generated/rustc_cfg:--cfg=CONFIG_CFG80211_CRDA_SUPPORT="y"
/usr/src/linux-headers-6.1.0-13-amd64/include/config/auto.conf:CONFIG_CFG80211_CRDA_SUPPORT=y
/usr/src/linux-headers-6.1.0-13-amd64/.config:CONFIG_CFG80211_CRDA_SUPPORT=y
■CRDAは、無線 Central Regulatory Domain Agent の頭文字
「wireless-regdb」が不要になったことを意味する
$ apt-cache search wireless-regdb
wireless-regdb - Linux 向け無線規制データベース
$ apt-cache show wireless-regdb | grep -A 3 Description-ja
Description-ja: Linux 向け無線規制データベース
このパッケージは、無線ネットワークの利用に影響を及ぼす電波発射の法的規制の
機械可読なデータベースを提供します。
Linux カーネルおよびドライバはこれを使ってこれら規制に遵守するよう保ちます。
■以下を参考に、既定では無効化されていいるチャンネルを有効化する
無線LAN問題の調査方法
https://ja.opensuse.org/%E7%84%A1%E7%B7%9ALAN%E5%95%8F%E9%A1%8C%E3%81%AE%E8%AA%BF%E6%9F%BB%E6%96%B9%E6%B3%95
> これらのチャンネルは規制領域を上書きすることで利用できるようになります
> (規制領域としては US (アメリカ), EU (ヨーロッパ), JP (日本) のいずれかを指定します):
$ echo "options cfg80211 ieee80211_regdom=JP" | sudo tee /etc/modprobe.d/cfg80211
options cfg80211 ieee80211_regdom=JP
■無線 LAN モジュールを再ロード
$ sudo modprobe -r cfg80211;sudo modprobe cfg80211
■状況は変わっていない
$ /sbin/iw list
$ /sbin/iw reg get
global
country 00: DFS-UNSET
(755 - 928 @ 2), (N/A, 20), (N/A), PASSIVE-SCAN
(2402 - 2472 @ 40), (N/A, 20), (N/A)
(2457 - 2482 @ 20), (N/A, 20), (N/A), AUTO-BW, PASSIVE-SCAN
(2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFDM, PASSIVE-SCAN
(5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW, PASSIVE-SCAN
(5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW, PASSIVE-SCAN
(5490 - 5730 @ 160), (N/A, 20), (0 ms), DFS, PASSIVE-SCAN
(5735 - 5835 @ 80), (N/A, 20), (N/A), PASSIVE-SCAN
(57240 - 63720 @ 2160), (N/A, 0), (N/A)
$ sudo lspci -v | grep -A 10 "Device b852" | sed -e "s/-[0-9a-f][0-9a-f]/-XX/g" | grep disable
I/O ports at e000 [disabled] [size=256]
Memory at fcd00000 (64-bit, non-prefetchable) [disabled] [size=1M]
■iwコマンドのソースを見ても想定通り、ヘッダで定義されてregとscanのサブコマンドで使用される内容
$ sudo apt-get install -y apt-file
$ sudo apt-file update
$ apt-file search sbin/iw | grep "iw\$"
iw: /sbin/iw
$ awk '/country/{print FILENAME | "sort -uV"}' $(find debian/ iw-5.19/ -type f )
iw-5.19/nl80211.h
iw-5.19/reg.c
iw-5.19/scan.c
■HWを誤認識してないのでlogical nameが無い
$ sudo apt-get install -y lshw
$ lshw -C network
$ sdiff -l -w 180 {p,w}net | sed -e "s/:[0-9a-f][0-9a-f]/:XX/g"
*-network | *-network UNCLAIMED
description: Ethernet interface | description: Network controller
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller | product: Realtek Semiconductor Co., Ltd.
vendor: Realtek Semiconductor Co., Ltd. (
physical id: 0 (
bus info: pci@0000:XX:XX.0 | bus info: pci@0000:XX:XX.0
logical name: enp2s0 | version: 00
version: 0c <
serial: 00:XX:XX:XX:XX:XX <
size: 1Gbit/s <
capacity: 1Gbit/s <
width: 64 bits (
clock: 33MHz (
capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical | capabilities: pm msi pciexpress cap_list
configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=6.1 | configuration: latency=0
resources: irq:XX ioport:XX00(size=256) memory:XXe00000-fce00fff memory:XX3000 | resources: ioport:XX00(size=256) memory:XXd00000-fcdfffff
(
■b852を正しく認識するkernel driverが必要なようだ
I/O ports at e000 [disabled]を有効にするための国指定の前に、
driverとmoduleが認識していないので、XXXXを見つける必要がある。
Kernel driver in use: XXXX
Kernel modules: XXXX
■ドライバはrtl8852beをたどると、モジュールと紐付いた
https://github.com/HRex39/rtl8852be
https://github.com/lwfinger/rtw89
$ sudo apt-get install make gcc linux-headers-$(uname -r) build-essential git
$ git clone https://github.com/lwfinger/rtw89.git;cd rtw89;make
...
$ sudo make install
make -C /lib/modules/6.1.0-13-amd64/build M=/home/labunix/rtw89 modules
make[1]: ディレクトリ '/usr/src/linux-headers-6.1.0-13-amd64' に入ります
make[1]: ディレクトリ '/usr/src/linux-headers-6.1.0-13-amd64' から出ます
Install rtw89 SUCCESS
$ sudo modprobe -v rtw_8852ae
insmod /lib/modules/6.1.0-13-amd64/kernel/lib/crypto/libarc4.ko
insmod /lib/modules/6.1.0-13-amd64/kernel/net/mac80211/mac80211.ko
insmod /lib/modules/6.1.0-13-amd64/kernel/drivers/net/wireless/realtek/rtw89/rtw89core.ko
insmod /lib/modules/6.1.0-13-amd64/kernel/drivers/net/wireless/realtek/rtw89/rtw89pci.ko
insmod /lib/modules/6.1.0-13-amd64/kernel/drivers/net/wireless/realtek/rtw89/rtw_8852a.ko
insmod /lib/modules/6.1.0-13-amd64/kernel/drivers/net/wireless/realtek/rtw89/rtw_8852ae.ko
$ lsmod | grep mac80211
mac80211 1175552 2 rtw89pci,rtw89core
libarc4 16384 1 mac80211
cfg80211 1134592 3 rtw_8852a,rtw89core,mac80211
$ lspci -v | grep ^03 -A 7
03:00.0 Network controller: Realtek Semiconductor Co., Ltd. Device b852
Subsystem: Realtek Semiconductor Co., Ltd. Device b852
Flags: fast devsel, IRQ 255, IOMMU group 11
I/O ports at e000 [disabled] [size=256]
Memory at fcd00000 (64-bit, non-prefetchable) [disabled] [size=1M]
Capabilities: <access denied>
Kernel modules: rtw_8852be
■kernelへの組み込みもあったので、システムを再起動する
$ sudo shutdown -r now && exit
■[wlp3s0]として認識したようだ
$ lshw -C network | sed -e "s/:[0-9a-f][0-9a-f]/:XX/g"
...
*-network
description: Wireless interface
product: Realtek Semiconductor Co., Ltd.
vendor: Realtek Semiconductor Co., Ltd.
physical id: 0
bus info: pci@0000:XX:XX.0
logical name: wlp3s0
version: 00
serial: 6e:XX:XX:XX:XX:XX
width: 64 bits
clock: 33MHz
capabilities: bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=rtw89_8852be driverversion=6.1.0-13-amd64 firmware=N/A latency=0 link=no multicast=yes wireless=IEEE 802.11
resources: irq:XX ioport:XX00(size=256) memory:XXd00000-fcdfffff
■使われているモジュールは[rtw89_8852be]
$ sudo lspci -v | grep -A 13 "Net" | sed -e "s/-[0-9a-f][0-9a-f]/-XX/g"
03:00.0 Network controller: Realtek Semiconductor Co., Ltd. Device b852
Subsystem: Realtek Semiconductor Co., Ltd. Device b852
Flags: bus master, fast devsel, latency 0, IRQ 73, IOMMU group 11
I/O ports at e000 [size=256]
Memory at fcd00000 (64-bit, non-prefetchable) [size=1M]
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
Capabilities: [70] Express Endpoint, MSI 00
Capabilities: [100] Advanced Error Reporting
Capabilities: [148] Device Serial Number 00-XX-XX-XX-XX-XX-XX-XX
Capabilities: [158] Latency Tolerance Reporting
Capabilities: [160] L1 PM Substates
Kernel driver in use: rtw89_8852be
Kernel modules: rtw_8852be
■無線デバイスも認識した
$ ls /sys/class/net/
br0 enp2s0 lo wlp3s0
$ sudo ip link show dev wlp3s0 | sed -e "s/:[0-9a-f][0-9a-f]/:XX/g"
3: wlp3s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DORMANT group default qlen 1000
link/ether 92:XX:XX:XX:XX:XX brd ff:XX:XX:XX:XX:XX permaddr a8:XX:XX:XX:XX:XX
$ sudo iw list | wc -l
506
$ sudo iw wlp3s0 info | sed -e "s/:[0-9a-f][0-9a-f]/:XX/g"
Interface wlp3s0
ifindex 3
wdev 0x1
addr 72:XX:XX:XX:XX:XX
type managed
wiphy 0
txpower 20.00 dBm
multicast TXQ:
qsz-byt qsz-pkt flows drops marks overlmt hashcol tx-bytes tx-packets
0 0 0 0 0 0 0 0 0
■ここでの国指定は意味なかった?
$ /sbin/iw reg get
global
country 00: DFS-UNSET
(755 - 928 @ 2), (N/A, 20), (N/A), PASSIVE-SCAN
(2402 - 2472 @ 40), (N/A, 20), (N/A)
(2457 - 2482 @ 20), (N/A, 20), (N/A), AUTO-BW, PASSIVE-SCAN
(2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFDM, PASSIVE-SCAN
(5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW, PASSIVE-SCAN
(5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW, PASSIVE-SCAN
(5490 - 5730 @ 160), (N/A, 20), (0 ms), DFS, PASSIVE-SCAN
(5735 - 5835 @ 80), (N/A, 20), (N/A), PASSIVE-SCAN
(57240 - 63720 @ 2160), (N/A, 0), (N/A)
■JPで絞って検索
https://github.com/labunix/lsec/blob/master/lsec
$ sudo iw dev wlp3s0 scan | egrep '^BSS |(signal|last seen|freq|SSID|DS Parameter set|primary channel|Country|Manufacturer|Model|Serial|(Group|Pairwise) ciphers?|Authentication):' | \
myscripts/lsec JP | sed -e "s/:[0-9a-f][0-9a-f]/:XX/g"
BSS 30:XX:XX:XX:XX:XX(on wlp3s0)
freq: 5240
signal: -63.00 dBm
last seen: 2400 ms ago
SSID: 307F10BEB433-5G
DS Parameter set: channel 48
Country: JP Environment: Indoor/Outdoor
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* primary channel: 48
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Manufacturer: OPPO
* Model: WAP
BSS 68:XX:XX:XX:XX:XX(on wlp3s0)
freq: 2462
signal: -71.00 dBm
last seen: 3056 ms ago
SSID: 6885A4027B5F-2G
DS Parameter set: channel 11
Country: JP Environment: Indoor/Outdoor
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* primary channel: 11
* Group cipher: CCMP
* Pairwise ciphers: CCMP
BSS 0c:XX:XX:XX:XX:XX(on wlp3s0)
freq: 5180
signal: -75.00 dBm
last seen: 2640 ms ago
SSID: L01_0C8FFFC5C40F_5G
Country: JP Environment: Indoor/Outdoor
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* primary channel: 36
* Manufacturer: Huawei
* Model: Huawei
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
BSS 00:XX:XX:XX:XX:XX(on wlp3s0)
freq: 2412
signal: -88.00 dBm
last seen: 7724 ms ago
SSID: RTS300NE-596475-1
DS Parameter set: channel 1
Country: JP Environment: Indoor/Outdoor
* Group cipher: CCMP
* Pairwise ciphers: CCMP
BSS 30:XX:XX:XX:XX:XX(on wlp3s0)
freq: 2412
signal: -50.00 dBm
last seen: 3676 ms ago
SSID: 307F10BEB433-2G
DS Parameter set: channel 1
Country: JP Environment: Indoor/Outdoor
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* primary channel: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Manufacturer: OPPO
* Model: WAP
■iwconfigで無線LANの設定を行う
$ sudo apt-get install -y wireless-tools
$ wpa_passphrase $ssid $pass | awk -F= '{if($1 ~ /ssid/){gsub(".*","[ssid]",$2)}{if($1 ~ /psk/){gsub(".*","[psk]",$2)}}}{print}'
network={
ssid [ssid]
psk [psk]
}
$ cat /etc/network/interfaces.d/wlp3s0 | awk '{if($1 ~ /wpa-ssid/){gsub(".*","[ssid]",$2)}{if($1 ~ /wpa-psk/){gsub(".*","[psk]",$2)}}}{print}'
auto wlp3s0
iface wlp3s0 inet dhcp
wpa-ssid [ssid]
wpa-psk [psk]
■ネットワークの再起動のやり方変わった?システムの再起動で代用
つながった。無線LANしか無いマシンにインストールする際はUSB-LANの変換アダプタでも付けて設定するのが吉。
$ sudo shutdown -r now && exit
$ ip a show wlp3s0 | sed -e "s/:[0-9a-f][0-9a-f]/:XX/g" | sed -e 's/[0-9]*\.[0-9]*\.[0-9]*\.\([0-9]*\)/X.X.X.\1/g'
3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether a8:XX:XX:XX:XX:XX brd ff:XX:XX:XX:XX:XX
inet X.X.X.148/24 brd X.X.X.255 scope global dynamic wlp3s0
valid_lft 6876sec preferred_lft 6876sec
inet6 fe80::XX43:XXff:XX61:XX60/64 scope link
valid_lft forever preferred_lft forever