ip — Network Management Command

What is ip?

The ip command is a powerful, versatile tool used to configure and manage network interfaces, routes, IP addresses, and other network-related tasks on Linux systems. It is part of the iproute2 package, which provides modern tools for network management, replacing older tools like ifconfig, route, and netstat.

ip offers a wide range of functionalities for network configuration and troubleshooting, including the management of network interfaces, routing tables, network addresses, tunnels, and more.


Key Features of ip

  • Interface Management: View and modify network interfaces, assign IP addresses, bring interfaces up or down.

  • Routing: View and configure network routes and IP forwarding.

  • Network Address Management: Assign and remove IP addresses to network interfaces.

  • Multicast and Tunnels: Handle multicast addresses and set up network tunnels.

  • Advanced Options: Provides detailed control over various networking features, including link-layer configuration and quality of service.


Basic Syntax

ip [options] OBJECT {COMMAND | help}

Where:

  • OBJECT is the network object (e.g., link, addr, route).

  • COMMAND is the action you want to perform (e.g., show, add, del).


Common ip Subcommands

Used to manage network interfaces (e.g., Ethernet, Wi-Fi, virtual interfaces).

Example Commands

  • Show all network interfaces:

  • Bring an interface up:

  • Bring an interface down:

  • Change the MAC address of an interface:

  • Enable promiscuous mode:

2. ip addr — Manage IP Addresses

Used to manage IP addresses assigned to network interfaces.

Example Commands

  • Show all IP addresses:

  • Add an IP address:

  • Remove an IP address:

  • Assign an IP address with a specific scope:

3. ip route — Manage Routing Tables

Used to display and modify routing tables.

Example Commands

  • Show the routing table:

  • Add a route:

  • Delete a route:

  • Add a default route:

Used to change the settings of network interfaces (e.g., bring interfaces up/down, assign addresses).

Example Commands

  • Set an interface to promiscuous mode:

  • Set an interface to non-promiscuous mode:

  • Change interface MTU (Maximum Transmission Unit):

5. ip tunnel — Create Tunnels

Used to manage IP tunnels (e.g., GRE tunnels, IPsec tunnels).

Example Commands

  • Create a GRE tunnel:

  • Show tunnel information:

You can set various attributes of network interfaces, including the interface’s name, MTU, and MAC address.

Example Commands

  • Set a new name for the interface:


Example Use Cases

Use Case 1: Configuring a Static IP Address

To set a static IP address on a network interface:

  1. Assign the IP address:

  2. Bring the interface up:

  3. Add the default route:

Use Case 2: Setting Up a Virtual Network Interface

For setting up a virtual interface (e.g., eth0:0):

  1. Assign the IP address to the virtual interface:

  2. Bring the interface up:


Comparison with Older Tools

Feature

ip Command

ifconfig/route

Interface Management

Full-featured management

Limited functionality

IP Address Handling

Advanced capabilities

Basic address assignment

Routing

Advanced routing features

Limited routing features

Tunnels

Supports advanced tunnels (GRE, IPsec)

Limited tunnel support

Efficiency

Preferred tool for modern Linux setups

Deprecated and less efficient


Alternatives to ip

Tool
Description

ifconfig

Older tool for managing network interfaces, largely replaced by ip.

netplan

For managing network configuration in newer Ubuntu versions (YAML-based).

nmcli

NetworkManager's command-line interface for managing network connections.


Summary

Feature

ip Command

Purpose

Manage network interfaces, addresses, and routes on Linux

Common Use Cases

IP configuration, route management, interface management

Alternatives

ifconfig, nmcli, netplan, brctl

Key Commands

ip link, ip addr, ip route, ip tunnel


The ip command is a robust and modern tool for network configuration on Linux, offering extensive features for managing interfaces, IP addresses, routing, and more. It is the preferred tool for most modern Linux systems, providing superior functionality compared to older tools like ifconfig and route.

Last updated