From Gentoo Wiki
Jump to:navigation Jump to:search
This page contains changes which are not marked for translation.

iproute2 is a tool developed to unify network interface configuration, routing, and tunneling for Linux systems.

iproute2 provides the ip command for this purpose.


USE flags

USE flags for sys-apps/iproute2 kernel routing and traffic control utilities

atm Enable Asynchronous Transfer Mode protocol support
berkdb build programs that use berkdb (just arpd)
bpf Use dev-libs/libbpf
caps Use Linux capabilities library to control privilege
elf support loading eBPF programs from ELFs (e.g. LLVM's eBPF backend)
iptables include support for iptables filtering
minimal only install ip and tc programs, without eBPF support
nfs Support RPC lookups via net-libs/libtirpc in ss
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
split-usr Enable behavior to support maintaining /bin, /lib*, /sbin and /usr/sbin separately from /usr/bin and /usr/lib*


sys-apps/iproute2 is part of the system set.

root #emerge --ask sys-apps/iproute2


IPv4 and IPv6 support

iproute2 supports both IP address families, IPv4 and IPv6. By default the ip command refers only to IPv4 protocol, explicit IP address family namimng for IPv4 ip -4 is also possible. IPv6 uses the ip -6 command.

Listing interfaces

Use ip link for displaying the interface link of all interfaces:

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 for displaying all IP information of all interfaces, or use ip address show for displaying the configuraton of a specific interface with assigned IP address:

user $ip addr show wlan0
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 brd 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 wlan0 down
root #ip link set eth0 up

Configuring IP addressing

Removing IP addressesing from the wlan0 interface:

root #ip addr del dev wlan0

Adding IP addressing to the eth0 interface:

root #ip addr add dev eth0
root #ip -6 addr add 2001:db8::11/64 dev eth0

Configure IP routing

Adding IP default route for both IP address families, IPv4 and IPv6:

root #ip route add default via
root #ip -6 route add default via fe80::1

Display the IPv4 routing table information:

user $ip route
default via dev eth0  metric 2 via dev lo dev eth0  proto kernel  scope link  src

Display the IPv6 routing table information:

user $ip -6 route
2001:db8::10/64 dev eth0  proto kernel  metric 2003  mtu 1492
fe80::/64 dev eth0  proto kernel  metric 256  pref medium
ff00::/8 dev eth0  metric 256  
default via fe80::1 dev eth0  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 to iproute2 command equivalents
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 -g ip maddr
netstat -i ip -s link
netstat -r ip route
iptunnel ip tunnel
ipmaddr ip maddr
tunctl ip tuntap[1]
(none) for interface rename ip link set dev OLDNAME name NEWNAME
brctl bridge[2]

See also

  • Static routing — covers routing of the IP protocol in the Linux kernel.

External resources


  1. Since iproute-2.6.34
  2. Since iproute-3.5.0