| |

LFCS 96 ๐Ÿง Network Interfaces โ€” ip addr

โฑ๏ธ Estimated read: 9 min | |

The ip command from the iproute2 suite has replaced the legacy ifconfig and route tools on virtually every modern Linux distribution. For the LFCS exam, ip addr is the essential tool for inspecting and modifying network interface addresses. The command operates on live kernel state, which means every change made with ip addr add or ip addr del is volatile and will not survive a reboot unless persisted through a network manager like NetworkManager or Netplan. Understanding this distinction between runtime configuration and persistent configuration is the difference between a working interface and a broken boot sequence.

Key point: ip addr manages protocol addresses on interfaces. It does not bring interfaces up or downโ€”that is the domain of ip link. An interface with an IP address but in a DOWN state cannot pass traffic.


Why ip addr exists

The ifconfig problem. The net-tools package, containing ifconfig, route, and arp, has not seen active development in decades. It cannot handle modern networking features like multiple addresses per interface with proper labeling, IPv6 privacy extensions, or network namespaces. The iproute2 suite was designed as a unified replacement, and ip addr is its address management component .

The multi-address problem. A single interface can have multiple IP addresses, and ifconfig handles this poorly through “aliases” like eth0:0. The ip addr command treats every address as a first-class citizen attached to the interface, with labels for backward compatibility and proper scoping for IPv6 .

The runtime persistence problem. Every change made with ip addr add modifies the running kernel state immediately. This is powerful for testing and troubleshooting, but dangerous if mistaken for a persistent configuration. A reboot wipes the change. The LFCS exam tests both the immediate command and the knowledge that persistence requires NetworkManager (nmcli), Netplan, or distribution-specific configuration files .

The IPv6 problem. IPv6 introduces concepts that ifconfig was never designed to handle: duplicate address detection (DAD), valid and preferred lifetimes, temporary privacy addresses, and scoped addresses (link, host, global). The ip addr command exposes these directly through flags like nodad, mngtmpaddr, and valid_lft .

The trade-off. ip addr has a steeper learning curve than ifconfig. The syntax is more structured (ip [object] [command]), and the output includes details that beginners may not need. The benefit is precision: every aspect of the address configuration is explicitly controllable.


a. Displaying interface addresses

The show subcommand (or no subcommand at all) lists the addresses attached to every interface. The output includes the interface name, its state, the MAC address, and every IPv4 and IPv6 address with its prefix length and scope.

# Show all addresses on all interfaces
ip addr show

# Shorthand
ip addr

# Show only IPv4 addresses
ip -4 addr show

# Show only IPv6 addresses
ip -6 addr show

# Show a specific interface
ip addr show dev enp0s3

The output for an interface in the UP state includes the inet line for IPv4 and inet6 lines for IPv6. An interface without an address shows only the link/ether line and is marked DOWN . The -c flag colorizes the output, which helps visually distinguish active from inactive interfaces .

The scope field is critical for IPv6. A link scope address is valid only on the local segment (e.g., fe80::/64). A global scope address is routable. A host scope address is valid only within the machine itself .


b. Adding and removing addresses

The add subcommand attaches a new address to an interface. The address must include the prefix length (/24 for IPv4, /64 for IPv6). Without it, the kernel may derive a default that is not what you intended.

# Add an IPv4 address
sudo ip addr add 192.168.1.100/24 dev enp0s3

# Add an IPv6 address
sudo ip addr add 2001:db8::1/64 dev enp0s3

# Add a secondary address with a label
sudo ip addr add 192.168.1.101/24 dev enp0s3 label enp0s3:1

The label option preserves compatibility with the old eth0:0 alias syntax. The label must begin with the interface name followed by a colon, and the total length cannot exceed 15 characters . This label is purely cosmetic for tools that still look for alias-style interfaces; the kernel treats the address as attached to the base interface.

Removing an address requires the exact address and prefix length that was added. If the prefix differs, the kernel will not find the address to delete.

# Remove an address
sudo ip addr del 192.168.1.100/24 dev enp0s3

