New network management tools under Linux IP replacement ifconfig 0 pressure

Source: Internet
Author: User
Tags root access

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.

    1. 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.

    1. IP A

This command will list information about all network interfaces.

You say you just want to see IPV4 related information, so you can.

    1. 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.

    1. IP a show wlan0

You can even locate more specific information to see the IPV4 information on the wlan0.

    1. Ip-4 a show Wlan0

You can also list the network interfaces that are running.

    1. 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.

    1. Ifconfig eth0 192.168.1.101

Then the IP command is the case.

    1. IP a add 192.168.1.101/255.255.255.0 dev eth0

A short one can do this.

    1. 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.

    1. 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.

    1. 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

    1. IP link set dev eth0 down

Activating eth0

    1. IP link set dev eth0 up

With the IP command, we can also add/remove the default gateway, just like this.

    1. 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.

    1. 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.

    1. 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.

    1. 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.

    1. IP route add 192.168.1.0/24 Dev eth0

Delete this route.

    1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.