The ip command is an incredibly useful tool for configuring network interfaces and routing on Linux systems. It replaces many of the old networking commands like ifconfig, route, arp and more with a single tool that‘s consistent across distributions.
In this comprehensive guide, we will explore the most common uses of ip on Debian 10 Buster to manage network interfaces, routing tables, and display network device information.
Getting Started with the IP Command
To get an overview of everything ip can do, run:
ip --help
This displays all the objects like link, address, neighbor, route etc. that can be configured with ip. You can also get command specific help with ip help COMMAND.
To find more detailed documentation, use:
man ip
Next, let‘s jump into some specifics on managing network interfaces and routing.
Manage Network Interfaces with ip link
The link object lets you configure network interfaces. Some common tasks include:
List Available Interfaces
To see all network interfaces recognized by your system:
ip link show
This provides the interface name, MAC address, MTU size, link state and more.
Enable/Disable Interfaces
To disable an interface like eth0:
sudo ip link set eth0 down
And to enable it again:
sudo ip link set eth0 up
View Interface Statistics
To troubleshoot connectivity issues, use -s to show detailed stats:
ip -s link show eth0
Change Interface MTU Size
Modify the maximum transmission unit size like this:
sudo ip link set eth0 mtu 1460
Manage Routing Tables with ip route
The routing table controls where packets are forwarded to.
Display Routing Table
View the current IPv4 routes with:
ip route show
Or for IPv6:
ip -6 route show
Add Static Routes
To add a static route:
sudo ip route add 192.168.1.0/24 via 10.0.0.1 dev eth1
Delete Routes
Delete routes by changing add to del like so:
sudo ip route del 192.168.1.0/24
Assign IP Addresses with ip addr
ip addr is used for managing IP addresses assigned to interfaces.
Display Interface Addresses
Show all interface IPs:
ip addr show
Or a specific interface:
ip addr show eth0
Assign Static IP Address
To assign a static IP address:
sudo ip addr add 192.168.1.100/24 broadcast 192.168.1.255 dev eth1
Note: This will be removed on reboot. To make permanent, edit
/etc/network/interfaces.
Delete IP Addresses
Remove IPs with:
sudo ip addr del 192.168.1.100/24 dev eth1
So in summary, the ip command is very versatile for interacting with networks. It consolidates older utilities into one standardized tool while still offering advanced features for network administration.
Conclusion
In this guide, we explored some of the most essential uses of ip on Debian 10 – displaying network info, assigning IP addresses, managing routes and configuring interfaces.
With this foundation, you can administer the network layer on any Linux machine using consistent ip syntax rather than distro-specific commands.
The syntax works similarly on Debian, RedHat, Arch, and more. Refer to the initial ip --help and man ip for even more advanced capabilities.


