Linux System network commands (II)

Source: Internet
Author: User

One, Linux under Iptoute2 Network Configuration Tool

We have learned to use the ifconfig, route two commands about the network configuration, these two commands and Netstat, ARP and other commands are net-tools RPM installation package, now has a new kit to replace the above command, The installation package is Iproute, the package contains a new command IP, SS, these two commands are very powerful through can be seen.

650) this.width=650; "title=" 003404uy9l1t5zayzllylm.png "src=" http://s3.51cto.com/wyfs02/M01/6F/AE/wKioL1WlG7_ Sg0iwabaxxxs5tny573.jpg "alt=" Wkiol1wlg7_sg0iwabaxxxs5tny573.jpg "/>

Second, the use of IP command under Linux

1. Introduction to IP commands

IP is a powerful network configuration tool in the Iproute package, it can replace some traditional network management tools, such as ifconfig, route, etc., with the privilege of Superuser . You can see the common collocation and introduction of IP commands.

650) this.width=650; "title=" Iproute2.png "src=" http://s3.51cto.com/wyfs02/M01/6F/B1/ Wkiom1wlghmaangsaauai-eizjs031.jpg "alt=" Wkiom1wlghmaangsaauai-eizjs031.jpg "/>

2. Common options

-v,-version Print the IP version and exit.

-s,-stats,-statistics output more detailed information. If this option occurs two or more times, the output information will be more detailed.

-f,-family This option is followed by protocol types, including inet, Inet6, or link, which emphasize the type of protocol used. If there is not enough information to tell the IP about the protocol type used, the IP will use the default value inet or any. Link is special, which means that no network protocols are involved.

-4 is a shorthand for-family inet.

-6 is a shorthand for-family Inet6.

-0 is a shorthand for-family link.

-o,-oneline uses a single-line output for each row of records, and the return line is replaced with characters. This option is used if you need to process the output of the IP using tools such as WC, grep, and so on.

-r,-resolve Query the domain name resolution system, replace the host IP address with the host name obtained


3. Examples of IP command use

The use of IP link, ip addr, IP route is introduced in this article because of the more functions of IP command.


3.1, IP link use example

To start and close the network card:

[[Email protected] ~]# IP link set dev eth0 up//start NIC, Dev can omit, set can be written s[[email protected] ~]# IP link set dev eth0 Down//off NIC


Display Device properties:

[[email protected] ~]# ip -s -s link show eth0//-s option appears two or more times, The IP will output more detailed error information statistics. 2: eth0: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast  state unknown qlen 1000    link/ether 00:0c:29:7a:e4:0e brd  ff:ff:ff:ff:ff:ff    rx: bytes  packets  errors   dropped overrun mcast      43571980   35915     0       0       0        0          RX  errors: length  crc     frame   fifo     missed               0     &Nbsp;   0       0       0 &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;0&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;TX:  bytes  packets  errors  dropped carrier collsns     2659582    24034    0        0       0       0           TX errors: aborted fifo     window  heartbeat                0        0       0        0

In the example above, show can also be replaced with list, LST, sh, LS, L.


3.2, IP addr Use example

Show protocol Address:

[[Email protected] ~]# IP addr show eth0//show can also replace 2:eth0 with list, LST, sh, ls, L: <broadcast,multicast,up,lower _up> MTU Qdisc pfifo_fast State UNKNOWN Qlen $ link/ether 00:0c:29:7a:e4:0e BRD FF:FF:FF:FF:FF:FF inet 19 2.168.1.110/24 BRD 192.168.1.255 Scope global eth0 inet6 fe80::20c:29ff:fe7a:e40e/64 scope link Valid_lft foreve R Preferred_lft Forever


Add a new protocol address:

Add an address 192.168.1.2 on the Ethernet interface eth0, labeled eth0:0:

