iproute2
From Noah.org
Jump to navigationJump to search
Contents
add an IP address to an interface
ip addr add \ local 10.10.10.17/32 \ dev eth0
show IP addresses assigned to an interface
ip addr show
delete an IP address from an interface
ip addr del \ local 10.10.10.17/32 \ dev eth0
default gateway route
This requires two steps.
ip route add \ 10.10.10.0/24 \ dev eth0 ip route add \ default via \ 10.10.10.1
virtual interfaces
The iproute2 system does not need the idea of a virtual interface. Instead, you can simply add additional IP addresses to an existing interface.
ip addr add \ local 10.10.10.17/32 \ dev eth0 ip addr add \ local 10.10.10.18/32 \ dev eth0 ip addr add \ local 10.10.10.19/32 \ dev eth0
labeling virtual interfaces for compatibility with `ifconfig`
Note that the `ifconfig -a` command will not show these additional IP addresses unless they are labeled. They don't show up as additional IP addresses on an interface, and they don't show up as separate virtual interfaces. This is be confusing.
You can label an IP address. If the label is unique, then it will show up under `ifconfig -a` as a separate interface. The following will show up under `ifconfig -a`.
ip addr add \ local 10.10.10.17/32 \ dev eth0 \ label eth0:1 ip addr add \ local 10.10.10.18/32 \ dev eth0 \ label eth0:2 ip addr add \ local 10.10.10.19/32 \ dev eth0 \ label eth0:3