Raspberry pi をアクセスポイントに
最近の寒さはなんなんだ 体調くずれまくりである。。
で、Raspberry pi をアクセスポイントにしようという話
Wifiドングルはこいつを使用
BUFFALO 11n対応 11g/b 無線LAN子機 親機-子機デュアルモード対応モデル WLI-UC-GNM2
- 出版社/メーカー: バッファロー
- 発売日: 2011/07/30
- メディア: Personal Computers
- 購入: 198人 クリック: 5,602回
- この商品を含むブログを見る
hostapd インストール
$ sudo apt-get install -y hostapd
hostapd.conf の編集
hostapd.conf を examples から展開
$ zcat /usr/share/doc/hostapd/examples/hostapd.conf.gz | sudo tee -a /etc/hostapd/hostapd.conf
で /etc/hostapd/hostapd.conf を確認して、下記の値が違ってたら修正
interface=wlan0 ssid=my-raspberry hw_mode=g wpa=2 wpa_passphrase=PASS wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256
/etc/network/interfaces を編集
wlan0 のネットワークを static で設定しなおし
(修正前) : allow-hotplug wlan0 iface wlan0 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf : (修正後) : auto wlan0 iface wlan0 inet static hostapd /etc/hostapd/hostapd.conf address 192.168.64.1 netmask 255.255.255.0 :
DNSMASQ インストール
DHCPサーバは、今回 dnsmasq を使うことにした
$ sudo apt-get install -y dnsmasq
/etc/dnsmasq.conf の編集
下記の値を修正する
interface=lo,wlan0 no-dhcp-interface=lo dhcp-range=192.168.64.20,192.168.64.254,255.255.255.0,12h
IP Foward 設定
/etc/sysctl.conf で 以下をアンコメント
net.ipv4.ip_forward=1
/etc/rc.local に以下の行を追加して起動時に iptable 設定する
iptables -t nat -A POSTROUTING -s 192.168.64.0/24 ! -d 192.168.64.0/24 -j MASQUERADE
で Raspberry pi リブート後、wlan0 がアクセスポイントとして立ち上がってたら OKAY
pi@raspberrypi:~ $ iw wlan0 info Interface wlan0 ifindex 3 ssid my-raspberry type AP wiphy 0