This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

iproute2

From Gentoo Wiki (test)
Jump to:navigation Jump to:search

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

iproute2 provides the ip command for this purpose.

Ethernet interface configuration

List available 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

Show IP address

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

Activate eth0 interface

root #ip link set eth0 up

Configure IP address on interface

Using IPv4 protocol:

  • Add IP address to eth0 interface
root #ip addr add 192.0.2.11/24 dev eth0
  • Remove IP address from wlan0 interface
root #ip addr del 192.0.2.10/24 dev wlan0

Using 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

Add default route

Using IPv4 protocol:

root #ip route add default via 192.0.2.1

Using IPv6 protocol:

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

Show IP routing table

Show IP routing table:

user $ip route show
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

Show IPv6 routing table:

user $ip -6 route show
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

iproute2 for net-tools swappers
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

See also

External resources