ip
ip shows and manipulates routing, devices, policy routing and tunnels.[1]
Documentation
- man 8 'ip' [EN]
Syntax
ifconfig SUBCOMMAND [SUBCOMMAND ...] OBJECT
Subcommands & Parameters
- -4
- Shortcut for -family 'inet'.
- -6
- Shortcut for -family 'inet6'.
- -f FAMILY, -family FAMILIY
- Followed by protocol FAMILIY identifier: inet, inet6 or link, enforce the protocol family to use. If the option is not present, the protocol family is guessed from other arguments. If the rest of the command line does not give enough information to guess the family, ip falls back to the default one, usually inet or any. link is a special family identifier meaning that no networking protocol is involved.
- address, addr
- The ip addr command displays addresses and their properties, adds new addresses and deletes old ones.
- add
- Add new protocol address.
- dev DEVICE
- The name of the device to add the address to.
- local ADDRESS
- The address of the interface. The format of the address depends on the protocol. It is a dotted quad for IP and a sequence of hexadecimal halfwords separated by colons for IPv6. The ADDRESS may be followed by a slash and a decimal number which encodes the network prefix length.
- peer ADDRESS
- The address of the remote endpoint for pointopoint interfaces.
- broadcast ADDRESS
- The broadcast address on the interface.
- label NAME
- Each address may be tagged with a label string.
- del
- Delete protocol address.
- show, list, ls
- Look at protocol addresses.
- dev DEVICE
- Name of device.
- link
- link is a network device and the corresponding commands display and change the state of devices.
- set
- Change device attributes.
- dev DEVICE
- DEVICE specifies network device to operate on.
- arp on, arp off
- Change the NOARP flag on the device.
- mtu AMOUNT
- Change the MTU of the device.
- up, down
- Change the state of the device to UP or DOWN.
- show, list, ls
- Display device attributes.
- dev DEVICE
- DEVICE specifies the network device to show. If this argument is omitted all devices are listed.
- up
- Only display running interfaces.
- route, ro, r
- Manipulate route entries in the kernel routing tables keep information about paths to other networked nodes.
- add
- Add new route.
- change
- Change route.
- dev DEVICE
- The output device name.
- to TYPE PREFIX
- The destination prefix of the route. If TYPE is omitted, ip assumes type unicast. Other values of TYPE are listed above. PREFIX is an IP or IPv6 address optionally followed by a slash and the prefix length. If the length of the prefix is missing, ip assumes a full-length host route. There is also a special PREFIX default - which is equivalent to IP 0/0 or to IPv6 ::/0.
- via ADDRESS
- The address of the nexthop router. Actually, the sense of this field depends on the route type.
- del
- Delete route.
- show
- List routes.
- all
- List all of the tables.
Examples
- Show IP information of eth0
ip addr show dev 'eth0'
Output:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 00:0c:29:80:79:9e brd ff:ff:ff:ff:ff:ff
inet 194.191.40.176/26 brd 194.191.40.191 scope global eth0
inet6 fe80::20c:29ff:fe80:799e/64 scope link
valid_lft forever preferred_lft forever
- Set IP address of eth0
ip addr add '192.168.1.100/24' dev 'eth0' brd '+'
- Show link information of eth0
ip link show dev 'eth0'
Output:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 00:0c:29:80:79:9e brd ff:ff:ff:ff:ff:ff
- Set MTU of eth0
ip link set 'eth0' mtu 1400
- Set route to 192.168.100.0/24 over eth0
ip route add to '192.168.100.0/24' via '192.168.1.1' dev 'eth0'
References
- ↑ man 8 'ip'