Raspberry Pi_Eng_11.1.2 “ifconfig” Command – Verify Network Status & IP Address


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" Command - Verify Network Status & IP Address

 

The "ifconfig" command is used on the Raspberry Pi system to check the current network connection status, to start a new network connection, or to stop normal working network.

 

[Command Format]

ifconfig  [display-option]   [interface]    [operation option]

 

[Command Overview]    

   This checks current network connection status or adjusts network connection status.

   User privilege          -- Normal user.

 

[Detail Description]

   This command is used to configure network interfaces. It is used to configure the interface when the system is booting, and after then, it is used only when necessary.

   If no special option is specified, information about the currently active interface is displayed.

   The interface is the name that combines the network driver name with unit number. For example, "eth0" is the name given to the first Ethernet connection.

 

[Main 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.

 

[Used Example]

Below is the result of querying the network connection information for the system.

 

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)

Table 11‑1 Execution example of ifconfig

 

"Eth0" means a wired Ethernet device. The IP address assigned here is the IP address assigned to the wired network. Normally, it is configured that if a LAN cable is connected to the Raspberry Pi system and the system is started, it is automatically connected to the network and the IP address is assigned to it.

"lo" is a loopback device built into the system. It has an IP address of 127.0.0.1. The loop back device is not a separate physical device on the network but a virtual interface device that refers to itself in the network. In Linux, many system services communicate and operate in a client/server application manner, where the loopback device is the device name that refers to the server running on its own system. In this way, an application that processes using IP address inside the system uses a loopback device when it wants to do something with its own system.

"wlan0" means wireless Wi-Fi device. If a Wi-Fi device is installed and is normally configured and connected to the network, an IP address will be assigned. However, if the Wi-Fi device is not properly configured, the IP address may not be assigned. We'll go into more detail later on how to set up Wi-Fi.