The Ubuntu ip command is a modern replacement for ifconfig and route, used to show and manipulate network interfaces, routing, tunnels, and neighbor tables. As the standard network management utility on Ubuntu servers and desktops, it provides concise output and powerful filtering for both IPv4 and IPv6 environments.
Learning to use ip effectively helps you troubleshoot connectivity, manage bridges, and control policy-based routing on Ubuntu with precision. This guide covers essential usage, advanced scenarios, and common troubleshooting tips for the ip command.
| Objective | Command | Typical Output Fields | Use Case |
|---|---|---|---|
| Show interface configuration | ip addr show | inet, inet6, scope, state | Verify IP assignment and interface status |
| Show routing table | ip route show | destination, gateway, metric, via | Diagnose default route and static routes |
| Show neighbor cache | neigh show | IP, lladdr, state, dev | Troubleshoot ARP/NDP resolution issues |
| Control policy routing | rule add from | pref, from, lookup table_id | Multi-table routing and source-based policies |
| Manage network namespaces | netns exec | ns path, interface list | Isolate processes and test routing in containers |
ip link show and interface management
Bringing interfaces up and down
Use ip link set to enable or disable network interfaces on Ubuntu. The command ip link set dev eth0 up activates the interface, while ip link set dev eth0 down deactivates it, which is useful for testing or temporarily isolating a device from the network.
Changing MAC and MTU settings
You can modify the MAC address and Maximum Transmission Unit (MTU) with ip link set. Commands such as ip link set dev eth0 address 52:54:00:12:34:56 and ip link set dev eth0 mtu 1400 allow low-level tuning for specialized network configurations and optimization.
ip addr and IP address handling
Adding and removing addresses
The ip addr add and ip addr del commands let you assign or remove secondary IP addresses from interfaces. Examples include ip addr add 192.168.10.10/24 dev eth0 and ip addr del 192.168.10.10/24 dev eth0, which are helpful for temporary bindings or multihoming without editing persistent configuration files.
Filtering address output by scope
You can filter addresses by scope using ip -4 addr show or ip -6 addr show to focus on IPv4 or IPv6 entries. For more specific filtering, combine ip addr show with grep to narrow results to primary or secondary addresses quickly during troubleshooting.
ip route and advanced routing control
Managing default and static routes
Configure default gateways with ip route add default via
Policy-based routing with multiple tables
Advanced routing with ip rule add allows source-based or mark-based lookups across multiple routing tables. Typical scenarios include prioritizing specific subnets or applications by creating custom tables with ip route add table and binding them using ip rule add from or fwmark for precise traffic engineering.
Troubleshooting and diagnostics
Inspecting ARP and neighbor states
The command ip neigh show displays the neighbor cache, revealing ARP entries for IPv4 and NDP entries for IPv6. Monitoring states like REACHABLE and STALE helps diagnose connectivity problems when hosts fail to respond or packets are being dropped at layer 2.
Capturing link statistics
Use ip -s link show to view detailed interface counters, including packets, errors, and dropped frames. These statistics are valuable for identifying physical layer issues, misconfigured NICs, or congestion on high-traffic interfaces on Ubuntu servers.
Key takeaways for effective use of ip on Ubuntu
- Use ip addr for quick interface and IP address verification.
- Leverage ip link for interface state, MAC, and MTU management.
- Control default and static routes with ip route show and ip route add.
- Employ ip rule for policy-based routing and advanced traffic selection.
- Monitor ip neigh show to troubleshoot ARP/NDP resolution problems.
- Check ip -s link show for interface counters and performance insights.
- Combine ip commands with grep and ip -json for scripting and automation.
FAQ
Reader questions
How can I quickly list all IP addresses assigned on Ubuntu using ip?
Run ip -brief addr show or ip a to get a concise list of interfaces with their assigned IPv4 and IPv6 addresses, including the interface state.
What does it mean when an interface shows state DOWN after ip link show?
The state DOWN indicates that the interface is administratively disabled or the physical/cable connection is absent, preventing layer 2 and layer 3 communication until it is brought up.
How do I add a secondary IP address temporarily without persisting after reboot?
Use sudo ip addr add 192.168.50.10/24 dev eth0, which assigns the address immediately; it will be lost on reboot unless added to your network configuration files.
Why does ip route show a blackhole or unreachable route?
Blackhole routes drop matching traffic without notification, while unreachable routes reject traffic with an error; these are often used for policy routing or to block specific subnets intentionally.