WirelessLan - h-sendai/RaspberryPi GitHub Wiki
Wireless LAN アクセスポイントの作成
Raspberry Piにはwireless LANインターフェイスが付いている。 これを使ってアクセスポイントを作ってみる。
解説文書
- routedにする場合 https://www.raspberrypi.com/documentation/computers/configuration.html#setting-up-a-routed-wireless-access-point
- bridgedにする場合 https://www.raspberrypi.com/documentation/computers/configuration.html#setting-up-a-bridged-wireless-access-point
以下、routedにする場合を参考にパケットをフォワードしないで
- Raspberry Pi経由で外には出れないようにする
- IPアドレスはdhcpで割り振られるようにする
のメモ。
bridge接続を試したときのメモも書いておいた。
ソフトウェアインストール
dnsmasqとhostapdをインストールする:
apt install dnsmasq hostapd
wlan0の確認
raspi-configで 5. Localisation Options →L4 WLAN CountryでJP Japanを選択する。 これで
iwlist wlan0 scan
とすると周辺で利用可能なアクセスポイントリストがでてくる。
/etc/dhcpcd.confの設定
wlan0のIPアドレスを/etc/dhcpcd.confで設定する。
interface eth0
static ip_address=192.168.10.207/24
interface wlan0
static ip_address=192.168.200.1/24
nohook wpa_supplicant
eth0は有線LANの設定。dhcpでとれるならそれでよい。 nohook wpa_supplicantが必要らしい。
/etc/dnsmasqの設定
/etc/dnsmasq.conf
に以下の行を追加する:
interface=wlan0
dhcp-range=192.168.200.100,192.168.200.199,255.255.255.0,12h
192.168.200.100: IPアドレス割り振り開始アドレス
192.168.200.199: IPアドレス割り振り終了アドレス
255.255.255.0: サブネットマスク
12h: リース時間(この場合は12時間)
/etc/hostapd/hostapd.confの設定
/etc/hostapd/hostapd.conf
に以下のように書く。
ssidとwpa_passphraseは適当なものにしておく。
wpa_passphraseの長さは8〜63文字。7文字以下だと起動に
失敗する。
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
interface=wlan0
driver=nl80211
ssid=MYSSID
hw_mode=g
country_code=JP
channel=11
ieee80211d=1
wmm_enabled=0
macaddr_acl=0
auth_algs=1
wpa=2
wpa_passphrase=MY-WPA-Passphrase
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
systemctl unmask hostapd.service
systemctl enable hostapd.service
いったんリブートして有線LANの接続性を確認しておく。
続いてwireless LAN機器から接続できるかどうか確認する。
参考
Raspberry Pi 4
Raspberry Pi 4でやってみたが、そもそも
ip a
コマンドでwlan0が出なかった。
(IPアドレスをつけていなくてもip aで普通はでるし
Raspberry Pi 3ではちゃんとでた)。
wlan0が壊れているのか?