iproute2
iproute2 is a tool developed to unify network interface configuration, routing, and tunneling for Linux systems.
iproute2 provides the ip command for this purpose.
Usage
Listing interfaces
Either ip link (shorthand) or ip link show (longhand) work for displaying the interface links:
user $
ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 00:22:68:13:da:7d brd ff:ff:ff:ff:ff:ff 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000 link/ether 00:1e:65:6b:ef:ca brd ff:ff:ff:ff:ff:ff
Showing IP addressing
Either ip addr (shorthand) or ip address show (longhand) work for displaying the interfaces with assigned IP addresses:
user $
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 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 valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 00:22:68:13:da:7d brd ff:ff:ff:ff:ff:ff 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000 link/ether 00:1e:65:6b:ef:ca brd ff:ff:ff:ff:ff:ff inet 192.0.2.10/24 brd 192.0.2.255 scope global wlan0 valid_lft forever preferred_lft forever
Activating interfaces
Interface links can be activated and deactivated (respectively) using the set subcommand:
root #
ip link set eth0 down
root #
ip link set eth0 up
Configuring IP addressing
Using the IPv4 protocol:
- Adding an IP address to the eth0 interface:
root #
ip addr add 192.0.2.11/24 dev eth0
- Removing an IP address from the wlan0 interface:
root #
ip addr del 192.0.2.10/24 dev wlan0
Using the IPv6 protocol:
- Add IPv6 address to wlan0 interface
root #
ip -6 addr add 2001:db8::10/64 dev wlan0
- Remove IPv6 address from eth0 interface
root #
ip -6 addr del 2001:db8::11/64 dev eth0
Adding default route
Using the IPv4 protocol:
root #
ip route add default via 192.0.2.1
Using IPv6 protocol:
root #
ip -6 route add default via fe80::1
Showing routing table
Display the IPv4 routing table information:
user $
ip route
default via 192.0.2.1 dev eth0 metric 2 127.0.0.0/8 via 127.0.0.1 dev lo 192.0.2.0/24 dev eth0 proto kernel scope link src 192.0.2.11
Display the IPv6 routing table information:
user $
ip -6 route
2001:db8::10/64 dev wlan0 proto kernel metric 2003 mtu 1492 fe80::/64 dev wlan0 proto kernel metric 256 pref medium ff00::/8 dev wlan0 metric 256 default via fe80::1 dev wlan0 metric 2003 mtu 1492
iproute2 for net-tools swappers
The following table can be used as a reference point for substituting commands from the sys-apps/net-tools package for the equivalent sys-apps/iproute2 commands:
net-tools | iproute2 |
---|---|
ifconfig (interface list) | ip link |
ifconfig (ip configuration) | ip addr |
ifconfig (interface stats) | ip -s link |
route | ip route |
arp | ip neigh |
brctl addbr | ip link add ... type bridge |
brctl addif | ip link set master |
netstat | ss |
netstat -M | conntrack -L |
netstat -g | ip maddr |
netstat -i | ip -s link |
netstat -r | ip route |
iptunnel | ip tunnel |
ipmaddr | ip maddr |
tunctl | ip tuntap (since iproute-2.6.34) |
(none) for interface rename | ip link set dev OLDNAME name NEWNAME |
brctl | bridge (since iproute-3.5.0) |
See also
- Static routing — covers routing of the IP protocol in the Linux kernel.