# Flush all addresses from an interface
sudo ip addr flush dev enp0s3

The flush command removes every address from the interface without deleting the interface itself. This is useful when reconfiguring an interface but is dangerous if applied to the wrong device .


c. Advanced options and persistence

The ip addr command accepts options that modify the behavior of the address after it is added. These options are critical for IPv6 and for interfaces with specific routing requirements.

OptionEffect
nodadSkip Duplicate Address Detection (IPv6 only)
mngtmpaddrManage temporary privacy addresses from this template (IPv6)
noprefixrouteDo not automatically add a route for the prefix
valid_lftLifetime until the address is removed
preferred_lftLifetime until the address is no longer used for new connections

The valid_lft and preferred_lft options are particularly relevant for IPv6, where addresses have finite lifetimes defined by the router advertisement. Setting them manually overrides the kernel’s defaults .

Every change made with ip addr is runtime-only. To persist the configuration across reboots, the address must be configured through the system’s network manager. On systems using NetworkManager, nmcli is the tool. On Ubuntu systems using Netplan, the configuration is written to a YAML file under /etc/netplan/ and applied with netplan apply .

# NetworkManager: add a static address persistently
sudo nmcli connection modify "Wired connection 1" \
    +ipv4.addresses 192.168.1.100/24

# Netplan: edit the YAML file, then apply
sudo nano /etc/netplan/01-netcfg.yaml
sudo netplan apply

Complete Example Session

# ============================================
# PART 1: LIST ALL INTERFACES
# ============================================

ip addr show
# Output shows lo, enp0s3, and enp0s8.
# enp0s3 has an address; enp0s8 is DOWN.
# ============================================
# PART 2: INSPECT A SPECIFIC INTERFACE
# ============================================

ip addr show dev enp0s3
# Output includes inet 10.0.2.15/24 and link/ether.
# ============================================
# PART 3: ADD AN ADDRESS AT RUNTIME
# ============================================

sudo ip addr add 192.168.1.50/24 dev enp0s8
# The address is attached immediately.
# The interface is still DOWN until ip link set up.
# ============================================
# PART 4: BRING THE INTERFACE UP
# ============================================

sudo ip link set enp0s8 up
# The interface transitions to UP.
# ============================================
# PART 5: VERIFY THE NEW ADDRESS
# ============================================

ip addr show dev enp0s8
# Output shows inet 192.168.1.50/24 brd 192.168.1.255.
# ============================================
# PART 6: ADD A SECONDARY ADDRESS WITH LABEL
# ============================================

sudo ip addr add 192.168.1.51/24 dev enp0s8 label enp0s8:1
# The label preserves alias compatibility.
# ============================================
# PART 7: REMOVE AN ADDRESS
# ============================================

sudo ip addr del 192.168.1.50/24 dev enp0s8
# The address is removed from the interface.
# ============================================
# PART 8: FLUSH ALL ADDRESSES
# ============================================

sudo ip addr flush dev enp0s8
# All addresses are removed, but the interface remains UP.
# ============================================
# PART 9: PERSIST THE CONFIGURATION
# ============================================

# On NetworkManager systems:
sudo nmcli connection modify "Wired connection 1" \
    +ipv4.addresses 192.168.1.50/24
sudo nmcli connection up "Wired connection 1"

The nine parts trace the lifecycle: listing, inspecting, adding, bringing up, verifying, labeling, removing, flushing, and persisting. The critical distinction is between the runtime command and the persistent configuration.


Quick Reference

ip addr Commands

CommandPurpose
ip addr showList all addresses
ip addr show dev eth0Show one interface
ip -4 addr showIPv4 only
ip -6 addr showIPv6 only
ip addr add 192.168.1.1/24 dev eth0Add an address
ip addr del 192.168.1.1/24 dev eth0Remove an address
ip addr flush dev eth0Remove all addresses

Address Options

OptionScope
label eth0:0Alias compatibility
scope globalRoutable address
scope linkLink-local only
nodadSkip DAD (IPv6)
noprefixrouteNo automatic prefix route
valid_lft 3600Lifetime in seconds

