ip — Network Management Command
What is ip
?
ip
?The ip
command is a powerful, versatile tool used to configure and manage network interfaces, routes, IP addresses, and other network-related tasks on Linux systems. It is part of the iproute2 package, which provides modern tools for network management, replacing older tools like ifconfig
, route
, and netstat
.
ip
offers a wide range of functionalities for network configuration and troubleshooting, including the management of network interfaces, routing tables, network addresses, tunnels, and more.
Key Features of ip
ip
Interface Management: View and modify network interfaces, assign IP addresses, bring interfaces up or down.
Routing: View and configure network routes and IP forwarding.
Network Address Management: Assign and remove IP addresses to network interfaces.
Multicast and Tunnels: Handle multicast addresses and set up network tunnels.
Advanced Options: Provides detailed control over various networking features, including link-layer configuration and quality of service.
Basic Syntax
Where:
OBJECT is the network object (e.g.,
link
,addr
,route
).COMMAND is the action you want to perform (e.g.,
show
,add
,del
).
Common ip
Subcommands
ip
Subcommands1. ip link
— Manage Network Interfaces
ip link
— Manage Network InterfacesUsed to manage network interfaces (e.g., Ethernet, Wi-Fi, virtual interfaces).
Example Commands
Show all network interfaces:
Bring an interface up:
Bring an interface down:
Change the MAC address of an interface:
Enable promiscuous mode:
2. ip addr
— Manage IP Addresses
ip addr
— Manage IP AddressesUsed to manage IP addresses assigned to network interfaces.
Example Commands
Show all IP addresses:
Add an IP address:
Remove an IP address:
Assign an IP address with a specific scope:
3. ip route
— Manage Routing Tables
ip route
— Manage Routing TablesUsed to display and modify routing tables.
Example Commands
Show the routing table:
Add a route:
Delete a route:
Add a default route:
4. ip link set
— Change Interface Settings
ip link set
— Change Interface SettingsUsed to change the settings of network interfaces (e.g., bring interfaces up/down, assign addresses).
Example Commands
Set an interface to promiscuous mode:
Set an interface to non-promiscuous mode:
Change interface MTU (Maximum Transmission Unit):
5. ip tunnel
— Create Tunnels
ip tunnel
— Create TunnelsUsed to manage IP tunnels (e.g., GRE tunnels, IPsec tunnels).
Example Commands
Create a GRE tunnel:
Show tunnel information:
6. ip link set
— Set Interface Attributes
ip link set
— Set Interface AttributesYou can set various attributes of network interfaces, including the interface’s name, MTU, and MAC address.
Example Commands
Set a new name for the interface:
Example Use Cases
Use Case 1: Configuring a Static IP Address
To set a static IP address on a network interface:
Assign the IP address:
Bring the interface up:
Add the default route:
Use Case 2: Setting Up a Virtual Network Interface
For setting up a virtual interface (e.g., eth0:0
):
Assign the IP address to the virtual interface:
Bring the interface up:
Comparison with Older Tools
Feature
ip
Command
ifconfig
/route
Interface Management
Full-featured management
Limited functionality
IP Address Handling
Advanced capabilities
Basic address assignment
Routing
Advanced routing features
Limited routing features
Tunnels
Supports advanced tunnels (GRE, IPsec)
Limited tunnel support
Efficiency
Preferred tool for modern Linux setups
Deprecated and less efficient
Alternatives to ip
ip
ifconfig
Older tool for managing network interfaces, largely replaced by ip
.
netplan
For managing network configuration in newer Ubuntu versions (YAML-based).
nmcli
NetworkManager's command-line interface for managing network connections.
Summary
Feature
ip
Command
Purpose
Manage network interfaces, addresses, and routes on Linux
Common Use Cases
IP configuration, route management, interface management
Alternatives
ifconfig
, nmcli
, netplan
, brctl
Key Commands
ip link
, ip addr
, ip route
, ip tunnel
The ip
command is a robust and modern tool for network configuration on Linux, offering extensive features for managing interfaces, IP addresses, routing, and more. It is the preferred tool for most modern Linux systems, providing superior functionality compared to older tools like ifconfig
and route
.
Last updated