[[Email protected] ~]# IP addr Add 192.168.1.2/24 dev eth0 label eth0:0[[email protected] ~]# IP addr Show Eth02:eth0: &L T Broadcast,multicast,up,lower_up> MTU Qdisc pfifo_fast State UNKNOWN Qlen-Link/ether 00:0c:29:7a:e4:0e BRD Ff:ff:ff:ff:ff:ff inet 192.168.1.110/24 BRD 192.168.1.255 scope global eth0 inet 192.168.1.2/24 scope Global Seconda Ry eth0:0 inet6 fe80::20c:29ff:fe7a:e40e/64 scope link Valid_lft forever Preferred_lft forever


Remove a protocol address:

[[Email protected] ~]# IP addr del 192.168.1.2/24 dev eth0 label eth0:0[[email protected] ~]# IP addr Show Eth02:eth0: &L T Broadcast,multicast,up,lower_up> MTU Qdisc pfifo_fast State UNKNOWN Qlen-Link/ether 00:0c:29:7a:e4:0e BRD FF:FF:FF:FF:FF:FF inet 192.168.1.110/24 Scope global eth0 inet6 fe80::20c:29ff:fe7a:e40e/64 scope link valid_ LfT Forever Preferred_lft Forever


Add an IP address on the eth0:

[[Email protected] ~]# IP addr Add dev eth0 192.168.1.23/24[[email protected] ~]# IP addr Show Eth02:eth0: <broadcast, Multicast,up,lower_up> MTU Qdisc pfifo_fast State UNKNOWN Qlen-link/ether 00:0c:29:7a:e4:0e BRD ff:ff:ff:f F:FF:FF inet 192.168.1.110/24 Scope global eth0 inet 192.168.1.23/24 scope Global secondary eth0


Clear protocol Address:

[Email protected] ~]# ip-4 addr Flush Label "eth0"

Note After clearing the SSH login will be broken, you need to add the IP address on the machine's virtual terminal or restart the Network service to new link to the terminal.


3, the use of IP route command

Set the route to the network 192.168.1.0/24 through the gateway 192.168.1.1

[[Email protected] ~]# IP route add 196.168.1.0/24 via 192.168.1.1[[email protected] ~]# IP route192.168.1.0/24 Dev eth0 Proto kernel scope link src 192.168.1.110196.168.1.0/24 via 192.168.1.1 dev eth0169.254.0.0/16 dev eth0 scope link met Ric 1002default via 192.168.1.1 Dev eth0


Remove the gateway that you added in the previous example:

[[Email protected] ~]# IP route del 196.168.1.0/24 via 192.168.1.1[[email protected] ~]# IP route192.168.1.0/24 Dev eth0 Proto kernel scope link src 192.168.1.110169.254.0.0/16 dev eth0 scope link metric 1002default via 192.168.1.1 Dev ETH 0


Remove all gateway routes in the routing table:

[[email protected] ~]#  ip -4 ro  Flush scope global type unicast[[email protected] ~]# route -nkernel  IP routing tableDestination     Gateway          Genmask         Flags Metric  ref    use iface192.168.1.0     0.0.0.0          255.255.255.0   U     0       0        0 eth0169.254.0.0      0.0.0.0         255.255.0.0      U     1002   0         0 e 


Get a single routed IP route get:

Use this command to obtain a route to the destination address and its exact contents. The IP route get command and the IP Route show command perform different actions. The IP route Show command simply shows the existing route, and the IP route get command will derive a new route if necessary.

To search for routes to 61.135.169.125 :

[[Email protected] ~]# IP route get 61.135.169.125 61.135.169.125 via 192.168.1.1 dev eth0 src 192.168.1.110 cache MTU ADVMSS 1460 Hoplimit 64

Learning from the above three commands can be seen in the use of IP commands instead of ifconfig, route and other commands, but because we are accustomed to using ifconfig, the route command and the use of IP command complexity, here is to suggest beginners or use the old command, With some experience, you will learn to use IP commands. As the IP command used in this article is relatively simple, if you want to continue to learn the following article is written or more detailed, suggest to see.




Http://www.cnblogs.com/bamboo-talking/archive/2013/01/10/2855306.html






This article is from the "Bread" blog, make sure to keep this source http://cuchadanfan.blog.51cto.com/9940284/1674241

Linux System network commands (II)

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.