Original: https://linux.cn/article-3144-1.html
--------------------------------------------------------------------------------------------------------------- ---------------------------
Try the IP command under Linux, Ifconfig is out of date
Linux's IP commands are similar to Ifconfig, but the former is more powerful and intended to replace the latter. With the IP command, you can easily perform some network administration tasks with just one command. Ifconfig is a command that has been deprecated in net-tools and has not been maintained for many years. Many of the enhanced commands are available in the Iproute2 suite, which is one of the IP commands.
Contrast
To install the IP, click here to download the Iproute2 Kit tool. However, most Linux distributions already have the Iproute2 tool preinstalled.
You can also use the git command to download the latest source code to compile:
Setting and removing 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/ dev wlan0
Please note that the IP address must have a suffix, such as/24. This usage is used to display the subnet mask used in the no-class intra-domain routing (CIDR). In this example, the subnet mask is 255.255.255.0.
Once you've set up your IP address as described above, you'll need to see if it's already in effect.
IP addr Show Wlan0
List the way out by table entry
The parameters of the routing object for the IP command also help you to view the routing data in the network and set up your routing table. The first entry is the default route entry, and you can change it at will.
In this example, there are several routing entries. This result shows that several devices are connected by different network interfaces. They include WiFi, Ethernet, and a point-to-point connection.
Change the default route
To change the default route, use the following IP command : (what is the default route?). )
sudo IP route add default via 192.168. 0.196
displaying network statistics
You can also use the IP command to display statistics for different network interfaces. Ip-s Link
ARP entry
The Address Resolution Protocol (ARP) is used to translate an IP address into its corresponding physical address, which is commonly referred to as the MAC address. Using the Neigh or neighbour option of the IP command, you can view the MAC address of the device that is accessing your local area network
Monitoring NetLink messages
You can also use the IP command to view netlink messages. The monitor option allows you to view the status of network devices. For example, a computer on the local area network can be classified as reachable or stale depending on its state. Use the following command:
Activating and stopping network interfaces
You can use the up and down options of the IP command to stress a particular interface, just like the usage of ifconfig.
In this example, when the Ppp0 interface is activated and after it is stopped and activated again, you can see the corresponding routing table entry. This interface may be wlan0 or eth0. Change ppp0 to any interface that you can use
Get help
You can use the Help option when you're in trouble and don't know how to use a particular option. The man page does not provide much information on how to use IP options, so here is where to get help.
For example, to find out more about the route options:
IP route Help
Summary
For network administrators and all Linux users, the IP command is a must-have tool. It's time to abandon the ifconfig command, especially when you're writing a script.
Linux under IP command vs. ifconfig command