Raspberry Pi_Kor_11.1.2 “ifconfig” 명령 – network 장치 상태 및 IP 주소 확인하기


Published Book on Amazon


All of IOT

Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1

All of IOT

Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2


출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사

물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)

최신 라즈베리파이(Raspberry Pi)로 시작하는 사

물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)


Original Book Contents


11.1.2  "ifconfig" 명령 - network 장치 상태 및 IP 주소 확인하기

 

Raspberry Pi 시스템에서 현재의 network 연결상태를 확인하거나 network 연결을 새롭게 시작하거나, 정상 작동중인 것을 중단하기 위해서 ifconfig 명령을 사용한다.

 

[명령 형식]

ifconfig  [display-option]   [interface]    [작동 option]

 

[명령 개요]       

    현재의 network 연결상태를 확인하거나 network 연결상태를 조정해 준다.

    user 권한    -- 일반 user.

 

[상세 설명]

    이 명령은 network interfaces를 설정하기 위해서 사용된다. 시스템이 booting할 때 interface를 설정하기 위해서 사용되고 그 이후는 필요한 경우만 사용한다.

    특별한 option을 지정하지 않으면 현재 활성화된 interface에 대한 정보를 보여준다.

    interface network driver 이름에 unit number가 결합된 이름이다. 예를 들어 eth0는 첫 번째 Ethernet 연결에 부여되는 이름이다.


 

[주요 Option]

-h

display help message and exit

-a    

display  all  interfaces  which are currently available, even if down

-s    

display a short list (like netstat -i)

up    

This  flag  causes the interface to be activated.  It is implicitly specified if an address is assigned to the interface.

down  

This flag causes the driver for this interface to be shut down.

 

 

[사용 Example]

아래는 시스템에 대한 network 연결 정보에 대해서 조회한 결과이다

 

pi@raspberrypi ~ $ ifconfig

eth0      Link encap:Ethernet  HWaddr b8:27:eb:e2:c7:4b

          inet addr:192.168.1.202  Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:11916 errors:0 dropped:0 overruns:0 frame:0

          TX packets:18069 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:947846 (925.6 KiB)  TX bytes:17912372 (17.0 MiB)

 

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:65536  Metric:1

          RX packets:71968 errors:0 dropped:0 overruns:0 frame:0

          TX packets:71968 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:512337630 (488.6 MiB)  TX bytes:512337630 (488.6 MiB)

 

wlan0     Link encap:Ethernet  HWaddr 48:02:2a:87:cb:26

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:91 errors:0 dropped:0 overruns:0 frame:0

          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:18229 (17.8 KiB)  TX bytes:1036 (1.0 KiB)

11‑1 ifconfig 실행 사례


 

"eth0"는 유선 Ethernet 장치를 의미한다. 여기에 지정되어 있는 IP address는 유선 network에 대해서 지정된 IP address이다. 통상적으로 Raspberry Pi 시스템에 LAN 케이블을 연결하고, 시스템을 시작하면 자동으로 network에 접속되어 IP address가 부여되도록 설정이 되어 있다.    

 

"lo"는 시스템에 내장된 loopback 장치이다. 여기에는 "127.0.0.1"이라는 IP address가 지정되어 있다. loop back 장치는 네트워크상의 별도의 물리적인 장치가 아니라 네트워크에서의 자기 자신을 지칭하는 가상 인터페이스 장치이다. Linux에서는 많은 시스템 서비스들은 client/server application 방식으로 서로 통신을 하면서 작동을 하는데, 이때 loopback 장치는 자체 시스템에서 실행되고 있는 server를 지칭하는 장치 이름이다. 이렇게 시스템 내부에서 IP address를 이용하여 처리를 하는 application이 자체 시스템에 대해서 어떤 처리를 하고자 할 때 loopback 장치를 사용한다

 

"wlan0"는 무선 Wi-Fi 장치를 의미한다. Wi-Fi 장치가 설치되고, 정상적으로 설정이 되어서 network에 접속되어 있다면 IP address가 부여되지만, 정상적으로 설정이 되지 않은 상태이면 IP address가 부여되지 않을 수도 있다. Wi-Fi를 설정하는 방식에 대해서는 뒤에서 다시 상세히 다루도록 하겠다.     


 

Leave a Reply