The ip
command is a powerful network configuration tool that allows you to configure network interfaces, routing tables, and more on Linux systems. It is a part of the iproute2
package and is used to replace the older ifconfig
command.
Overview
The ip
command is used to configure and manage network interfaces and routing tables on Linux systems. It can be used to perform a variety of tasks, including:
- Configuring network interfaces
- Displaying network interface information
- Configuring routing tables
- Displaying routing table information
- Configuring network addresses and routes
- Displaying network address and route information
- Configuring network tunnels
- Displaying network tunnel information
Examples
Displaying Network Interface Information
To display information about all network interfaces on your system, you can use the following command:
ip address show
This will display information about all network interfaces, including their IP addresses, netmasks, and more.
Configuring Network Interfaces
To configure a network interface, you can use the following command:
ip address add <ip_address>/<netmask> dev <interface>
For example, to configure the eth0
interface with the IP address 192.168.0.2
and the netmask 255.255.255.0
, you can use the following command:
ip address add 192.168.0.2/24 dev eth0
Specific Use Cases
The ip
command can be used in a variety of situations, including:
- Configuring a network interface with a static IP address
- Configuring a network interface with a dynamic IP address using DHCP
- Configuring a network interface to use a specific DNS server
- Configuring a network interface to use a specific gateway
Options
The ip
command has many options that can be used to perform various tasks. The following table lists some of the most commonly used options:
Option | Description |
---|---|
address |
Configure IP addresses and related information |
route |
Configure routing tables |
link |
Configure network interfaces |
tunnel |
Configure network tunnels |
neighbour |
Manage ARP or NDISC cache entries |
maddress |
Manage multicast addresses |
monitor |
Monitor network traffic |
Troubleshooting Tips
If you encounter issues when using the ip
command, try the following troubleshooting tips:
- Make sure you have the
iproute2
package installed on your system - Check your command syntax for errors
- Check your network configuration files for errors
- Check your network hardware for issues
Notes
- The
ip
command is a powerful tool that should be used with caution, as it can potentially cause network connectivity issues if used incorrectly. - The
ip
command replaces the olderifconfig
command and should be used instead for configuring network interfaces on modern Linux systems.