라즈베리파이(Raspberry PI) 인터넷 연결

1. 유선랜 설정
– 기본적으로 DHCP기능이 활성화 되어 있어 랜선만 꽃기만 하면 된다.
ifconfig를 쳐보면 192.168.0.125라는 IP주소로 할당받은 것을 알수 있다.

pi@raspberrypi:~$ ifconfig
enxb827ebeaadc5: flags=4163  mtu 1500
        inet 192.168.0.125  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::3dba:6631:6fe1:c90f  prefixlen 64  scopeid 0x20
        ether b8:27:eb:ea:ad:c5  txqueuelen 1000  (Ethernet)
        RX packets 5418  bytes 569192 (555.8 KiB)
        RX errors 0  dropped 1239  overruns 0  frame 0
        TX packets 63  bytes 7286 (7.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099  mtu 1500
        ether b8:27:eb:bf:f8:90  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

pi@raspberrypi:~$

2. SSH를 통한 연결 접속
1) SSH 서버 활성화

sudo raspi-config







2) SSH 서버로 접속
위에서 확인한 IP/PORT :192.168.0.125/22로 SecureCRT를 통해 접속

3. 무선랜 설정
1) iwconfig 명령으로 네트워크 어답터 목록 확인
이중 “no wireless extensions”가 아닌 wlan0이 내장되어있는 WiFi 아답터임.

iwconfig

2) 접속가능한 주변 AP 검색

sudo iwlist wlan0 scan | more

– 여러개의 AP가 나오는데, 연구소에 설치되어 있는 “moram-lab”을 이용하기로 한다.

          Cell 05 - Address: 64:E5:99:0A:32:04
                    Channel:6
                    Frequency:2.437 GHz (Channel 6)
                    Quality=60/70  Signal level=-50 dBm  
                    Encryption key:on
                    ESSID:"moram-lab"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s
                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=0000000000000000
                    Extra: Last beacon: 80ms ago
                    IE: Unknown: 00096D6F72616D2D6C6162
                    IE: Unknown: 010882848B960C121824
                    IE: Unknown: 030106
                    IE: Unknown: 2A0100
                    IE: Unknown: 32043048606C
                    IE: Unknown: 2D1A6E181EFFFF000000000000000000000000000000000000000000
                    IE: Unknown: 3D1606070000000000000000000000000000000000000000
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP

3) PSK를 생성
– wpa_passphrase명령을 이용하여 PSK 생성

 wpa_passphrase 접속할AP의SSID 접속할AP의비밀번호
 wpa_passphrase moram-lab 비밀번호
network={
        ssid="moram-lab"
        psk=d847cf7519242cc9486e9bbe317a1ed811b20034cd74b4d995c6d6c8a2e2c3d9
}

4) /etc/wpa_supplicant/wpa_supplicant.conf 파일 수정
– 일단 editing을 위해 vim 설치

sudo apt-get install vim
sudo vim /etc/wpa_supplicant/wpa_supplicant.conf

– 아래와 같이 하단에 위에서 생성한 PSK를 추가한후에 저장

country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
        ssid="moram-lab"
        psk=d847cf7519242cc9486e9bbe317a1ed811b20034cd74b4d995c6d6c8a2e2c3d9
}

5) 인터페이스 파일 수정

sudo vim /etc/network/interfaces

하단에 아래와 같이 추가

auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

6) wifi 아답터 재시작
– WIFI 재시작

sudo ifup wlan0

Internet Systems Consortium DHCP Client 4.3.5
Copyright 2004-2016 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/b8:27:eb:bf:f8:90
Sending on   LPF/wlan0/b8:27:eb:bf:f8:90
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
DHCPREQUEST of 192.168.0.126 on wlan0 to 255.255.255.255 port 67
DHCPOFFER of 192.168.0.126 from 192.168.0.1
DHCPACK of 192.168.0.126 from 192.168.0.1
bound to 192.168.0.126 -- renewal in 3297 seconds.

– 참고 : 만약 아래와 같이 에러난 경우, 라즈베리파이에 전원을 뺐다가 다시 넣으니까 해결됨.

wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
ifup: failed to bring up wlan0
pi@raspberrypi:~$ 

7) IP 할당

sudo wpa_cli reconfigure
Selected interface 'p2p-dev-wlan0'
OK

8) IP 할당 확인
– ifconfig로 확인

wlan0: flags=4163  mtu 1500
        inet 192.168.0.126  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::ba27:ebff:febf:f890  prefixlen 64  scopeid 0x20
        ether b8:27:eb:bf:f8:90  txqueuelen 1000  (Ethernet)
        RX packets 316  bytes 36224 (35.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 40  bytes 6359 (6.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
태그

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다