Try the ip command in Linux. ifconfig is out of date.
Linux's ip commands are similar to ifconfig, but the former is more powerful and aims to replace the latter. Using ip commands, you can easily execute some network management tasks with only one command. Ifconfig is an obsolete command in net-tools. It has not been maintained many years ago. The iproute2 suite provides many enhanced functions. The ip command is one of them.
Practical application of CentOS ifconfig, route, and ip commands
Ifconfig cannot display the NIC after CentOS is installed
Practical application of CentOS ifconfig, route, and ip commands
Ifconfig: command not found
Ifconfig output network port and ip address in CentOS 6.2
To install the ip address, click here to download the iproute2 package. However, most Linux distributions are pre-installed with the iproute2 tool.
You can also use the git command to download the latest source code for compilation:
- $ Git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/shemminger/iproute2.git
Set and delete IP addresses
To set an ip address for your machine, you can use the following ip commands:
- $ Sudo ip addr add 192.168.0.193/24 dev wlan0
Note that the IP address must have a suffix, such as/24. This usage is used to display the subnet mask used in classless domain routing selection (CIDR. In this example, the subnet mask is 255.255.255.0.
After you set the IP address according to the above method, you need to check whether it has taken effect.
- $ Ip addr show wlan0
You can also delete an IP address in the same way. You only need to replace add with del.
- $ Sudo ip addr del192.168.0.193/24 dev wlan0
List route table entries
The parameters of the route object of the ip command can also help you view route data in the network and set your route table. The first entry is the default route entry. You can modify it at will.
In this example, there are several route entries. The result shows that several devices are connected through different network interfaces. They include WIFI, Ethernet, and a point-to-point connection.
- $ Ip route show
If you have an IP address, you need to know where the route package comes from. The following routing options can be used ):
- $ Ip route get10.42.0.47
For more details, please continue to read the highlights on the next page: