Raspberry Piã¨ã¹ãã¼ããã©ã³ãWiFiã§ç´æ¥æ¥ç¶ããã
ãRaspberry Piã¨ã¹ãã¼ããã©ã³(iPhone/Android)ãç´æ¥WiFiã§æ¥ç¶ãããã¨ãã£ã¦ããã¾ãããï¼ãããªå ´åãä»ã¾ã§ã¯
Raspberry Pi - (WiFi) - ç¡ç·LANã«ã¼ã¿ - (WiFi) - ã¹ãã¼ããã©ã³
ãã¨ãã£ãæãã«éã«ç¡ç·LANã«ã¼ã¿ããã¾ãã¦ãã¾ãããããããã¨ç¡ç·LANã«ã¼ã¿ãã¤ã³ã¿ã¼ãããã«ç¹ãã¨Raspberry Piãã¹ãã¼ããã©ã³ãWiFiçµç±ã§ã¤ã³ã¿ã¼ãããã«æ¥ç¶ã§ããã®ã§ä¾¿å©ã§ãããã ãå½ç¶ç¡ç·LANã«ã¼ã¿ãå¿ è¦ã¨ãªãã¾ããã¨ãã«ã¯ã¤ã³ã¿ã¼ãããã«ç¹ããªãã¦ããã®ã§ãã«ã¼ã¿ãªãã§ç´æ¥WiFiçµç±ã§Raspberry Piã¨ã¹ãã¼ããã©ã³ãæ¥ç¶ãããã¨ãããã¾ããããä¾ãã°ã以ä¸ã®ããã«WiFiã§Raspberry Piã¨ã¹ãã¼ããã©ã³ããã¤ã¬ã¯ãã«ç¹ããããªæ§æã§ãã
Raspberry Pi - (WiFi) - ã¹ãã¼ããã©ã³
ãè²ã
ãªãµã¤ããè¦ãã¨ãRaspberry Piãã«ã¼ã¿åãã¦ããä¾ã¯è¦ã¤ããã®ã§ãããæå¤ã«ä¸è¨ã®ãããªãã¼ã«ã«ã§WiFiã§ã¢ãããã¯æ¥ç¶ããä¾ãå°ãªãããããã®æ
å ±éãã«ãã£ã¦ããå°ãæ
å ±ãå¤ãã£ãããç°å¢ãéã£ããã§ãã®ã¾ã¾ã§ã¯ã§ããªãã£ããããã®ã§ãè¨å®æ¹æ³ãã¡ã¢ä»£ããã«æ®ãã¦ããã¾ãã
ãç°å¢ã¯ãRaspberry Pi 2 + Raspbian JessieãRaspberry Pi Zero + Raspbian Jessie LITEã§ç¢ºèªãã¦ãã¾ããRaspberry Pi 3ã¯ä»å¾ç¢ºèªäºå®ã§ãï¼ãããã§æ¢ãã¨åããã¦ãã人ã¯ããã¿ããã§ãï¼ã
å¿ è¦ãªãã®
Raspberry Pi 2 + Raspbian Jessieã®å ´å
[asin:B00T356SFO:detail]
Raspberry Pi 2
[asin:B005DU4XSM:detail]
USB WiFiã¢ã¸ã¥ã¼ã«ï¼BUFFALO WLI-UC-GNM2WiFiï¼
[asin:B00ESA34GA:detail]
USB WiFiã¢ã¸ã¥ã¼ã«ï¼PLANEX GW-USNANO2Aï¼
ãPLANEX GW-USNANO2Aã®æ¹ãæ¶è²»é»åå°ãªãããããã§ãããBUFFALO WLI-UC-GNM2WiFiã®è¨å®ã«å ãã¦ä¸æéå¿ è¦ãªã®ã§æ³¨æä¸ãããPLANEX GW-USNANO2Aã®è¨å®ã¯æ¬è¨äºã®å¾ãã®æ¹ã«è¿½è¨ãã¦ããã¾ãã®ã§ã注æä¸ããã
Raspberry Pi Zero + Raspbian Jessie Zeroã®å ´å
ã以ä¸åç
§ãã ããã
ã以éã¯ä¸é¨ã®äººã«ã¯å®å®èªã«ãªãã®ã§ãèå³ããæ¹ã®ã¿ç¶ããã覧ãã ããã
è¨å®æ¹æ³
ãRaspberry Piã®åºæ¬çãªè¨å®ã¯å®äºãã¦ããåæã¨ãã¾ããOSã¯Raspbian Jessieåæã§ããã»ããã¢ããã«é¢ãã¦ã¯ã以ä¸è¨äºåç §ä¸ããã
ã大ãã以ä¸2ã¤ã§Raspberry Piã¨ç´æ¥WiFiæ¥ç¶å¯è½ã§ãã
- ã¢ã¯ã»ã¹ãã¤ã³ãåï¼hostapdï¼
- DHCPãµã¼ãåï¼dhcpdï¼
ãæ£ç¢ºã«ã¯ã¢ã¯ã»ã¹ãã¤ã³ãåã ãã§ãæ¥ç¶ã§ããã®ã§ãããã¯ã©ã¤ã¢ã³ãï¼ã¹ããï¼ã§ç´æ¥èªåã®IPã¢ãã¬ã¹ãè¨å®ãã¦ãããªããã°ãããªãã¦é¢åãããã®ã§ãDHCPãµã¼ãåããã¦ãã¾ãããªã®ã§å¤å°æéããã£ã¦ãç´æ¥æ¥ç¶ã§ããã°ããã¨ãã人ã¯ã¢ã¯ã»ã¹ãã¤ã³ãåã ãã¾ã試ãã¦ã¿ã¦ãã ããã
ã¢ã¯ã»ã¹ãã¤ã³ãåï¼hostapdï¼
hostapdã¤ã³ã¹ãã¼ã«ã»è¨å®
ãhostapd
ãã¤ã³ã¹ãã¼ã«ãã¾ãã
$ sudo apt-get update $ sudo apt-get install hostapd
ãè¨å®ãã¡ã¤ã«ã®ã²ãªå½¢ãã³ãã¼
$ cd /etc/hostapd/ $ sudo cp /usr/share/doc/hostapd/examples/hostapd.conf.gz ./ $ sudo gzip -d hostapd.conf.gz
ãè¨å®ãã¡ã¤ã«ãä½æã»ç·¨éãã¾ãã
$ sudo vi /etc/hostapd/hostapd.conf
ãè¨å®ã¯ä»¥ä¸ããã以å¤ã®é ç®ã¯ã²ãªå½¢ã®ããã©ã«ãã®ã¾ã¾ã§OKã§ãããã¾ãåããªãã¨ãã¯ãå ¨ãä¿®æ£ããªãããã©ã«ãã®ç¶æ ã§ãä¸åº¦è©¦ãã¦ã¿ãã®ãããããããã¾ããã
interface=wlan0 # bridge=br0 ssid=karaage country_code=JP hw_mode=g channel=1 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 ieee80211n=1 wpa=2 wpa_passphrase=12345678 wpa_key_mgmt=WPA-PSK rsn_pairwise=CCMP
ãssid
ã¨wpa_passphrase
ã¯èªåã®å¥½ããªããã«ã¤ãã¦ãã ãããããããã®ã¾ã¾Raspberry Piã®SSIDã¨ãã¹ã¯ã¼ãã«ãªãã¾ããä»ã®è¨å®é
ç®ã®è©³ç´°ã¯æ¥æ¬èªã§ãã£ã¨è¦ãããªã以ä¸ãµã¤ããé常ã«ããããããã§ããï¼ãªã³ã¯åãã®ããåé¤ï¼
ãå¾ã¯/etc/default/hostapd
ã以ä¸ã³ãã³ãã§ç·¨éã
$ sudo vi /etc/default/hostapd
ã以ä¸ã®ã¿ä¿®æ£ä¸ããã
DAEMON_CONF="/etc/hostapd/hostapd.conf"
ãWiFiã¢ã¸ã¥ã¼ã«ãBUFFALO WLI-UC-GNM2WiFiã®å ´åã¯ããã¾ã§ã§ããã®ã§ãããPLANEX GW-USNANO2Aã®å ´åã¯ããä¸æéå¿ è¦ã§ããæ¬è¨äºã®å¾åã«è¿½è¨ãã¦ãã¾ãã®ã§ããã¡ãã®è¨å®ãå¿ããå®æ½ä¸ããã
USB WiFiãåºå®IPå
ãwlan0
ã«åºå®IPãå²ãæ¯ãã¾ãã/etc/network/interfaces
ã以ä¸ã®ã³ãã³ãã§ç·¨é
$ sudo vi /etc/network/interfaces
ãä¸è¨ãã¡ã¤ã«ã®wlan0
ã®ã¨ããã以ä¸ã®ããã«ä¿®æ£ä¸ããã
iface wlan0 inet static address 192.168.0.20 netmask 255.255.255.0
ãIPã¢ãã¬ã¹ã¯ã好ã¿ã®æ°åã§ããã§ããããã¼ã«ã«ãããã¯ã¼ã¯ã ã¨192.168.0.*
ã使ãã®ãåºæ¬ã§ããwpa-conf
ã®è¨å®ã¯åé¤ãããã³ã¡ã³ãã¢ã¦ããã¦ããã¾ããããè¨å®ãæå¹ã«ããããä¸æ¦åèµ·åãã¦ããã¾ãããã
$ sudo shutdown -r now
hosapdåä½ç¢ºèª
ã以ä¸ã³ãã³ãã§èµ·å
$ sudo hostapd /etc/hostapd/hostapd.conf
ãiPhoneã§WiFiã«æ¥ç¶è¨å®ãã¾ãã
ãkaraageã¨ããSSIDãåºã¦ããï¼æè§ãªã大塩平å
«éã®LANã¨ãã«ããã°è¯ãã£ãï¼
ãkaraageãé¸æãã¦ãèªåãè¨å®ãããã¹ã¯ã¼ããå
¥åããã®å¾ãèªåã®IPã¢ãã¬ã¹ãæåã§è¨å®ãã¦ããã¾ããããRaspberry Piã®ã¢ãã¬ã¹ã®ä¸çªæå¾ã®æ°åãå¤ãããã®ãè¨å®ãã¾ããä¾ãã°ä»åã¯Raspberry Piã192.168.0.20
ãªã®ã§192.168.0.15
ã¨ããã
ããããªæã
ãããã§è¨å®å®äº
ãããã§Raspberry Piã¨WiFiçµç±ã§æ¥ç¶ããããã¨ã«ãªãã¾ããä¾ãã°ãiPhoneããServerauditorã¨ããã¢ããªãèµ·åãã¦Raspberry Piã®IPã¢ãã¬ã¹ãå ¥åãã¦sshæ¥ç¶ããã¦ã¿ã¾ãã
ã
ããããªæãã§ãã°ã¤ã³ã§ãã¾ãããã£ããï¼
ããã ãããã ã¨èªåã§IPã¢ãã¬ã¹ãå
¥åããã®é¢åãããã§ãããé©å½ãªæ°åãªããåæã«è¨å®ãã¦æ¬²ããã§ãããããããå®ç¾ãã¦ãããã®ãdhcpãµã¼ãã§ãã次ã«Raspberry Piã«dhcpdãå
¥ãã¦DHCPãµã¼ãåãã¦ã¿ã¾ãã
DHCPãµã¼ãåï¼dhcpdï¼
ãåºå®IPåãã¦ãããã«ç¹ãããªãç¶æ
ã«ãªã£ã¦ããããã¾ãã¯ä¸æ¦ãããã«ç¹ããããã«/etc/network/interfaces
ãè¨å®ãã¦ããã¾ãããã
isc-dhcp-serverã¤ã³ã¹ãã¼ã«ã»è¨å®
ã以ä¸ã®ã³ãã³ãã§ã¤ã³ã¹ãã¼ã«
$ sudo apt-get install isc-dhcp-server
ã以ä¸ã®ã³ãã³ãã§isc-dhcp-serverã®è¨å®
$ sudo vi /etc/dhcp/dhcpd.conf
ãauthoritative
ã®ã³ã¡ã³ãã¢ã¦ããå¤ãã¦æå¹ã«ãã¾ãããï¼ä»¥ä¸ã®ããã«ï¼ã
# If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. authoritative;
ãããã¦ä»¥ä¸ã®ãããªè¨å®ã追è¨ãã¾ãããã
subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.21 192.168.0.50; option broadcast-address 192.168.0.255; }
ããã®è¨å®ã«ãããRaspberry Piã«æ¥ç¶ããã¯ã©ã¤ã¢ã³ãã«dhcpdã192.168.0.21ã50
ã¾ã§ã®IPã¢ãã¬ã¹ãå²ãæ¯ãããã«ãªãã¾ããããããããªã人ã¯ã¨ããããã³ãããã¦ããã¦ä¸ãããå¾ã
ã«ç解ãã¦ããã°ããã§ããç§ãæ£ç´ä»ã ã«ããåãã£ã¦ãªãã§ãã
isc-dhcp-serveråä½ç¢ºèª
ãããã§åã³/etc/network/interfaces
ãä¿®æ£ãã¦USB WiFiãåºå®IPåãã¾ããããè¨å®å
容ã¯hostapd
ã®ã¨ãã¨åãã§OKã§ãã
ãããããã以ä¸ã³ãã³ããå®è¡ãã¦/isc-dhcp-server
ãèµ·åãã¾ãã
$ sudo /etc/init.d/isc-dhcp-server start
ãã¨ã©ã¼ãªãdhcpãµã¼ããèµ·åããã°OKã次ã«ä»¥ä¸ã³ãã³ãã§hostapdãç«ã¡ä¸ãã¦ããã¾ãã
$ sudo hostapd /etc/hostapd/hostapd.conf
ããã®å¾ãhostapdã®ã¨ãã¨åæ§ã«WiFiã§Raspberry Piã«æ¥ç¶ãã¦ã¿ã¾ããä»åº¦ã¯ãèªåã§IPã¢ãã¬ã¹è¨å®ããªãã¦ããDHCPã§IPã¢ãã¬ã¹ãå²ãæ¯ãããããã«ãªãã¾ãã
ããããªæãã便å©ï¼
èªåèµ·åè¨å®
ãèªåçèµ·åæå¹ããããã«ã¯ã以ä¸ã³ãã³ããå®è¡ãã ããã
$ sudo update-rc.d hostapd defaults $ sudo update-rc.d isc-dhcp-server defaults
ã以ä¸ã³ãã³ãã§åèµ·åãã¦è©¦ãã¦ã¿ã¾ããããåèµ·åå¾ãã¹ããããWiFiã§æ¥ç¶ã§ããã°æåã§ãã
$ sudo shutdown -r now
ãèªåèµ·åãç¡å¹ã«ããå ´åã¯ä»¥ä¸ã³ãã³ãã§OKã
$ sudo update-rc.d hostapd remove $ sudo update-rc.d isc-dhcp-server remove
PLANEX GW-USNANO2Aã使ã£ã¦ã¢ãããã¯æ¥ç¶ããå ´å
ãPLANEX GW-USNANO2Aã使ã£ãå ´åã®è¨å®ã«é¢ãã¦ã追è¨ãã¾ããã
ãçç±ã¯å§åçã«æ¶è²»é»åãå°ãããããå®æ¸¬ããããããï¼ä»¥ä¸è¨äºåç
§ï¼
ãé·æé使ããããªã±ã¼ã¹ã ã¨ããã¯ãBUFFALOããPLANEXã®æ¹ãè¯ãããã ãªã¨æã追è¨ãã¦ãã¾ãã
hostapdä¿®æ£
ãBUFFALOã®ä¾ã®éãã«hostapd
ã¯ã¤ã³ã¹ãã¼ã«ããã¦ããåæã§ããã¾ãã¯hostapd
ãBUFFALOã®WiFiã¢ã¸ã¥ã¼ã«ã§ã®è¨å®ãåèã«ã¤ã³ã¹ãã¼ã«ãã¦ä¸ããï¼æ¬è¨äºååã§ãï¼ã
ãapt-get
ã§å
¥ããã¤ããªã®hostapd
ã¯PLANEXã®ãã®ã«ã¯å¯¾å¿ãã¦ããªããããªã®ã§å
¥ãæ¿ãã¾ããå
·ä½çã«ã¯ä»¥ä¸ãµã¤ãããzipãã¡ã¤ã«ããã¦ã³ãã¼ãã
http://www.adafruit.com/downloads/adafruit_hostapd.zip
ã以ä¸ã³ãã³ãã§ãã¡ã¤ã«ã解åãã¦ãhostapdãã¡ã¤ã«ãå ¥ãæ¿ãã念ã®ããå ã®ãã¡ã¤ã«ã¯hostapd_orgã¨ãã¦ããã¯ã¢ãããã¨ã£ã¦ããã¾ãã
$ unzip adafruit_hostapd.zip $ sudo mv /usr/sbin/hostapd /usr/sbin/hostapd_org $ sudo mv hostapd /usr/sbin/ $ sudo chmod 755 /usr/sbin/hostapd
ã/etc/hostapd/hostapd.conf
ã以ä¸ã®ããã«ä¿®æ£ã
driver=rtl871xdrv
ãããã§PLANEXã®WiFiã¢ã¸ã¥ã¼ã«ã§ãhostapd
ã使ããããã«ãªãã¯ãã§ãã
ç¡ç·LAN ãã¯ã¼ããã¸ã¡ã³ãæ©è½OFF
ããã¯ã¼ããã¸ã¡ã³ãOFFã®å¯¾å¿ããæ¹ãæ¥ç¶ãå®å®ãããããªã®ã§è¨å®è¡ãã¾ããã¾ãã¯ã以ä¸ã®ã³ãã³ããå®è¡ãã¾ãã
$ cat /sys/module/8192cu/parameters/rtw_power_mgnt
ã1
ãè¿ã£ã¦ããããã¯ã¼ããã¸ã¡ã³ãONã«ãªã£ã¦ãã¾ããæ¶è²»é»åã¯æããããã®ã§ããããã¾ã«æ¥ç¶ãä¸å®å®ã«ãªã£ã¦ãã¾ãã¾ããPlanexã®ç¡ç·LANã¯æ¶è²»é»åå
ã
å°ããã®ã§ãOFFã«ãã¦ããã¾ãããã
ãä¸è¨ã³ãã³ãã§/etc/modprobe.d/8192cu.conf
ãã¡ã¤ã«ãä½æ
$ sudo vi /etc/modprobe.d/8192cu.conf
ããã¡ã¤ã«ã®ä¸èº«ã«ä¸è¨ãæ¸ãè¾¼ã
options 8192cu rtw_power_mgnt=0
ãåèµ·åå¾ãä¸è¨å®è¡ã
$ cat /sys/module/8192cu/parameters/rtw_power_mgnt
ã0
ãè¿ã£ã¦ããããã¯ã¼ããã¸ã¡ã³ãOFFã«ãªã£ã¦ãã¾ãã
ã¾ã¨ã
ãèªåã®ãããããã¨ãæ¢ãã®ã¯ãè¨èãç¥ããªãã¨é£ããã§ãããç¹ã«ãããã¯ã¼ã¯å¨ãã¯åãã£ã¦ããããã§å ¨ç¶åãã£ã¦ããªãã®ã§é£ããã§ãããããããã¨ãç¹°ãè¿ãã¦å°ããã¤è©³ãããªã£ã¦ããæ°ã¯ãã¾ãããããã¡ããä½ç³»çã«ç解ããã»ããããããªã¨ãã¾ã«æãã¾ãã
åèãµã¤ã
Raspberry Piにisc-dhcp-serverを設置、自動起動(20161028版) | Making Mugbot マグボットの作り方
é¢é£è¨äº
å¤æ´å±¥æ´
2016/12/01 Raspberry Pi Zeroã§ã®åä½ç¢ºèªè¿½è¨
2016/11/09 å°ä¿®æ£
2015/11/22 PLANEX GW-USNANO2Aã使ã£ã¦ã¢ãããã¯æ¥ç¶ããå ´åã追è¨