Iproute IP commands for Linux packages

Source: Internet
Author: User

[email protected] ~]# RPM-QF/SBIN/IP
iproute-2.6.32-31.el6.x86_64
IP is a command, there are many functions of IP command! Basically, it integrates the two commands of Ifconfig and route.
Ip-show/manipulate routing, devices, policy Routing and tunnels

IP [OPTIONS] OBJECT {COMMAND | help}

OBJECT: = {link | addr | addrlabel | route | rule | neigh | tunnel |
maddr | Mroute | Monitor}

OPTIONS: = {-v[ersion] |-s[tatistics] |-r[esolve] |-f[amily] {inet
| Inet6 | IPX | dnet | LINK} | -o[neline]}

[[Email protected] ~]# IP link
1:lo: <LOOPBACK,UP,LOWER_UP> MTU 16436 qdisc noqueue State UNKNOWN
Link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00
2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast State up Qlen 1000
Link/ether 00:0C:29:75:34:A5 BRD FF:FF:FF:FF:FF:FF
IP link
IP link can set settings related to devices (device), including the MTU and the MAC of the network device, and of course it can start (up) or shut down a network device.
IP link Set [device] [action and parameters] device refers to eth0, ETH1, etc. device code
Up|down: Start (UP) or off (down) a device, other parameters using preset Ethernet parameters;
Address: If this device can change MAC, use this parameter to modify;
Name: Give this device a special name;
MTU: Sets the maximum transmission unit.
[[Email protected] ~]# IP link set eth0 up
# start eth0 this device;
[[Email protected] ~]# IP link set eth0 down
# close eth0 this device;
[[Email protected] ~]# IP link set eth0 MTU 1000
# change the MTU to bytes, the unit is bytes.
IP link set eth0 address Aa:aa:aa:aa:aa:aa
[Email protected] ~]# ip-s link
1:lo: <LOOPBACK,UP,LOWER_UP> MTU 16436 qdisc noqueue State UNKNOWN
Link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00
Rx:bytes packets Errors dropped overrun Mcast
108016 473 0 0 0 0
Tx:bytes packets errors dropped carrier Collsns
108016 473 0 0 0 0
2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast State up Qlen 1000
Link/ether 00:0C:29:75:34:A5 BRD FF:FF:FF:FF:FF:FF
Rx:bytes packets Errors dropped overrun Mcast
23016263 27785 0 0 0 0
Tx:bytes packets errors dropped carrier Collsns
2402975 17084 0 0 0 0

[[Email protected] ~]# IP addr
1:lo: <LOOPBACK,UP,LOWER_UP> MTU 16436 qdisc noqueue State UNKNOWN
Link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00
inet 127.0.0.1/8 Scope host Lo
INET6:: 1/128 Scope Host
Valid_lft Forever Preferred_lft Forever
2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast State up Qlen 1000
Link/ether 00:0C:29:75:34:A5 BRD FF:FF:FF:FF:FF:FF
inet 192.168.2.128/24 BRD 192.168.2.255 Scope Global eth0
Inet6 FE80::20C:29FF:FE75:34A5/64 Scope link
Valid_lft Forever Preferred_lft Forever

IP addr
If IP link is related to the second layer of data link layer of the OSI layer seven model, then IP address (IP addr) is related to the third layer of network layer. Mainly in the setting of IP-related parameters, including netmask, broadcast and so on.
IP address [add|del] [IP parameters] [dev device name] [related parameters]
IP parameters: Mainly the setting of the domain, such as 192.168.100.100/24
The relevant parameters are as follows:
Broadcast: Set the broadcast address, if the setting value is + means let the system automatically calculate;
Label: the alias of the device, such as eth0:0;
Scope: The realm of this device, usually the following major categories:
Global: Allow connections from all sources;
Site: Only support IPV6, only allow the connection of the host;
Link: Only allow the device to self-connect;
Host: Allow only internal connections to the host;
So of course it's using global. Presets are also global!
IP addr Add 192.168.50.50/24 dev eth1
IP addr del 192.168.50.50/24 dev eth1

[[email protected] ~]# IP addrlabel
Prefix:: 1/128 label 0
Prefix::/96 label 3
Prefix:: ffff:0.0.0.0/ 4 label
Prefix 2001::/32 label 6
prefix 2001:10::/28 label 7
prefix 2002::/16 label 2
prefix FC00::/7 label 5
Prefix::/0 Label 1

[[email protected] ~]# IP rule
0:      from all lookup Local
32766:  from any lookup main
32767:  from all lookup default

[[email protected] ~]# IP Neigh
192.168.2.190 Dev eth0 lladdr 6c:fd:b9:3b:57:ff REACHABLE
192.168.2.2 Dev eth0 lladdr 50:46:5d:b9:cd:68 REACHABLE

[[email protected] ~]# ip-s neigh
192.168.2.190 dev eth0 lladdr 6c:fd:b9:3b:57:ff ref 3 used 58/ 0/2 REACHABLE
192.168.2.2 dev eth0 lladdr 50:46:5d:b9:cd:68 ref + used 102/102/82 STALE

[[email protected] ~]# IP route
192.168.50.0/24 dev eth1  proto kernel  scope link  src 192.168 .50.50
192.168.2.0/24 Dev eth1  proto kernel  scope link  src 192.168.2.131  metric 1
Default V ia 192.168.2.2 dev eth1  proto static
IP route
Proto: Routing contract for this route, mainly redirect, kernel, boot, static, RA, etc., where Kern El refers to the automatic setting directly from the core judgment.
Scope: The scope of the route, mainly link, is a direct connection to this device.
IP route add 192.168.5.0/24 dev eth0 Direct connect segment
IP route add 192.168.10.0/24 via 192.168.5.100 dev eth0 non-direct network segment

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.