Linux Commands to Display and Change IP Configuration Settings
Managing network configuration from the command line is one of the most fundamental skills for any Linux administrator. Whether you're setting up a fresh VPS Hosting environment, troubleshooting a connectivity issue on a production server, or configuring a static IP after deployment, knowing the right commands gives you fast, precise control over how your system connects to the network β no GUI required.
This guide covers every essential command you need to display, modify, and persist IP configuration settings on modern Linux systems.
Why Linux Network Configuration via CLI Matters
Linux powers the vast majority of the world's servers, cloud infrastructure, VPS nodes, routers, and embedded devices. In all of these environments, graphical interfaces are either unavailable or impractical. The command line is your primary β and often only β tool for network management.
In real-world scenarios, you'll use these commands to:
- Display current IP addresses assigned to all network interfaces (IPv4 and IPv6)
- Check link status β whether an interface is UP or DOWN, its MTU, and MAC address
- View the routing table and identify the active default gateway
- Temporarily change IP configuration for testing, failover, or emergency recovery
- Diagnose connectivity problems β wrong subnet, missing route, downed interface
- Confirm which interface and route the system uses to reach a specific destination
Understanding these tools is non-negotiable for anyone managing Dedicated Servers or cloud-based infrastructure at scale.
The Modern Standard: ip (from iproute2)
The primary command for displaying and changing IP configuration on modern Linux is:
ipThis tool is part of the iproute2 suite and has replaced the older ifconfig and route utilities across virtually all major distributions. It works consistently on Debian, Ubuntu, CentOS, RHEL, Fedora, Arch, and their derivatives β making it the definitive standard for production environments.
Displaying IP Configuration (Read-Only Commands)
These commands let you inspect the current network state without making any changes.
Show All Interfaces and IP Addresses
ip addr show
# Shorthand:
ip aThis outputs all network interfaces along with their assigned IPv4 and IPv6 addresses, subnet masks, and flags.
Show a Specific Interface
ip addr show dev eth0Replace eth0 with your actual interface name (e.g., ens3, enp0s3, bond0).
Show Link State, MAC Address, and MTU
ip link showThis reveals whether each interface is UP or DOWN, its hardware (MAC) address, and its Maximum Transmission Unit (MTU).
Show the Full Routing Table
ip route show
# Shorthand:
ip rThis displays all active routes, including the default gateway β critical for diagnosing why traffic isn't reaching its destination.
Show the Route Used to Reach a Specific Host
ip route get 8.8.8.8This is one of the most useful diagnostic commands available. It tells you exactly which interface and gateway the kernel will use to reach a given IP address β invaluable when troubleshooting routing issues on complex network setups.
Changing IP Configuration at Runtime (Non-Persistent)
> Important: Changes made with ip are temporary. They apply immediately but are lost after a reboot or if NetworkManager/systemd-networkd rewrites the configuration. For permanent changes, see the persistence section below.
Bring an Interface Up or Down
sudo ip link set dev eth0 up
sudo ip link set dev eth0 downAdd an IP Address (CIDR Notation)
sudo ip addr add 192.168.10.50/24 dev eth0Remove an IP Address
sudo ip addr del 192.168.10.50/24 dev eth0Replace an IP Address (Clean Method)
sudo ip addr flush dev eth0
sudo ip addr add 192.168.10.50/24 dev eth0Using flush before adding ensures no stale addresses remain on the interface.
Add a Default Gateway
sudo ip route add default via 192.168.10.1 dev eth0Replace the Default Gateway (Without Conflicts)
sudo ip route replace default via 192.168.10.1 dev eth0Add a Static Route to a Specific Network
sudo ip route add 10.50.0.0/16 via 192.168.10.254 dev eth0This is useful when you need traffic destined for a specific subnet to go through a particular gateway β common in multi-homed server setups or VPN configurations.
Making IP Changes Persistent
Runtime changes disappear on reboot. For a stable, production-ready configuration, you need to persist your settings using one of the following methods depending on your distribution and init system.
Method 1: NetworkManager with nmcli
Best for: Ubuntu Desktop, most RHEL/CentOS-based systems, Fedora, and many cloud images.
Show All Network Connections
nmcli con showConfigure a Static IPv4 Address on a Connection
sudo nmcli con mod "Wired connection 1"
ipv4.method manual
ipv4.addresses 192.168.10.50/24
ipv4.gateway 192.168.10.1
ipv4.dns "1.1.1.1 8.8.8.8"Apply the Changes
sudo nmcli con up "Wired connection 1"Replace "Wired connection 1" with the actual connection name shown by nmcli con show.
Method 2: systemd-networkd with networkctl
Best for: Minimal server installations, containers, and systems using systemd as the primary network manager.
Check Interface Status
networkctl statusConfigure Persistence via .network Files
Create or edit configuration files in:
/etc/systemd/network/A typical static IP configuration file (/etc/systemd/network/10-eth0.network) looks like this:
[Match]
Name=eth0
[Network]
Address=192.168.10.50/24
Gateway=192.168.10.1
DNS=1.1.1.1
DNS=8.8.8.8After editing, restart the service:
sudo systemctl restart systemd-networkdLegacy Commands: Still Present, No Longer Preferred
You'll occasionally encounter these older tools in documentation, tutorials, or legacy systems β but they are not recommended for modern environments.
| Legacy Command | Modern Replacement |
|---|---|
ifconfig | ip addr show / ip link show |
route | ip route show |
netstat -r | ip route |
The net-tools package (which provides ifconfig and route) is no longer installed by default on most distributions. If you encounter it on a system you're managing, consider it a signal that the environment may need modernization.
Quick Reference: Most-Used ip Commands
| Task | Command |
|---|---|
| Show all IPs | ip a |
| Show routing table | ip r |
| Show specific interface | ip addr show dev eth0 |
| Check route to host | ip route get 8.8.8.8 |
| Add IP address | sudo ip addr add 192.168.10.50/24 dev eth0 |
| Remove IP address | sudo ip addr del 192.168.10.50/24 dev eth0 |
| Set default gateway | sudo ip route add default via 192.168.10.1 |
| Bring interface up | sudo ip link set dev eth0 up |
| Bring interface down | sudo ip link set dev eth0 down |
Practical Summary
| Goal | Tool |
|---|---|
| Display current IP configuration | ip addr show / ip a |
| View routing table and gateway | ip route show / ip r |
| Temporarily change IP settings | ip addr, ip route, ip link |
| Persist changes (NetworkManager) | nmcli |
| Persist changes (systemd-networkd) | Edit /etc/systemd/network/*.network |
Applying This Knowledge in Hosted Environments
If you're managing a Linux server in a hosted environment, these commands are your first line of defense when something goes wrong with connectivity. Whether you're running a VPS with cPanel or a bare-metal dedicated machine, the ability to inspect and reconfigure networking from the CLI can mean the difference between a quick fix and extended downtime.
For environments where you need full control over your network stack β including custom routing, multiple IPs, or VLAN configuration β VPS Control Panels can complement CLI tools by providing a visual overview of your network interfaces alongside the power of direct shell access.
And if your server also handles outbound email, ensuring your IP configuration is correct is directly tied to mail deliverability. Misconfigured reverse DNS or a wrong gateway can silently break your Email Hosting setup β another reason to master these commands.
Mastering the ip command and understanding when to use nmcli or systemd-networkd for persistence puts you firmly in control of Linux networking β whether you're managing a single VPS or an entire fleet of production servers.
on All Hosting Services