Raspberry Pi3 をアクセスポイントとして使う
我が家には無線LANルーターがあるのだが、iPhone SE との接続がなぜか安定しない。そこでRPi3をアクセスポイント化(AP化)して「接続がちょくちょく切れる問題」を解決したい。
想定構成
RPi3はあくまでAPとしてのみ使用し、DHCPによるアドレス配布は無線ルーターに任せる。
必要になるパッケージ
bridge-utils, hostapd
作業手順
- 必要なパッケージをインストールする
# apt-get update
# apt-get install bridge-utils hostapd - NICの設定をする(ブリッジ接続のためのインターフェイスを追加する)
ポイントとしては、bridge_ports でブリッジ設定することと、wlan0の設定をmanualにすること
$ sudo emacs /etc/network/interfaces
- RPi3を再起動して、ブリッジ接続が上手くできているか確認する
$ brctl show
bridge name に br0 が表示されていればOK - hostapdの設定をする
/usr/share/doc/hostapd/examples/hostapd.conf.gz の内容を参考に設定ファイルを作成するのだけど、コメントが多いので以下をコピペして使う。
赤字のところは自分の環境に合わせて設定する。
# This is the name of the WiFi interface we configured aboveパスフレーズは8文字以上じゃないとダメっぽいです。
interface=wlan0
# Use the nl80211 driver with the brcmfmac driver
driver=nl80211
# This is the name of the network
ssid=<your SSID name>
# Bridge Interface Name
bridge=br0
# Use the 2.4GHz band
hw_mode=g
# Use channel 6
channel=[1-14]
# Enable 802.11n
ieee80211n=1
# Enable WMM
wmm_enabled=1
# Enable 40MHz channels with 20ns guard interval
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
# Accept all MAC addresses
macaddr_acl=0
# Use WPA authentication
auth_algs=1
# Require clients to know the network name
ignore_broadcast_ssid=0 # 1にしてもステルスにならない...
# Use WPA2
wpa=2
# Use a pre-shared key
wpa_key_mgmt=WPA-PSK
# The network passphrase
wpa_passphrase=<your SSID password>
# Use AES, instead of TKIP
rsn_pairwise=CCMP - RPi3を再起動する
- hostapd の試運転を行なう
$ sudo hostapd /etc/hostapd/hostapd.conf - 問題がなければ、hostapd.conf をデーモンのデフォルトに指定する
$ sudo emacs /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf" - サービスを再起動する
$ sudo service hostapd restart