ip
Manage network interfaces, routing, and tunnels
TLDR
List interfaces with detailed info
List interfaces with brief network layer info
List interfaces with brief link layer info
Display the routing table
Show neighbors (ARP table)
Make an interface up/down
Add/Delete an IP address to an interface
Add a default route
SYNOPSIS
ip [ OPTIONS ] OBJECT { COMMAND | help }
Common Usage Examples:
ip link show
ip addr add 192.168.1.100/24 dev eth0
ip route show
ip neigh show
PARAMETERS
-V, -version
Displays the version of the ip utility.
-s, -stats, -statistics
Shows statistics for the object, such as packet counts or errors. Can be specified multiple times for more details.
-d, -details
Shows more detailed information about the object.
-n, -numeric
Prevents ip from resolving hostnames, user names, or service names to their numeric representations.
-o, -oneline
Outputs each record on a single line, useful for scripting.
-t, -timestamp
Displays a timestamp in front of each line of output.
-r, -resolve
Resolves hostnames and service names, opposite of -n.
-4, -6
Filters output to only show IPv4 or IPv6 addresses/routes, respectively.
-f, -family
Specifies the protocol family to use (e.g., inet for IPv4, inet6 for IPv6, bridge, link).
-netns
Executes the command within the specified network namespace.
OBJECT
The type of networking object to manage. Common objects include link (network interfaces), addr (IP addresses), route (routing table entries), neigh (ARP/NDP cache entries), netns (network namespaces), tunnel (IP tunnels), etc.
COMMAND
The action to perform on the specified OBJECT. Common commands include add (create), del (delete), show (display), set (modify), get (retrieve specific information), flush (clear).
DESCRIPTION
The ip command is a powerful, modern utility for configuring and managing network interfaces, routing tables, ARP entries, IP tunnels, and more on Linux systems. It is part of the iproute2 suite, which was developed to replace the older, less capable net-tools utilities like ifconfig, route, arp, and netstat. The ip command provides a unified and consistent interface for network configuration, addressing limitations of traditional tools, especially in handling advanced networking features such as policy routing, network namespaces, and traffic control.
Unlike its predecessors, ip operates on various "objects" (e.g., link for network interfaces, addr for IP addresses, route for routing tables) and performs specific "commands" (e.g., add, del, show, set) on them. This object-oriented approach makes it more versatile and scalable for complex network setups, making it the standard tool for network management in modern Linux distributions.
CAVEATS
Most operations with the ip command require root privileges to execute. Its comprehensive and object-oriented syntax can be complex for new users compared to older tools. The output, especially with detailed options, can be verbose and may require filtering with utilities like grep or awk to extract specific information.
KEY OBJECTS OF THE <I>IP</I> COMMAND
The ip command's power comes from its ability to interact with various network objects. The most frequently used objects are: link (manages network interfaces like adding/deleting virtual interfaces, changing interface state), addr (assigns/removes IP addresses to/from interfaces), route (manages the kernel's routing table, defining how packets are forwarded), and neigh (manages the ARP/NDP cache, mapping IP addresses to MAC addresses). Understanding these core objects is fundamental to using ip effectively.
NETWORK NAMESPACES (NETNS)
ip is instrumental in managing Linux network namespaces, a powerful virtualization feature that allows multiple independent network stacks to exist within a single Linux kernel instance. Each namespace has its own network interfaces, routing tables, and IP addresses, enabling containerization technologies like Docker and LXC. The ip netns command allows creation, deletion, and execution of commands within specific namespaces, making it crucial for network isolation and multi-tenant environments.
HISTORY
The iproute2 suite, which includes the ip command, was primarily developed by Alexey Kuznetsov, starting in the late 1990s. Its creation was driven by the need for more advanced networking capabilities in the Linux kernel that the traditional net-tools (ifconfig, route, arp, netstat) could not support effectively. These new capabilities included policy routing, Quality of Service (QoS), network namespaces, and more sophisticated interface management. Over the past two decades, iproute2 has become the standard and recommended way for Linux network configuration, replacing the older tools in most modern distributions.