「サーバ/WiFi AP」
(目的)
超小型PC(NUC、RaspberryPi、Arduino等)をWi-Fi AccessPointとして
利用する。
数名で使う分には十分であろう。
特にRaspberryPi Zero Wの販売が開始されているので十分活用の場がある。
(用意)
hostapd、iptables-persistentを用意する。
インストール
$ sudo apt-get install hostapd
$ sudo apt-get install iptables-persistent
/etc/hostapd/hostapd.conf設定
$ sudo nano /etc/hostapd/hostapd.conf
interface=wlan0
driver=rtl871xdrv
ssid=eva999
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=999999999
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_group_rekey=86400
ieee80211n=1
wme_enabled=1
/etc/default/hostapd設定
$ sudo nano /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
ドライバー rtl871xdrv対応(RaspberryPi3、NL80211ドライバ時は不要)
$ cd ~
$ wget http://adafruit-download.s3.amazonaws.com/adafruit_hostapd_14128.zip
$ unzip adafruit_hostapd_14128.zip
$ sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.org
$ sudo mv hostapd /usr/sbin
$ sudo chmod 755 /usr/sbin/hostapd
sysctl設定
/etc/sysctl.conf
net.ipv4.ip_forward=1
ip_forward設定
$ sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
sudo mv /usr/share/dbus-1/system-services/fi.epitest.hostap.WPASupplicant.service ~/
(参考)
ラズベリーパイを使ったWiFiローカルサーバーの作り方 - Qiita
http://qiita.com/danjiro/items/28bb17ab3e2aaf79e572?utm_campaign=popular_items&utm_medium=twitter&utm_source=dlvr.it
最終更新:2017年04月09日 04:18