Skip to content

ip Linux Command Guide

The ip command in Linux is a versatile tool used to manage network configurations. It allows users to display, configure, and manage network interfaces, IP addresses, routes, and more. With ip, you can troubleshoot network issues, set up virtual interfaces, assign multiple IP addresses to a single interface, and manage routing tables effectively. This command replaces the older ifconfig and route commands, providing a more robust and modern solution for configuring network settings in Linux distributions.

ip Syntax:

Terminal window
ip [options] [parameters]

Options:

OptionDescription
linkNetwork device-specific operations
addressAddress-specific operations
routeRouting table-specific operations
neighborNeighbor-specific operations
-sDisplay short output
-hDisplay help message

Parameters:

ParameterDescription
addressTarget IP address
interfaceInterface name or id
networkNetwork name or IP address
showDisplay specific information
helpDisplay help message

ip Command Samples:

Display Network Interfaces

Terminal window
ip address show

Shows the configuration of all network interfaces on the system.

Assign an IP Address to an Interface

Terminal window
ip address add 192.168.1.10/24 dev eth0

Assigns the IP address “192.168.1.10” with a subnet mask of 24 to the interface “eth0”.

Bring Down an Interface

Terminal window
ip link set eth0 down

Brings down the network interface “eth0”.

Display the Routing Table

Terminal window
ip route show

Displays the current routing table of the system.

Add a Static Route

Terminal window
ip route add 192.168.2.0/24 via 192.168.1.1

Adds a static route for the network “192.168.2.0/24” via the gateway “192.168.1.1”.

Flush ARP Cache

Terminal window
ip neigh flush all

Flushes the ARP cache, removing all entries.

Manage IPv6 Addresses

Terminal window
ip -6 address show

Displays IPv6 addresses and related information for all interfaces.

ip FAQ:

How do I use ip in Linux?

To use the ip command in Linux, execute the following command:

Terminal window
ip --option <value>

How can I display information about network interfaces using ip?

You can display information about network interfaces using the following ip command:

Terminal window
ip addr show

How do I add a new IP address to a network interface with ip in Linux?

To add a new IP address to a network interface using the ip command, run the following command:

Terminal window
ip addr add <ip_address>/<subnet_mask> dev <interface>

How can I list all the routes with ip in Linux?

To list all the routes using the ip command in Linux, use the following command:

Terminal window
ip route show

How do I delete an IP address from a network interface with ip?

To delete an IP address from a network interface using the ip command, you can use the following command:

Terminal window
ip addr del <ip_address>/<subnet_mask> dev <interface>

How can I flush all IP addresses of a network interface with ip in Linux?

To flush all IP addresses of a network interface using the ip command, you can run the following command:

Terminal window
ip addr flush dev <interface>

Applications of the ip command

  • Assigning an IP address to a network interface
  • Bringing up or taking down a network interface
  • Displaying information about network interfaces
  • Managing routing tables and rules
  • Setting up virtual network interfaces
  • Managing ARP cache
  • Managing Multicast addresses
  • Managing tunneling interfaces