标签:
ip 命令的语法
ip [OPTIONS] OBJECT {COMMAND | help}OPTIONS是修改ip行为或者改变其输出的选项。
-V : 打印ip的版本并退出 -s :输出更为详细的信息。如果这个选项出现两次或者多次,输出的信息将更为详细。 -f : 这个选项后接协议种类,包括 inet、inet6、link。表明强调使用的协议种类。(link代表不涉及任何网络协议)。 -4 :是-f inet 的简写。 -6 :是-f inet6 的简写。 -0 :是-f link 的简写。 -o :对每条记录都使用单行输出。 -r :查询域名解析系统,用获得的主机名代替主机IP地址。
link :网络设备 address : 一个设备的协议(IP 或 IPV6)地址。 neighbour:ARP或者NDISC缓冲区条目。 route :路由表条目。 maddress :多播地址。 mroute :多播路由缓冲区条目。 tunnel : IP上的通道。COMMAND 针对指定对象执行的操作,它和对象的类型有关。一般情况下,支持对象的增加(add)、删除(delete)和展示(show或者list)。可以使用 ip OBJECT help 命令查看这个对象支持的操作和语法。
示例说明:
$ ip help Usage: ip [ OPTIONS ] OBJECT { COMMAND | help } ip [ -force ] -batch filename where OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable | tunnel | tuntap | maddr | mroute | mrule | monitor | xfrm | netns } OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] | -f[amily] { inet | inet6 | ipx | dnet | link } | -l[oops] { maximum-addr-flush-attempts } | -o[neline] | -t[imestamp] | -b[atch] [filename] | -rc[vbuf] [size]} ## 列出ip命令的信息。
$ ip link help Usage: ip link add [link DEV] [ name ] NAME [ txqueuelen PACKETS ] [ address LLADDR ] [ broadcast LLADDR ] [ mtu MTU ] type TYPE [ ARGS ] ip link delete DEV type TYPE [ ARGS ] ip link set { dev DEVICE | group DEVGROUP } [ { up | down } ] [ arp { on | off } ] [ dynamic { on | off } ] [ multicast { on | off } ] [ allmulticast { on | off } ] [ promisc { on | off } ] [ trailers { on | off } ] [ txqueuelen PACKETS ] [ name NEWNAME ] [ address LLADDR ] [ broadcast LLADDR ] [ mtu MTU ] [ netns PID ] [ netns NAME ] [ alias NAME ] [ vf NUM [ mac LLADDR ] [ vlan VLANID [ qos VLAN-QOS ] ] [ rate TXRATE ] ] [ master DEVICE ] [ nomaster ] ip link show [ DEVICE | group GROUP ] TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | can | bridge } ##列出link对象支持的动作以及语法信息。
$ ip link show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:46:6d:ae brd ff:ff:ff:ff:ff:ff ##展示 设备eth0 的基本信息
$ ip -s link show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:46:6d:ae brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 4111724 8814 0 1 0 290 TX: bytes packets errors dropped carrier collsns 131499 1339 0 0 0 0 ##展示 设备eth0 的详细信息
$ ip -s -s link show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:46:6d:ae brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 4111908 8816 0 1 0 290 RX errors: length crc frame fifo missed 0 0 0 0 0 TX: bytes packets errors dropped carrier collsns 131499 1339 0 0 0 0 TX errors: aborted fifo window heartbeat 0 0 0 0 ##展示 设备eth0 更为详细的信息
$ 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 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:46:6d:ae brd ff:ff:ff:ff:ff:ff inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 inet6 fe80::a00:27ff:fe46:6dae/64 scope link valid_lft forever preferred_lft forever ## 显示ip地址
$ sudo ip addr add 10.0.2.14/24 brd + dev eth0 ## 在以太网接口eth0上增加一个地址 10.0.2.14。掩码长度为24位(255.255.255.0)标准广播地址。 $ ip addr show dev eth0 ##查看添加后的地址 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:46:6d:ae brd ff:ff:ff:ff:ff:ff inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 inet 10.0.2.14/24 brd 10.0.2.255 scope global secondary eth0 inet6 fe80::a00:27ff:fe46:6dae/64 scope link valid_lft forever preferred_lft forever $ sudo ip addr del 10.0.2.14/24 brd + dev eth0 ##删除 10.0.2.14 这个地址
标签:
原文地址:http://blog.csdn.net/u011641885/article/details/45818871