ip

networkingLinux
The ip command is one of the most frequently used commands in Linux/Unix-like operating systems. ip Show / manipulate routing, network devices, interfaces and tunnels

Quick Reference

Command Name:

ip

Category:

networking

Platform:

Linux

Basic Usage:

ip [options] [arguments]

Common Use Cases

    Syntax

    ip [options] object [command [arguments]]

    Options

    Option Description
    -V, -Version Print the version of ip utility and exit
    -s, -stats, -statistics Output more information. If the option appears twice or more, the amount of information increases
    -d, -details Output more detailed information
    -h, -human, -human-readable Output statistics with human-readable values followed by suffix
    -r, -resolve Use the system's resolver to print DNS names instead of IP addresses
    -f, -family Specify the protocol family: inet, inet6, bridge, mpls, link
    -4 Shortcut for -family inet
    -6 Shortcut for -family inet6
    -B Shortcut for -family bridge
    -M Shortcut for -family mpls
    -0 Shortcut for -family link
    -o, -oneline Output each record on a single line, replacing line feeds with the '\' character
    -n, -netns Switch to the specified network namespace
    -a, -all Execute the command for all objects
    -c, -color Use color in output
    -t, -timestamp Display current time with each output line
    -b, -batch filename Read commands from a file or stdin and invoke them

    Examples

    How to Use These Examples

    The examples below show common ways to use the ip command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    ip address show
    Display information about all network interfaces.
    ip link show
    Display information about all network devices.
    ip route show
    Display the routing table. # Advanced Examples Advanced ip -s link show Display statistics for all network interfaces. ip address add 192.168.1.10/24 dev eth0 Add an IP address to the eth0 interface. ip link set eth0 up Bring the eth0 interface up. ip link set eth0 down Bring the eth0 interface down. ip route add default via 192.168.1.1 dev eth0 Add a default route via 192.168.1.1 through eth0. ip neighbor show Display the ARP table (neighbor cache). ip -6 address show Display IPv6 addresses for all interfaces. ip -4 route add 10.0.0.0/8 via 192.168.1.254 Add a route to the 10.0.0.0/8 network via the gateway 192.168.1.254. ip tunnel add mytunnel mode gre remote 10.0.0.1 local 10.0.0.2 Create a GRE tunnel named mytunnel between 10.0.0.1 and 10.0.0.2.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The ip command is a powerful and versatile network configuration tool in Linux that is part of the iproute2 package. It replaces older networking commands like ifconfig, route, and arp with a unified interface for managing most aspects of network configuration. Key features of ip: 1. Comprehensive Network Management: The ip command can configure network interfaces, routing tables, ARP tables, network tunnels, and more, all through a single command-line interface. 2. Object-Based Structure: The command uses a hierarchical, object-based approach where the first argument specifies the object type (address, link, route, etc.), followed by the action and additional parameters. 3. Network Namespace Support: It can manage networking in different network namespaces, which is essential for containerization and network virtualization. 4. IPv6 Support: ip fully supports IPv6 addressing and routing, with consistent command syntax between IPv4 and IPv6 operations. 5. Advanced Routing Capabilities: Beyond basic routing, ip supports policy-based routing, multipath routing, and traffic control. 6. Detailed Network Information: It can provide extensive statistics and detailed information about network interfaces and connections. 7. Tunnel Management: ip can create and manage various tunnel types like GRE, IPIP, and SIT for connecting disparate networks. Common object types include: - address (or addr): IP address management - link: Network device management - route: Routing table management - neighbor (or neigh): ARP or NDISC cache management - tunnel: Tunnel configuration - maddress (or maddr): Multicast address management - rule: Routing policy database management The ip command is essential for modern Linux system administration, especially for: - Server configuration and troubleshooting - Network performance tuning - Setting up virtual private networks (VPNs) - Configuring complex network topologies - Container networking - Software-defined networking While it has a steeper learning curve than older networking commands, ip's consistent syntax and comprehensive capabilities make it the preferred tool for network configuration in current Linux distributions.

    Related Commands

    These commands are frequently used alongside ip or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the ip command works in different scenarios.

    $ ip
    View All Commands