Linux under the IP command, in addition to ifconfig there are many

Source: Internet
Author: User
Tags git clone

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.

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:

    1. $ git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/shemminger/ Iproute2.git

Iproute2 git clone

Setting and removing IP addresses

To set an IP address for your machine, you can use the following IP commands:

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

    1. $ ip addr show wlan0

Set IP Address

You can also delete the IP address in the same way, just use del instead of Add.

    1. $ sudo ip addr del 192.168. 0.193/ dev wlan0

Delete IP Address

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.

    1. $ IP Route show

IP Route Show

Assuming you now have an IP address, you need to know where the routing packets are coming from. You can use the following routing options: Lists the interfaces used by the route, and so on:

    1. $ IP route get 10.42. 0.47

IP Route Get

Change the default route

To change the default route, use the following IP command:

    1. $ sudo IP route add default via 192.168. 0.196

Default route

displaying network statistics

You can also use the IP command to display statistics for different network interfaces.

IP Statistics all interfaces

When you need to get information about a particular network interface, add the option LS after the network interface name. Using multiple options- s will give you more detailed information about this particular interface. This is especially useful when troubleshooting network connections.

    1. $ IP -s -s link ls p2p1

IP link Statistics

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 connected to your local area network.

    1. $ IP neighbour

IP neighbour

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:

    1. $ IP monitor All

IP Monitor All

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 the ppp0 to any interface that you can use.

    1. $ sudo ip link set ppp0 down
    2. $ sudo ip link set ppp0 up

IP link set up and down

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:

    1. $ IP route Help

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.

via:http://linoxide.com/linux-command/use-ip-command-linux/

Linux under the IP command, in addition to ifconfig there are many

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.