The ip command

a) Description

The ip command is used view and manage a Linux system’s network configuration. Its main purposes are:

Changes made with ip are temporary and are lost after a reboot, so for permanent settings you configure the network through your system’s tools (NetworkManager, netplan, systemd-networkd, etc.).

b) Examples

1-It shows interface name, IP address and subnet mask in CIDR (modern) format
dacomo@inf1-dacomo:~$ ip a
2-It show the gateway (router) IP address.
dacomo@inf1-dacomo:~$ ip r
3-It shows the DNS IP addresses.
dacomo@inf1-dacomo:~$ cat /etc/resolv.conf
4-It removes IP address = 192.168.5.10 with subnet mask = 23 from device enp0s3
dacomo@inf1-dacomo:~$ sudo ip a del 192.168.5.10/23 dev enp0s3
5-It adds IP address = 172.16.1.1210 with subnet mask = 21 to device enp0s3
dacomo@inf1-dacomo:~$ sudo ip a add 172.16.1.210/21 dev enp0s3
6-It removes IP address = 192.168.1.10 with subnet mask = 22 from device enp0s3
dacomo@inf1-dacomo:~$ sudo ip a del 192.168.1.10/22 dev enp0s3
7-It sets a default router IP address to 172.16.1.1
dacomo@inf1-dacomo:~$ sudo ip route add default via 172.16.1.1
8-It removes a default router IP address equal to 192.168.1.1
dacomo@inf1-dacomo:~$ sudo ip route del default via 192.168.1.1