IP (Internet Protocol) address is a numerical label assigned to a network interface of a computer that allows the communication of the system over the internet. On a computer network, a system communicates with another system by its IP address. The older operating systems were uses the ifconfig. Which was also a powerful command, is deprecated on newer Linux systems, and replaced by the ip command. But, You can also use the ifconfig command on modern OS/Distros by installing net-tools package.. In this tutorial, you will learn about the uses of the Linux ip command with useful examples.

How to Use ip Command

The modern Linux systems provide iproute2 package, which replaces the various commands provided by the net-tools package. Also, the ip command comes under this packages, with great features.

Syntax:

The ip command uses the following syntax: Remember that configurations created with this command like IP addresses, routes, and policy routing rules (and so on) are not persistent. Make changes permanently, you need to edit the appropriate configuration to your platform/OS.

Get Help

Just type “help” after the ip command to view commands uses details. In addition, use the help command to get object specific help, like: Similarly, try below command to get help for route object subcommand. Try the help command with other objects to get help. Next, you will learn about the uses of the ip command. For the learning purpose, use a system physically accessible. In other words, any wrong command may down the network interface and you may disconnect from the remote systems. But, the physical system still be accessible.

View and Manage Network Interfaces

Use link subcommand with ip command to manage and display the state of all network interfaces. The Name of the network interfaces may differ based on the Linux distributions and hardware platforms etc.

Display and Add IP Address on Network Interfaces

The ip addr subcommand is used for displaying the IP address configured on network interfaces. You can also use the same command to set an IP address on a network interface. Remove the interface name (eth0) to view statics for all the available network interfaces. Use down option to bring the network interface offline Note: While working with remote systems, don’t bring down the interface. It may disconnect your system from the network.

Display and Alter the Routing Table

The ip command also provides you the option to view or change the routing table of any network interface. You can also display only IPv4 or IPv6 ip addresses by using ip -4 addr or ip -6 addr commands. For example, view the IP address on eth0 network interface: For example, use the following command to remove IP address 192.168.10.105 with 24 subnet mask from eth0 interface Use ip route subcommand to work with the routing tables.

Conclusion

In conclusion, you have learned about Linux ip command with useful examples. Here we describe, how to manage a network interface on Linux systems. Adding or deleting the kernel routing table entries. Make a network interface UP (online) and down (offline). Adding, remove or display the IP addresses on a network interface. The above results show that 192.168.10.1 is the default gateway used by the kernel via the eth0 network interface.