- WiFi サーバ (アクセスポイント化) ソフト hostapd のインストール
$ sudo apt update
$ sudo apt install libssl-dev libdbus-1-dev libnl-3-dev libnl-genl-3-dev libnl-route-3-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
avrdude : Depends: libncurses5 (>= 5.5-5~) but it is not going to be installed
libssl-dev : Depends: libssl1.1 (= 1.1.1d-0+deb10u7) but 1.1.1d-0+deb10u6+rpt1 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
(インストール失敗)
"Try 'apt --fix-broken install' " に従う:
$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
libncurses5
The following NEW packages will be installed:
libncurses5
0 upgraded, 1 newly installed, 0 to remove and 211 not upgraded.
1 not fully installed or removed.
Need to get 75.3 kB of archives.
After this operation, 238 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf libncurses5 armhf 6.1+20181013-2+deb10u2 [75.3 kB]
Fetched 75.3 kB in 1s (64.6 kB/s)
Selecting previously unselected package libncurses5:armhf.
(Reading database ... 172959 files and directories currently installed.)
Preparing to unpack .../libncurses5_6.1+20181013-2+deb10u2_armhf.deb ...
Unpacking libncurses5:armhf (6.1+20181013-2+deb10u2) ...
Setting up libncurses5:armhf (6.1+20181013-2+deb10u2) ...
Setting up avrdude (1:5.10-4) ...
Processing triggers for libc-bin (2.28-10+rpi1) ...
$ sudo apt install libssl-dev libdbus-1-dev libnl-3-dev libnl-genl-3-dev libnl-route-3-dev
(インストール成功)
$ sudo apt install hostapd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
hostapd
0 upgraded, 1 newly installed, 0 to remove and 209 not upgraded.
Need to get 632 kB of archives.
After this operation, 1,729 kB of additional disk space will be used.
Get:1 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf hostapd armhf 2:2.7+git20190128+0c1e29f-6+deb10u3 [632 kB]
Fetched 632 kB in 2s (359 kB/s)
Selecting previously unselected package hostapd.
(Reading database ... 173164 files and directories currently installed.)
Preparing to unpack .../hostapd_2%3a2.7+git20190128+0c1e29f-6+deb10u3_armhf.deb ...
Unpacking hostapd (2:2.7+git20190128+0c1e29f-6+deb10u3) ...
Setting up hostapd (2:2.7+git20190128+0c1e29f-6+deb10u3) ...
Created symlink /etc/systemd/system/multi-user.target.wants/hostapd.service → /lib/systemd/system/hostapd.service.
Job for hostapd.service failed because the control process exited with error code.
See "systemctl status hostapd.service" and "journalctl -xe" for details.
Created symlink /etc/systemd/system/hostapd.service → /dev/null.
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for systemd (241-7~deb10u6+rpi1) ...
hostapd は,/usr/sbin に置かれる
- hostapd の設定ファイル /etc/hostapd/hostapd.conf を作成
$ cd /etc/hostapd
$ sudo vi hostapd.conf
interface=wlan0
country_code=JP
driver=nl80211
hw_mode=g
ieee80211d=1
channel=6
auth_algs=1
ignore_broadcast_ssid=0
disassoc_low_ack=1
ieee80211n=1
ht_capab=[HT40] [SHORT-GI-20] [DSSS_CCK-40]
require_ht=0
rsn_pairwise=CCMP
max_num_sta=3
ssid=raspi
wpa_passphrase=12345678
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_group_rekey=86400
ssid, wpa_passphrase は任意。
但し,wpa_passphrase には「不適切」がある。
つぎは,6文字の passphrase を設定したときの,hostapd 起動エラーメッセージ:
Configuration file: /etc/hostapd/hostapd.conf
Line 16: invalid WPA passphrase length 6 (expected 8..63)
WPA-PSK enabled, but PSK or passphrase is not configured.
2 errors found in configuration file '/etc/hostapd/hostapd.conf'
Failed to set up interface with /etc/hostapd/hostapd.conf
Failed to initialize interface
- WiFi クライアント用の wpa_supplicant を無効にする
$ cd /etc/wpa_supplicant
$ sudo mv wpa_supplicant.conf wpa_supplicant.conf_org
$ sudo systemctl disable wpa_supplicant
Removed /etc/systemd/system/dbus-fi.w1.wpa_supplicant1.service.
Removed /etc/systemd/system/multi-user.target.wants/wpa_supplicant.service.
$ sudo reboot
wpa_supplicant が無くなっていることを確認:
$ ps aux | grep wpa
- wlan0 に固定IPアドレスを設定する
( /etc/network/interfaces.d/wlan0 を作成する)
$ cd /etc/network/interfaces.d
$ sudo vi wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 10.10.10.1
netmask 255.255.255.0
- hostapd の起動テスト
$ sudo hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
rfkill: WLAN soft blocked
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
wlan0: INTERFACE-DISABLED
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr b8:27:eb:1c:15:60 and ssid "raspi"
Failed to set beacon parameters
wlan0: Could not connect to kernel driver
Interface initialization failed
wlan0: interface state COUNTRY_UPDATE->DISABLED
wlan0: AP-DISABLED
wlan0: interface state DISABLED->DISABLED
wlan0: AP-DISABLED
wlan0: CTRL-EVENT-TERMINATING
hostapd_free_hapd_data: Interface wlan0 wasn't started
nl80211: deinit ifname=wlan0 disabled_11b_rates=0
("rfkill: WLAN soft blocked" による起動失敗らしい)
$ rfkill list
0: phy0: Wireless LAN
Soft blocked: yes
Hard blocked: no
$ sudo rfkill unblock wifi
$ rfkill list
0: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
$ sudo hostapd /etc/hostapd/hostapd.conf
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr b8:27:eb:1c:15:60 and ssid "raspi"
wlan0: interface state COUNTRY_UPDATE->ENABLED
wlan0: AP-ENABLED
(起動成功)
- WiFi で IP通信するときの Raspberry Pi の IPアドレスを設定する
── /etc/dhcpcd.conf の編集
PC からターミナルの新規ウィンドウで,ssh 接続
$ cd /etc
$ sudo cp dhcpcd.conf dhcpcd.conf_org
$ sudo vi dhcpcd.conf
‥‥‥
interface wlan0
static ip_address=10.10.10.1
$ sudo cp dhcpcd.conf dhcpcd.conf_p2p_wifi
- 再起動 ( /etc/dhcpcd.conf の設定を有効にする)
- hostapd を起動
$ sudo hostapd /etc/hostapd/hostapd.conf
|