Persistence Tools

ToolSystem
nmcliNetworkManager (RHEL, Fedora, modern Ubuntu)
netplanUbuntu (YAML under /etc/netplan/)
ifcfg filesOlder RHEL/CentOS (/etc/sysconfig/network-scripts/)

Best Practices

โœ… Do This:

ip addr add 192.168.1.50/24 dev enp0s8
<!-- Always include the prefix length -->            # โœ…
ip addr show dev enp0s8
<!-- Verify the address after adding -->             # โœ…
sudo nmcli connection modify ... +ipv4.addresses ...
<!-- Persist the configuration -->                   # โœ…

โŒ Don’t Do This:

ip addr add 192.168.1.50 dev enp0s8
<!-- Missing prefix length -->                       # โŒ
ip addr flush dev enp0s3
<!-- Flushing the primary interface kills connectivity --> # โŒ
# Assume ip addr add persists across reboot
<!-- Runtime changes are volatile -->                # โŒ

Common Pitfalls

PitfallWhy It HappensFix
Address lost after rebootRuntime-only changeConfigure with nmcli or Netplan
Interface DOWN despite addressip addr does not bring link upip link set dev up
Delete failsPrefix length mismatchUse the exact /prefix from ip addr show
Cannot reach gatewayMissing routeAdd route with ip route add
ifconfig not foundnet-tools not installedUse ip addr or install net-tools

Real-World Examples

1. Show All Addresses

ip addr show

2. Show IPv4 Only

ip -4 addr show

3. Add Address

sudo ip addr add 10.0.0.5/24 dev eth0

4. Add with Label

sudo ip addr add 10.0.0.6/24 dev eth0 label eth0:1

5. Remove Address

sudo ip addr del 10.0.0.5/24 dev eth0

6. Flush Interface

sudo ip addr flush dev eth0

7. Persist with nmcli

sudo nmcli con mod "eth0" +ipv4.addresses 10.0.0.5/24

8. Persist with Netplan

sudo netplan apply

9. Colorized Output

ip -c addr show

10. Check for Duplicate IPs

ip addr show | grep inet

Visual

ip addr vs ip link

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  ip link set enp0s8 up                       โ”‚
โ”‚  (Layer 2: administratively enables link)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  ip addr add 192.168.1.50/24 dev enp0s8      โ”‚
โ”‚  (Layer 3: assigns protocol address)         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Interface is UP with an address             โ”‚
โ”‚  Traffic can flow                            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

An address on a DOWN interface does nothing. The link must be enabled first.

Runtime vs Persistent

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  ip addr add 192.168.1.50/24 dev eth0        โ”‚
โ”‚  Immediate effect. Lost on reboot.           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  nmcli connection modify ...                 โ”‚
โ”‚  Stored in /etc/NetworkManager/              โ”‚
โ”‚  Applied at boot.                            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The two commands achieve the same runtime state, but only one survives a reboot.


Summary

ItemValue
Address displayip addr show
Address addip addr add /dev
Address removeip addr del /dev
Address fluship addr flush dev
IPv4 onlyip -4 addr
IPv6 onlyip -6 addr
Label syntaxlabel eth0:1
Persistencenmcli or Netplan
Runtime onlyYes (lost on reboot)

Key takeaways:

  • ip addr manages Layer 3 addresses. It does not bring interfaces up or downโ€”that is ip link .
  • Every change is runtime-only. Persistence requires NetworkManager (nmcli), Netplan, or distribution-specific files .
  • The prefix length is mandatory. Without it, the kernel may derive an unintended netmask.
  • Multiple addresses per interface are normal. Labels provide alias compatibility, but the kernel treats each address independently .
  • IPv6 addresses have lifetimes. valid_lft and preferred_lft control when the address expires and when it stops being used for new connections .

Remember: ip addr is the inspection and modification tool for protocol addresses. It is not the tool for bringing links up, adding routes, or persisting configuration. The LFCS exam tests the distinction: the command for the immediate change, and the command for the permanent change.

Was this helpful?


Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!