Home > Network Management > ip

ip Command Guide: Managing Network Interfaces and Routing

`ip` command is a powerful command-line utility used to check and configure various network-related information such as network interfaces, routing tables, and ARP (Address Resolution Protocol) cache in Linux. It offers more features than the traditional `ifconfig` command and is the recommended tool for network management on modern Linux systems. Use this guide to learn the main usages of the `ip` command.

Overview of ip

`ip` command is part of the `iproute2` package, providing a unified interface to control various aspects of the network stack. It is essential for network administrators to configure and troubleshoot networking on the system.

Main Roles of ip

`ip` command is primarily used for the following purposes:

Key Use Cases

  • Network Interface Management: Check the status of network adapters, assign IP addresses, enable/disable, etc.
  • Routing Table Management: Set and verify the paths for packets to reach their destinations.
  • ARP Cache Management: Check the mapping information between IP addresses and MAC addresses.
  • Network Device Statistics: Check the statistics of received/sent packets and errors per interface.
  • Multipath and Policy Routing: Configure advanced networking settings.

`ip` vs `ifconfig`

`ifconfig` is an outdated command, and it is recommended to use `ip` on modern Linux distributions. `ip` better supports the latest networking features, including IPv6, and offers a more consistent and scalable syntax.

Main ip Command Options

`ip` command is used in the form of `ip [OPTIONS] OBJECT { COMMAND | help }`, where `OBJECT` represents the network resources to manage (e.g., `link`, `addr`, `route`, `neigh`), and `COMMAND` defines the action to be performed on that resource.

1. Network Interfaces (ip link / ip addr)

2. Routing Table (ip route)

3. ARP Cache (ip neigh)

Generated command:

Try combining the commands.

Description:

`ip` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

Learn how to effectively manage and troubleshoot network interfaces, IP addresses, routing tables, etc., through various usage examples of the `ip` command.

Check IP addresses of all network interfaces

ip addr show

Displays detailed information such as IP addresses (IPv4, IPv6), broadcast addresses, MAC addresses, etc., of all network interfaces connected to the system.

Activate specific interface (eth0)

sudo ip link set dev eth0 up

Activates the network interface named `eth0` to enable communication.

Add IP address to interface

sudo ip addr add 192.168.1.10/24 dev eth0

Assigns the IP address `192.168.1.10/24` to the `eth0` interface.

Check current routing table

ip route show

Shows the routing rules used by the operating system to decide where to send packets. Includes information about the default gateway.

Set default gateway

sudo ip route add default via 192.168.1.1

Sets the default gateway to `192.168.1.1`, ensuring that all traffic going outside the local network goes through this gateway.

Check ARP cache entry

ip neigh show

Checks the mapping information between IP addresses and their corresponding MAC addresses that the system has recently communicated with.


Same category commands