If you use Linux long enough, then you naturally know that some tools come and go. The 2009 Debian Developer Mailing List announced the abandonment of the lack of maintenance of the Net-tools Toolkit. To this day net-tools is still used by some people. In fact, you can still use the ifconfig command to manage your network configuration in Ubuntu 14.10.
However, in some cases (e.g., Ubuntu Docker containers), the Net-tools Toolkit will not be installed by default, which means that ifconfig cannot be used . However, Net-tools can be installed using a software repository.
- sudo apt-get install Net-tools
Since Net-tools is no longer maintained, we strongly recommend replacing ifconfig with IP commands. More importantly, IP is performing better on the basis of replacing Ifconfig.
Interestingly , IP is more than just a substitute for ifconfig, and the two commands are structurally different. Even so, they are used for the same purpose. In fact, the IP command can complete all the following transactions.
- List which network interfaces are configured on the system
- To view the status of a network interface
- Configuring network interfaces (including local loops and Ethernet)
- Enable or disable a network interface
- Manage default static routes
- IP tunneling Configuration
- Configuring ARP or Ndisc cache entries
Next, let's try using IP instead of Ifconfig as described above. I'll cite some simple examples to illustrate how to use IP commands. To properly use and understand these commands requires root access , you can switch to the root user with Su or use sudo. Because these commands will change the network information of your machine. use with caution .
Note : The address used in the demo is only a demonstration, and when it comes to your computer, it will be different from your network and hardware.
Next, let's get started!
Collect information
The first thing most people learn to do with Ifconfig is to look at the assigned IP address on the network interface. Direct terminal input ifconfig can be seen without any parameters. Then using IP to do this is all we need.
- IP A
This command will list information about all network interfaces.
You say you just want to see IPV4 related information, so you can.
- Ip-4 A
You say you want to see information about a particular network interface, then use the following command to view the wireless card connection information.
- IP a show wlan0
You can even locate more specific information to see the IPV4 information on the wlan0.
- Ip-4 a show Wlan0
You can also list the network interfaces that are running.
- IP link ls up
Modifying the Configuration network interface
Next, let's learn the core function of the IP command-modifying the configuration network interface. If you want to schedule a specific address for the first Ethernet network card (eth0). With ifconfig, it looks like this.
- Ifconfig eth0 192.168.1.101
Then the IP command is the case.
- IP a add 192.168.1.101/255.255.255.0 dev eth0
A short one can do this.
- IP a add 192.168.1.101/24 dev eth0
Obviously in this case, you need to know the subnet mask of the address you want to schedule.
In the same way, you can delete the address of a network card like this.
- IP a del 192.168.1.101/24 dev eth0
If you want to simply clear all the addresses on all the interfaces, you just need to.
- Ip-s-S A f to 192.168.1.0/24
The IP command can also activate/disable the network interface on the other.
Disable eth0
- IP link set dev eth0 down
Activating eth0
- IP link set dev eth0 up
With the IP command, we can also add/remove the default gateway, just like this.
- IP route Add default via 192.168.1.254
If you want to get more details on the network interface, you can edit the transmission queue, set a low value for the slow interface, and set a higher value for the speed. Then you need to do it like this.
- IP link set txqueuelen 10000 dev eth0
This command sets a very long transmission queue. You should set a value that best fits your hardware.
You can also set the maximum transmission unit for a network interface with an IP command.
- IP link set MTU 9000 dev eth0
Once you have made a change, you can use the IP A list eth0 to verify that it is in effect.
Manage routing Tables
In fact, you can also use IP commands to manage the System routing table. This is a very useful feature of the IP command. And you should use it carefully .
View all routing tables.
- IP r
The output will look like the following.
Now you want to route all traffic from the eth0 NIC to the 192.168.1.254 gateway through, then please do so.
- IP route add 192.168.1.0/24 Dev eth0
Delete this route.
- IP route del 192.168.1.0/24 dev eth0
This article only introduces some of the IP commands. You are not required to use the IP command immediately. You can continue to use ifconfig. Because the ifconfig is quite slow to discard, the command is still installed by default in many distributions. However, it is believed that the IP command will eventually be completely replaced. Read this introduction, then you can quickly change the past. If you also want to learn more about the use of IP commands, see the Man manual for IP commands.
New network management tools under Linux IP replacement ifconfig 0 pressure