概要
- ↓にそって、
hostapd
とisc-dhcp-server
の設定- (Adafruit) Setting up a Raspberry Pi as a WiFi access point
- => 8192用の
hostapd
を用意してくれてる。(RPi3には必要ない)
- => 8192用の
-
Using your new Raspberry Pi 3 as a WiFi access point with hostapd
- => RPi3で
hostapd
とdnsmasq
のお話
- => RPi3で
- (Adafruit) Setting up a Raspberry Pi as a WiFi access point
- RPi
wlan0
のIP192.168.42.1、eth0
はdhcpで拾ってくる - 起動時、
dhcpd
がうまく開始されないので、スタートアップスクリプトに直接、待ち(sleep 7)
を入れた。
=>うまい方法をお願いします
環境
- Raspberry Pi 3
- Raspberry Pi 2 + USB WiFiドングル(RTL8188CUS) (追記)
=>hostapd
の差し替えとhostapd.conf
の書き換え その他参照 - Jessie-lite :
2016-05-27-raspbian-jessie-lite.img
手順
- Raspbianを焼く
-
いつもの
++
sudo apt-get update sudo apt-get upgrade -y sudo apt-get install -y hostapd isc-dhcp-server
-
sudo vi /etc/dhcp/dhcpd.conf
/etc/dhcp/dhcpd.conf. . #コメントアウト . #option domain-name "example.org"; #option domain-name-servers ns1.example.org, ns2.example.org; . . #コメントをはずす . . authoritative; . . #最後に追記 . . subnet 192.168.42.0 netmask 255.255.255.0 { range 192.168.42.10 192.168.42.50; option broadcast-address 192.168.42.255; option routers 192.168.42.1; default-lease-time 600; max-lease-time 7200; option domain-name "local"; option domain-name-servers 8.8.8.8, 8.8.4.4; }
-
sudo vi /etc/default/isc-dhcp-server
/etc/default/isc-dhcp-server... # wlan0記述 INTERFACES="wlan0"
-
sudo vi /etc/network/interfaces
/etc/network/intefacesiface wlan0 inet manual # wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf ... #↑ コメントアウト
-
sudo vi /etc/dhcpcd.conf
/etc/dhcpcd.conf... 最後に追記: wlan0をstatic ip (192.168.42.1)へ interface wlan0 static ip_address=192.168.42.1/24
-
sudo vi /etc/hostapd/hostapd.conf
/etc/hostapd/hostapd.conf#新規作成 interface=wlan0 driver=nl80211 #driver=rtl871xdrv ssid=Pi3-AP hw_mode=g channel=6 ieee80211n=1 wmm_enabled=1 ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40] macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_key_mgmt=WPA-PSK wpa_passphrase=raspberry rsn_pairwise=CCMP
- SSID:
ssid
=Pi3-AP
- パスワード:
wpa_passphrase
=raspberry
- SSID:
-
sudo vi /etc/default/hostapd
/etc/default/hostapd#コメントをはずして、編集 DAEMON_CONF="/etc/hostapd/hostapd.conf"
-
sudo vi /etc/sysctl.conf
/etc/sysctl.conf#コメントをはずす net.ipv4.ip_forward=1
-
iptablesの設定
#コマンドラインへこぴぺ # 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 vi /lib/dhcpcd/dhcpcd-hooks/70-ipv4-nat
/lib/dhcpcd/dhcpcd-hooks/70-ipv4-nat#新規作成 iptables-restore < /etc/iptables.ipv4.nat
sudo reboot
-
テスト
#コマンドラインへこぴぺ # sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
- Windowsとかで、
Pi3-AP
というのが現れるか確認して、CTRL-c
で、抜ける
- Windowsとかで、
-
サービス起動
#コマンドラインへこぴぺ #サービス開始 sudo service hostapd start sudo service isc-dhcp-server start # #サービス状態 #sudo service hostapd status #sudo service isc-dhcp-server status # #サービス登録. sudo update-rc.d hostapd enable sudo update-rc.d isc-dhcp-server enable # #サービス解除. #sudo update-rc.d hostapd disable #sudo update-rc.d isc-dhcp-server disable
-
sudo vi /etc/init.d/isc-dhcp-server
- (!!要確認!!) - アドバイスおねがいします
/etc/init.d/isc-dhcp-server... start) test_config log_daemon_msg "Starting $DESC" "$NAME" # sleep 7 # 起動時にこけるのでWaitをいれる. # start-stop-daemon --start --quiet --pidfile "$DHCPD_PID" \ ...
クライアントで、接続してチェック
IPは192.168.42.xx
がアサインされる
その他
-
Raspberry Pi 2
-
8188cus/8192cuなどのWifi-USBドングルの場合はそのままの
hostapd
では動かない。 -
Adafruitのとこから、。hostapd
のzipを入手して入れ替える - (NEW)
hostapd v2.5
ベースで、ビルドしました。
#コマンドラインへこぴぺ wget https://raw.githubusercontent.com/mt08xx/vgc/master/bin/hostapd_v2.5-rtl871xdrv.zip unzip hostapd_v2.5-rtl871xdrv.zip sudo mv -i /usr/sbin/hostapd /usr/sbin/hostapd.ORIG sudo mv -i hostapd /usr/sbin sudo chmod 755 /usr/sbin/hostapd
/etc/hostapd/hostapd.conf... # driver=nl80211 driver=rtl871xdrv ...
参考:hostapdバージョンpi@raspberrypi:~$ /usr/sbin/hostapd -v hostapd v2.5 for Realtek rtl871xdrv User space daemon for IEEE 802.11 AP management, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator Copyright (c) 2002-2015, Jouni Malinen <j@w1.fi> and contributors pi@raspberrypi:~$ pi@raspberrypi:~$ /usr/sbin/hostapd.ORIG -v hostapd v2.3 User space daemon for IEEE 802.11 AP management, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator Copyright (c) 2002-2014, Jouni Malinen <j@w1.fi> and contributors pi@raspberrypi:~$
-
8188cus/8192cuなどのWifi-USBドングルの場合はそのままの