Display IP address

One of the ways to display the IP address in Raspbian is by running the ifconfig command. This command can also used to configure, disable, and enable a network interface. Used without any options, the ifconfig command displays network settings of all network interfaces on your device:

ifconfig command

As you can see from the picture above, the ifconfig command displayed detailed information about the eth0 interface (the 10/100 MBps Ethernet port on the Raspberry Pi board) and the lo interface, a virtual network interface used for diagnostics and troubleshooting. Consider the following line of the output:

ifconfig command ip address

The inet addr parameter represents the IP address of the interface (192.168.5.11 in our case).

By default, a Raspberry Pi device running Raspbian will get network information (such as the IP address and subnet mask) from the DHCP server. You can also configure the IP address manually using the ifconfig IP address. Here is how this can be done:

ifconfig assign an ip address

As you can see from the picture above, the ifconfig eth0 192.168.5.11 netmask 255.255.255.0 command was used to assign a static IP address to our device.

Subscribe to our Newsletter

Like us on Facebook

top
Geek University 2019