IP command and ifconfig command (reprint)

Source: Internet
Author: User

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.

set up and delete Ip Address

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

1. $ sudo ip addr add 192.168.0.193/24 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.

2. $ IP Addr Show Wlan0

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

3. $ sudo ip addr del192.168.0.193/24 dev 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.

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

2. $ IP Route get10.42.0.47

--------------------------------------------------------------------------------------------------------------- -------

--------------------------------------------------------------------------------------------------------------- --------

The IP command is the same as the Ifconfig command, but is more powerful and is designed to replace the latter. The IP command is used by default in CentOS 7 and is not installed ifconfig. The Ifconfig command belongs to the Net-tools suite, and the IP command belongs to the Iproute suite. Let's take a look at its usage:

1. Set, view, and delete IP addresses:

Set IP address--

IP addr Add 192.168.1.1/24 dev eth0

View IP Address--

IP Addr Show eth0

Remove IP Address--

IP addr del 192.168.1.1 dev eth0

2. Modify the route:

View the routing table--

IP Route Show

View the interface from which the routing packet came (local interface)--

IP Route Get 123.125.114.144

Change the default route--

IP route add default via 192.168.1.254

3. Display Network information:

Show Network Statistics--

Ip-s Link

View ARP Entries--

IP neigh (or neighbour)

Monitoring NetLink messages--

IP Monitor All

4. Activating or stopping the network interface:

Activating the network interface--

IP link set eth0 up

Stop network Interface--

IP link set eth0 down

Well, it took me a while to get to know this thing with a ifconfig. In addition, the netstat command was replaced by the SS command!

IP command and ifconfig command (reprint)

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.