Linux Command ip, linux Command ip
Ip command syntax
ip [OPTIONS] OBJECT {COMMAND | help}
OPTIONS is an option for modifying ip behavior or changing its output.
-V: print the ip version and exit-s: output more detailed information. If this option appears twice or multiple times, the output information is more detailed. -F: This option is followed by the protocol types, including inet, inet6, and link. Indicates the protocol type that is emphasized. (Link indicates that no network protocol is involved ). -4: Short for-f inet. -6: Short for-f inet6. -0: Short for-f link. -O: a single row output is used for each record. -R: queries the domain name resolution system and replaces the Host IP address with the obtained host name.
An OBJECT is an OBJECT for managing or retrieving information.
Link: network device address: the protocol (IP or IPV6) address of a device. Neighbor: ARP or NDISC buffer entry. Route: route table entry. Maddress: multicast address. Mroute: the entry of the multicast routing buffer. Tunnel: the channel on the IP address.
The operation that the COMMAND performs on a specified object. It is related to the object type. Generally, you can add, delete, and show objects ). You can use the ip OBJECT help command to view the operations and syntaxes supported by this OBJECT.
Example:
$ Ip help Usage: ip [OPTIONS] OBJECT {COMMAND | help} ip [-force]-batch filenamewhere 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] }## list ip command information.
$ Ip link helpUsage: ip link add [link DEV] [name] NAME [txqueuelen PACKETS] [address LLADDR] [broadcast LLADDR] [mtu MTU] type [ARGS] ip link delete dev 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 group] TYPE: = {vlan | veth | vcan | dummy | ifb | macvlan | can | bridge }## list the actions and syntax information supported by the link object.
$ Ip link show eth02: 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 # display the basic information of the eth0 Device
$ Ip-s link show eth02: 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 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 # display device eth0 details
$ Ip-s link show eth02: 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 RX: bytes packets errors dropped overrun mcast 4111908 8816 0 1 0 290 RX errors: length crc frame fifo missed 0 0 0 0 TX: bytes packets errors dropped carrier collsns 131499 1339 0 0 0 TX errors: aborted fifo window heartbeat 0 0 0 # display more detailed information about the device eth0
$ Ip addr1: lo: <LOOPBACK, UP, LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00: 00: 00: 00: 00 brd 00: 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 forever2: 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 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 # display IP Address
$ Sudo ip addr add 10.0.2.14/24 brd + dev eth0 # add an address 10.0.2.14 to the Ethernet interface eth0. The mask length is 24 bits (255.255.255.0) Standard broadcast address. $ Ip addr show dev eth0 # view the added address 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 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 # Delete 10.0.2.14