LinuxCommandLibrary

ip-addrlabel

Configure address selection policy labels

SYNOPSIS

ip addrlabel { add | change | replace | delete } label NUMBER prefix PREFIX [ dev STRING ]
ip addrlabel { list | flush } [ dev STRING ] [ label NUMBER ]
ip addrlabel { help }

PARAMETERS

add
    Add new label entry for prefix

change
    Change existing label for prefix

replace
    Add or replace label for prefix

delete
    Delete label entry for prefix

list
    List address labels (default action)

flush
    Flush address labels

label NUMBER
    Label number (0-15); required for add/change/replace/delete/list

prefix PREFIX
    IP prefix (IPv4/IPv6) to label; required for add/change/replace/delete

dev STRING
    Device name; optional, makes label device-specific

DESCRIPTION

The ip addrlabel command is part of the iproute2 suite and manages the kernel's address label table. This table assigns numeric labels (0-15) to IP prefixes, enabling policy-based routing decisions based on source addresses.

Address labels allow fine-grained control in multi-homed setups or complex networks. For example, label 10 might tag RFC1918 private addresses, influencing route selection via ip rule and ip route with selectors like from all lookup 100 iif lo fwmark 0x1 uidrange 0-65535.

Common operations include adding labels to prefixes (e.g., label 3 for 192.168.0.0/16), listing current labels per device, or flushing the table. Labels are device-specific and persist across reboots if configured in /etc/iproute2/rt_labels for human-readable names (e.g., "private" maps to 1).

Primarily used by advanced admins for traffic engineering, QoS, or failover without full VRFs. Requires root privileges and kernel support (CONFIG_IP_MULTIPLE_TABLES, CONFIG_IP_ROUTE_MULTIPATH). Output uses standard iproute2 formatting for scripting.

CAVEATS

Requires root privileges. Labels limited to 16 (0-15). Device-specific labels override global. No validation on prefix/label conflicts. Kernel must support multiple routing tables.

CONFIGURATION FILE

Label names defined in /etc/iproute2/rt_labels (e.g., private 1); loaded automatically.

EXAMPLE

ip addrlabel add 10 prefix 10.0.0.0/8 dev eth0
ip addrlabel list dev eth0

HISTORY

Introduced in iproute2 2.6.20 (2007) by Stephen Hemminger, aligning with kernel 2.6.20's rtable-based policy routing enhancements by Alexey Kuznetsov. Evolved with IPv6 support in later iproute2 releases; widely used in enterprise networking since Linux 3.x.

SEE ALSO

ip-address(8), ip-route(8), ip-rule(8), rtlabel(8)

Copied to clipboard