Lesson 80: ip Command
In this lesson, you'll learn how to use the ip command to assign IP addresses, manage network interfaces, configure routing, and manage ARP entries in Linux.
The ip command is a new networking command-line utility that is used to assign an IP address to a network interface or configure/update useful network variables on a Linux system.
It is a part of the iproute2 package and offers several network administration tasks such as bringing up or down network interfaces, assigning and removing IP addresses and routes, managing ARP cache, and much more.
The ip command is very similar to the old ifconfig command, but it is greatly more powerful with more functions and capabilities added to it.
The ifconfig command has been deprecated and replaced by the ip command in all modern Linux distributions.
However, the ifconfig command still works and is available for most Linux distributions.
Note: Please take a configuration file backup before making any changes.
ip Command Syntax
$ ip [OPTIONS] OBJECT [COMMAND]
ip Command Objects and Options
| Object/Option | Description |
|---|---|
link |
Manage network interfaces |
addr |
Manage IP addresses on interfaces |
route |
Manage routing table entries |
neigh |
Manage ARP cache (neighbouring objects) |
show |
Display information about an object |
add |
Add a new entry (address, route, ARP) |
del |
Delete an entry |
flush |
Remove all entries for an object |
set |
Modify interface settings |
--color |
Display output in colored format |
-j |
Display output in JSON format |
-p |
Pretty-print JSON output with indentation |
1. Permanently Configure a Static IP Address
To permanently configure a static IP address in Linux, you need to update or edit the network configuration file. You must be a superuser.
Set Static IP Address in RHEL Systems:
Open and edit the network configuration file for (eth0 or eth1) using your favourite text editor. For example, assigning an IP address to the eth0 interface on RHEL-based distributions:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0 # RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux
Set Static IP Address in Debian Systems:
To configure the permanent static IP address, modify the network interface configuration file /etc/network/interfaces for Debian-based distributions:
$ sudo nano /etc/network/interfaces # Debian, Ubuntu and Mint
Next, restart network services after entering all the details using the following command:
$ sudo systemctl restart networking