RaspberryPiをアクセスポイントにする(ブリッジモード)

RaspberryPi3はWi-fi持ってるので、LANの接続をWi-fiとしてルータ化したい。

なんですが、アクセスポイントモードとブリッジモードというものがあるらしく。そもそもこの違いを知らなかったんですが、ここのページで分かりやすく違いを説明してくれていました。

超ざっくりいうと、

  • アクセスポイントモード:IPを振りなおす

  • ブリッジモード:IPは、親が振る

っていう感じでしょうか。それによってルータを挟んでアクセスできるか、できないか、がかわってくる、と。

方法は、まんまここです。

必要ソフトのインストール

bridge-utils を インストールとhostapdをインストール

apt-get install bridge-utils -y
apt-get install hostapd -y

無線LANのブリッジモード設定。AP設定の場合は、この辺りが変わってくるのか。 /etc/network/interfaces に下3行追加

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto br0
iface br0 inet dhcp
    bridge_ports eth0 wlan0

次に表示されるSSID、パスワードなどの設定 /etc/hostapd/hostapd.conf (ないので新規で作成) 内容は↓。

#新規作成
interface=wlan0
bridge=br0
driver=nl80211

ssid=Pi3-AP
country_code=JP
hw_mode=g
channel=7
auth_algs=1
ieee80211n=1

wpa=2
wpa_passphrase=raspberry
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP

上記では、SSID[Pi3-AP]、パスワード[raspberry]ですが、この辺りを任意で変更。

最後に、起動後に自動で立ち上がるように /etc/default/hostapd 10行目を以下に変更

DAEMON_CONF="/etc/hostapd/hostapd.conf"

最後に再起動して、設定したSSIDが見えれば完了


2018-03-12 hostapd.conf の内容が間違っていたので修正