LoginSignup
5
8

More than 5 years have passed since last update.

RaspberryPi Wi-Fi設定

Last updated at Posted at 2016-02-22

目的

LANにwi-fiでRaspberryPiを参加させる

環境

設定

  • APのESSIDを取得
$ sudo iwlist scan| less
lo        Interface doesn't support scanning.

eth0      Interface doesn't support scanning.

wlan0     Scan completed :
          Cell 01 - Address: YY:YY:YY:YY:YY:YY
                    ESSID:"aterm-215cfd-g"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.452 GHz (Channel 9)
                    Encryption key:on
                    Bit Rates:300 Mb/s
                    Extra:wpa_ie=*************
                    IE: WPA Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    Extra:rsn_ie=*************
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown:*************
                    Quality=100/100  Signal level=68/100  
          Cell 02 - Address: YY:YY:YY:YY:YY:YY
                    ESSID:"aterm-215cfd-gw"
                    Protocol:IEEE 802.11bg
                    Mode:Master
                    Frequency:2.452 GHz (Channel 9)
                    Encryption key:on
                    Bit Rates:54 Mb/s
                    Quality=95/100  Signal level=64/100  
          Cell 03 - Address: YY:YY:YY:YY:YY:YY
                    ESSID:"RooM301"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.462 GHz (Channel 11)
                    Encryption key:on
                    Bit Rates:144 Mb/s
                    Extra:rsn_ie=*************
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    Quality=100/100  Signal level=23/100
  • 有線と無線のDHCP設定を書いておく
/etc/network/interfaces
# 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 lo
iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

##static
#iface wlan0 inet static
#adress xxxxxx
#netmask xxxxxx
#network xxxxxx
#broadcast xxxxxx
#gateway xxxxxx
  • 接続させるAPを記述
    • パスワードをハッシュ値に変更
# wpa_passphrase <ssid-name> <password> >> /etc/wpa_supplicant/wpa_supplicant.conf
  • 下記のように整形
/etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
#ap_scan=1
update_config=1
network={
    ssid="<ssid-name>"
    psk=5df1b80706017a7a85191ffb5baba13326655b1f50008b605ec011dae2048a1e
    key_mgmt=WPA-PSK
    proto=WPA2
}
  • 設定適用
# ifdown wlan0;ifup wlan0
  • 確認
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 2  bytes 78 (78.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2  bytes 78 (78.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.169  netmask 255.255.248.0  broadcast 192.168.7.255
        inet6 fe80::222:cfff:fef4:b254  prefixlen 64  scopeid 0x20<link>
        ether 00:22:cf:f4:b2:54  txqueuelen 1000  (Ethernet)
        RX packets 1141  bytes 144616 (141.2 KiB)
        RX errors 0  dropped 113  overruns 0  frame 0
        TX packets 753  bytes 124899 (121.9 KiB)
        TX errors 0  dropped 1 overruns 0  carrier 0  collisions 0
  • 参加したサブネットにある他ノードから接続
$ ssh pi@192.168.1.169
pi@192.168.1.169's password:
Linux raspberrypi 4.9.59+ #1047 Sun Oct 29 11:47:10 GMT 2017 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Jan  4 15:15:43 2018 from 192.168.1.87

pi@raspberrypi:~ $
5
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
8