Understanding the ip Command

Basic Usage of ip

The ip command is a versatile tool used to manage networking in Linux. It is part of the iproute2 package and replaces older commands like ifconfig. This command can configure network interfaces, manage routing, and more.

ip [OPTIONS] OBJECT {COMMAND | help}

Options Available with ip

OBJECTS

The ip command has several objects, including:

ip link

Manage network interfaces:

ip link [COMMAND]

ip addr

Manage IP addresses:

ip addr [COMMAND]

ip route

Manage routing tables:

ip route [COMMAND]

Common Commands

show

Display information:

ip link show

add

Add a new interface or address:

ip addr add 192.168.1.100/24 dev eth0

del

Delete an interface or address:

ip addr del 192.168.1.100/24 dev eth0

set

Set parameters for an interface:

ip link set dev eth0 up

link set

Change the state of a network interface:

ip link set eth0 down

Examples of ip Command

Display All Network Interfaces

ip link show

This command displays all network interfaces and their status.

Add an IP Address to an Interface

ip addr add 192.168.1.100/24 dev eth0

This command assigns the IP address 192.168.1.100 to the eth0 interface.

Delete an IP Address from an Interface

ip addr del 192.168.1.100/24 dev eth0

This command removes the IP address 192.168.1.100 from the eth0 interface.

Show Routing Table

ip route show

This command displays the current routing table.

Understanding ip Output

The output of the ip command can vary based on the object and command used. For example:

Summary of Options

Option Description
link Manage network interfaces.
addr Manage IP addresses.
route Manage routing tables.
neigh Manage ARP entries.
rule Manage routing policy rules.
tunnel Manage IP tunnels.
show Display information about the specified object.
add Add a new interface or address.
del Delete an interface or address.
set Set parameters for an interface.