In this step, you will learn how to use the ip command, which is the modern and preferred tool for viewing and manipulating network interfaces, IP addresses, and routes on Linux systems. We will start with the most fundamental command to display information about all available network interfaces.
The command ip a is a shortcut for ip address show. It provides a comprehensive overview of your system's network configuration.
First, ensure you are in the terminal. Your default path is ~/project. Now, execute the ip a command to list all network interfaces and their associated addresses.
ip a
You will see a detailed output listing all network interfaces. Typically, you will see several interfaces:
lo: This is the loopback interface, a virtual network interface that the system uses to communicate with itself. It always has the IP address 127.0.0.1.
eth0 (or a similar name like enp0s5): This is your primary Ethernet interface, which connects your system to the external network. Notice the altname fields, which provide alternative names for the interface.
docker0: If Docker is installed, you might see a docker0 interface, which is a virtual bridge created by Docker for container networking.
Your output will look similar to the example below, though the specific names and addresses will differ.
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:16:3e:0e:d8:3c brd ff:ff:ff:ff:ff:ff
altname enp0s5
altname ens5
inet 172.16.50.202/24 metric 100 brd 172.16.50.255 scope global dynamic eth0
valid_lft 1892159975sec preferred_lft 1892159975sec
inet6 fe80::216:3eff:fe0e:d83c/64 scope link
valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:60:7e:6f:bc brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
Take a moment to examine the output. In the following steps, we will break down this information to identify specific details like the MAC address and IP addresses.