ip — Manipulate network device, routing and tunnelsSummary:
The ip is a swiss army knife command. It does many functions like assigning IP addresses to interfaces, for setting up routes and display configurations etc. In this part, we will see some of the protocol (IP) address management using the IP command. Examples:
$ ip address -- Show the address of the interfaces. $ ip address show -- Same as above. $ ip address show eth0 -- Show only eth0 interface. $ ip addr show scope global -- Show all global addresses. $ ip addr show scope host -- Show all host addresses. $ ip addr show to 192.168.0.0/16 -- Show all prefix matching IP. $ ip addr show primary -- Show primary address. $ ip addr show secondary -- Show secondary address. $ ip addr show label "eth*" -- Show the matching interfaces. # ip addr add 127.0.0.1/8 brd + dev lo scope host -- Add IP tolo interface. # ip addr add 10.1.1.1/24 brd + dev eth0 scope global -- Add IP toeth0 interface. # ip addr add 10.1.2.1/24 brd + dev eth0 -- Add 2nd IP to eth0 # ip addr add 10.1.3.1/24 brd + dev eth0 label eth0:1 -- Add IP to eth0 with a label (alias). # ip addr del dev eth0 -- Delete the 1st IP address. # ip addr del dev eth0 10.1.3.1/24 -- Delete the specific IP. # ip addr flush to 10.0.0.0/8 -- Delete all local IPs. # ip addr -4 flush label "eth*" -- Delete all IPv4 addressof Ethernet interfaces.
Read: man ip