Linux under IP command usage

Source: Internet
Author: User

The configuration data forwarding, can pass 1, the route forwarding namely uses the router realizes;

2, using NAT forwarding;

To put it simply:

The information in the routing table is just the next place in the router where the packet is specified. Does not change the address information of the packet itself. That is, it just "change the road, the destination is unchanged";

The address translation is to convert the address of the packet to a web-enabled IP address, so that the host can be authenticated to the Internet. That is, "replace the destination";

Setting and removing IP addresses

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

# ip addr Add 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

After setting the IP address, you need to see if it is already in effect

#ip Addr Show Wlan0

Delete the IP address, just need del Replace add

#ip addr del Dev Wlan0

Routing Table Related:

The parameters of the routing object for the IP command can also help you view the routing data in the network and set up the routing table. The first entry is the default routing entry, and you can change it at will.

1. List the routing table entries:

#ip Route Show

1[Email protected]:~# IP Route2 defaultVia222.132.16.49Dev Br03 defaultVia222.132.16.49Dev br0 Metric - 4 -Dev eth1 proto kernel scope link src10.0.0.50 5 -Dev br0 proto kernel scope link src10.22.0.1 6 -Dev br0 proto kernel scope link src10.128.0.3 7 -Dev br0 proto kernel scope link src10.128.0.1 8 -Dev virbr0 proto kernel scope link src192.168.122.1 9 -Dev br0 proto kernel scope link src222.132.16.50 

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

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

Get 101.80. 4.77 101.80. 4.77 222.132. 16.49 Dev br0  222.132.  16.50     

3. Change the default route

#ip route add default via #default via

4. Display the network statistic data

#ip-S link

1[Email protected]:~# ip-s Link2 1: Lo: <LOOPBACK,UP,LOWER_UP> MTU65536qdisc noqueue State UNKNOWN3Link/loopbackxx:xx:xx:xx:xx:xxBrdxx:xx:xx:xx:xx:xx4 rx:bytes packets Errors dropped overrun Mcast5     78835338   773177   0       0       0       0      6 tx:bytes packets errors dropped carrier Collsns7     78835338   773177   0       0       0       0      8 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU theQdisc MQ Master Ovs-system State up Qlen +9Link/etherxx: -: 9e:9c: $: theBRD FF:FF:FF:FF:FF:FFTen rx:bytes packets Errors dropped overrun Mcast One     1229283210 9618898  0       0       0       1300950 A tx:bytes packets errors dropped carrier Collsns -     14610128653 14780439 0       0       0       0  

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.

#ip-S link ls eth0

5. Activating and stopping the network interface

#ip Link Set eth1 down

#ip Link set eth0 up


#ifconfig eht1 Down

#ifconfig eth1 up


Linux under IP command usage

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