<span>ip</span> command is a powerful tool for network interface configuration and management in Linux systems, part of the <span>iproute2</span> software package. It replaces the outdated <span>ifconfig</span>, <span>route</span>, and <span>arp</span> commands, offering more powerful and flexible functionality.
📌 Basic Syntax
ip [options] object [command] [parameters]
Common objects include:
<span>link</span>: network interfaces (e.g., eth0, wlan0)<span>addr</span>or<span>address</span>: IP address<span>route</span>: routing table<span>neigh</span>: ARP/NDP cache (neighbor table)<span>rule</span>: policy routing rules
🔧 Common <span>ip</span> Command Examples
1. View Network Interface Information (Equivalent to the old ifconfig)
ip link show
Description: Displays the status (UP/DOWN), MAC address, etc., of all network interfaces.
👉 To view a specific interface:
ip link show dev eth0
2. Enable or Disable Network Interfaces
# Enable eth0
ip link set eth0 up
# Disable eth0
ip link set eth0 down
3. View or Set IP Addresses
View IP Address:
ip addr show
Or shorthand:
ip a
👉 View a specific interface:
ip addr show dev eth0
Add IP Address:
ip addr add 192.168.1.100/24 dev eth0
Delete IP Address:
ip addr del 192.168.1.100/24 dev eth0
4. Manage Routing
View Routing Table:
ip route show
Or shorthand:
ip r
Add Default Gateway:
ip route add default via 192.168.1.1 dev eth0
Add Static Route:
ip route add 10.0.0.0/8 via 192.168.1.1 dev eth0
Delete Route:
ip route del 10.0.0.0/8
5. View Neighbor Table (Similar to arp -a)
ip neigh show
Clear a specific neighbor entry:
ip neigh del 192.168.1.1 lladdr aa:bb:cc:dd:ee:ff dev eth0
Force refresh:
ip neigh flush dev eth0
6. Display Network Statistics
ip -s link show dev eth0
This will display the number of packets sent and received, errors, and other statistics.
7. Use Color Highlighting for Output (for better readability)
ip -color a
8. Monitor Network Events (Dynamically Observe Changes)
ip monitor all
This can monitor changes in interfaces, addresses, and routes in real-time.
Only monitor route changes:
ip monitor route
✅ Comparison with Old Commands (Migration Reference)
| Old Command | New ip Command |
|---|---|
<span>ifconfig</span> |
<span>ip addr</span> / <span>ip link</span> |
<span>ifconfig eth0 up</span> |
<span>ip link set eth0 up</span> |
<span>route -n</span> |
<span>ip route show</span> |
<span>route add ...</span> |
<span>ip route add ...</span> |
<span>arp -a</span> |
<span>ip neigh show</span> |
⚠️ Notes
- Executing the
<span>ip</span>command to modify network configurations is usually temporary and will not persist after a reboot. For persistence, modify the network configuration files (e.g.,<span>/etc/network/interfaces</span>or use NetworkManager, systemd-networkd). - Root privileges are required to modify interfaces, routes, etc. (use
<span>sudo</span>):sudo ip link set wlan0 up
💡 Tips
- Using Tab completion can help you quickly input
<span>ip</span>subcommands. <span>ip help</span>or<span>ip -h</span>can be used to view help.- Combine usage:
<span>ip a && ip r</span>to view addresses and routes simultaneously.