« Previous 1 2 3 4 Next »
Network management with the IPRoute2 toolbox
A Well-Stocked Toolbox
Managing IP Addresses
To assign an additional IP address of 172.16.55.1/24
to the interface eth0
, you would issue the following command:
ip address add 172.16.55.1/24 brd 172.16.55.255 dev eth0
The specification of the broadcast address (brd
) is optional, but still recommended. To remove the assignment of an IP address from an interface, you need the del
option, as the following example shows:
ip address del 172.16.55.1/24 dev eth0
The flush
option takes a somewhat harder line here, and it also lets you remove all the IP addresses from an interface. To remove all IP addresses from the interface eth0
, you can enter:
ip address flush dev eth0
This condition persists until the interface is reinitialized. Also, DHCP-based interfaces do not immediately pick up a new address after their previous address is removed.
The important thing is that this kind of IP address manipulation for an interface does not end up in the configuration file. After reinitializing the interface or restarting the system, the changes made by ip
are no longer available. If you want them to stick, you need to create a startup script.
Predestined for IPv6
The ip
command lets you view and manipulate the advanced features of IPv6. This includes, for example, the prefix policy as per RFC 3484, which defines the rules by which the various IPv6 addresses are used. This policy can be displayed by typing ip addrlabel
or ip addrl
(Figure 2). The label determines the priority of each address. The well-known IPv6 prefixes are used here.
Because the various IPv6 addresses assigned to an IPv6-enabled interface have a different scope, the labels ensure that an IPv6 packet uses a sender address that matches the destination address.
To do this, the label of a source address in an incoming packet is used to find a suitable local address that has the same scope.
For example, to add another entry for the prefix 2002::2/64
with a label of 99
to this prefix policy, you can use the following:
ip addrlabel add prefix 2002::2/64 label 99
Accordingly, you can do:
ip addrlabel del prefix 2002::2/64 label 99
to remove prefixes with their labels again.
One Level Down
Link-layer information, that is, MAC addresses and the like, is handled by the link
option. For example, using ip link
or ip link show
shows you the low-level information about the interfaces (Figure 3) in a similar way to ip address
. Using
ip -s link show
gives you a statistical overview of the available interfaces, which can be limited by adding the interface again:
ip -s link show eth0
In a way that is almost typical of Linux, you can extend the output by adding another -s
. For example:
ip -s -s link show eth0
However, the combination of both -s
and -ss
is not possible.
The command ip link set
lets you set various hardware parameters for the interfaces. For example, you can shut down the eth0 interface with
ip link set eth0 down
and fire it up again with:
ip link set eth0 up
Additionally, you can manipulate the maximum transmission unit (MTU), the MAC address, promiscuous mode, and many other parameters.
« Previous 1 2 3 4 Next »