addresses Command in Linux with Examples
ip address command is a part of IP command in Linux. IP command is used to deal with IP address, ARP cache entry, tunnel over IP, routing table entry, etc. of all the network devises on a system, it is a replacement of old ifconfig command in Linux. More details on the IP command can be found here. IP address command is used to deal with protocol addresses (IP, IPv6). It becomes particularly helpful when dealing with systems with numerous network devices. It gives the user the ability to monitor all the devices and modify the addresses when necessary, as well as add or remove network devices. There are two abbreviations of IP address, namely: IP a and IP addr.
Let’s see how to use the IP address command.
1. Display all the network devices and their corresponding address
ip address or ip a or ip addr
Output:

2. Display all the network devices with IPv4 address addresses only
ip -4 addr
Output:

3. Display all the network devices with IPv6 address addresses only
ip -6 address
Output:

4. Display network information of a specific interface
ip a show dev {interface}Example:
ip a show dev docker0
Output:

ip a show up command shows all the devices which are up. The output would be similar to the output of first command ip a.
5. Using ip a add command to assign an IP address to an interface
Syntax
ip a add [ip_address/mask] dev {inferface}Example
ip a add 111.111.111.111/255.255.255.0 dev docker0 or ip a add 111.111.111.111/24 dev docker0
There would be no output in the terminal, the user needs to use ip a to check if the address of the interface is changed. If the user faces any issue like “Operation not permitted” try using the same command with sudo.
6. Using ip a del command to unassign an IP address to an interface
Syntax:
ip a del [ip_address/mask] dev {inferface}Example:
ip a del 111.111.111.111/255.255.255.0 dev docker0 or ip a add 111.111.111.111/24 dev docker0
There would be no output in the terminal, the user needs to use ip a to check if the address of the interface is changed. The interface would now be allocated a new address using automatically. If the user faces any issue like “Operation not permitted” try using the same command with sudo.


