function::addr - Linux


Overview

The addr command is a powerful network administration tool used to display or modify the network address, hardware address, and routing tables for a specified network interface. It allows network administrators to configure and manage network settings, diagnose network issues, and troubleshoot routing problems.

Syntax

addr [options] [interface]

Options/Flags

  • -d, –down: Bring the specified interface down.
  • -h, –help: Display help message and exit.
  • -r, –routes: Display the routing table for the specified interface.
  • -v, –verbose: Enable verbose output, providing more detailed information.

Examples

Display the network address for eth0:

addr eth0

Bring down the eth0 interface:

addr -d eth0

Display the routing table for all interfaces:

addr -r

Modify the network address for eth0:

addr -d eth0
addr eth0 192.168.1.100/24

Common Issues

  • Interface Not Found: Ensure the specified interface exists and is correctly configured.
  • Permission Denied: You may need to run the command as a privileged user (e.g., root).
  • Routing Table Not Available: The specified interface may not have a valid routing table. Use the -v option for more information.

Integration

The addr command can be combined with other network tools to perform advanced tasks:

  • ip: To set up network interfaces and manage IP addresses.
  • route: To manipulate the kernel routing table.
  • traceroute: To trace the path of network packets to a destination.

Related Commands

  • ifconfig
  • netstat
  • route