Configure Static IPs on Linux Servers — A Quick, Step-by-Step Guide
Keep your servers reachable and your services predictable—this quick, step-by-step guide walks you through configuring a static IP on Linux across common distributions and network managers. With copy-paste examples, troubleshooting tips, and VPS buying advice, you’ll have stable, production-ready networking in minutes.
Assigning a static IP to a Linux server is a foundational skill for system administrators, developers, and webmasters who manage services that require predictable networking — from web servers and mail relays to VPN gateways and clustered applications. This guide walks through the principles, practical configurations across common distributions and network managers, troubleshooting tips, and buying considerations for VPS instances where static addressing matters. Examples focus on real-world commands and configuration snippets you can copy, customize, and deploy quickly.
Why choose a static IP: principles and benefits
At its core, a static IP is an address manually assigned to a host that does not change across reboots or DHCP lease renewals. Static addressing provides:
- Predictability: DNS records, firewall rules, and access control lists (ACLs) can reliably reference the same IP.
- Availability for services: Services like HTTPS, SMTP, and FTP benefit from fixed endpoints for certificates, MX records, and whitelist configurations.
- Simpler routing and NAT setup: Port forwarding and NAT rules are stable when the internal or external IP remains constant.
- Better for monitoring and logging: Alerts and traffic analysis tie to a stable IP rather than a potentially ephemeral DHCP lease.
However, static IPs require careful configuration to avoid IP conflicts and to ensure correct gateway, DNS, and route settings. Below we cover common Linux network stacks and practical examples.
Common Linux networking stacks and when to use each
Modern Linux distributions use different network management tools. Choose the one your system uses:
- ifupdown (/etc/network/interfaces) — Classic Debian/Ubuntu legacy method.
- Netplan — Default on Ubuntu 18.04+; generates configs for NetworkManager or systemd-networkd.
- NetworkManager — Desktop-focused but used on many server OSes for dynamic control.
- systemd-networkd — Lightweight, systemd-native network manager for servers and containers.
Principles common to all methods
- Address — IP/mask (e.g., 203.0.113.42/24).
- Gateway — The next-hop router (e.g., 203.0.113.1).
- DNS — One or more name servers (e.g., 1.1.1.1, 8.8.8.8).
- Routes — Static routes for additional networks if needed.
Step-by-step configurations
1) Netplan (Ubuntu 18.04, 20.04, 22.04)
Netplan YAML files live in /etc/netplan/*.yaml. After editing, run sudo netplan apply. Example for a simple static IPv4 config:
Example file: /etc/netplan/01-netcfg.yaml
<pre>network:
version: 2
renderer: networkd
ethernets:
eth0:
addresses: [203.0.113.42/24]
gateway4: 203.0.113.1
nameservers:
addresses: [1.1.1.1, 8.8.8.8]
</pre>
Notes:
- Set
renderertoNetworkManagerif managing interfaces via GUI or NetworkManager. - For multiple IPs on one interface, list them under
addresses(e.g.,[203.0.113.42/24, 203.0.113.43/24]). - To add a static route: under the interface, add
routes:with destination, via, and optionally metric.
2) ifupdown (/etc/network/interfaces) — Debian and older Ubuntu
Edit /etc/network/interfaces. Example:
<pre>auto eth0
iface eth0 inet static
address 203.0.113.42
netmask 255.255.255.0
gateway 203.0.113.1
dns-nameservers 1.1.1.1 8.8.8.8
</pre>
Then:
sudo ifdown eth0 && sudo ifup eth0(or restart networking service).- On some systems, use
sudo systemctl restart networking.
3) systemd-networkd (server-focused)
Place .network files under /etc/systemd/network/. Example:
/etc/systemd/network/10-eth0.network
<pre>[Match] Name=eth0
[Network] Address=203.0.113.42/24Gateway=203.0.113.1
DNS=1.1.1.1 8.8.8.8
</pre>
Then restart:
sudo systemctl restart systemd-networkd
4) NetworkManager (nmcli)
NetworkManager is scriptable with nmcli. Example to set a static IPv4 on eth0:
- Create a connection or modify existing:
<pre>sudo nmcli con add type ethernet ifname eth0 con-name static-eth0
ipv4.addresses 203.0.113.42/24 ipv4.gateway 203.0.113.1
ipv4.dns “1.1.1.1 8.8.8.8” ipv4.method manual
</pre>
To modify an existing connection:
<pre>sudo nmcli con modify eth0 ipv4.addresses 203.0.113.42/24 ipv4.gateway 203.0.113.1 ipv4.method manual
sudo nmcli con up eth0
</pre>
Advanced topics: routes, multiple IPs, IPv6, and NAT
Adding persistent static routes
Netplan and systemd-networkd support routes directly in configs. For ifupdown, add lines like:
<pre>up ip route add 10.10.20.0/24 via 203.0.113.5 dev eth0
down ip route del 10.10.20.0/24 via 203.0.113.5 dev eth0
</pre>
For NetworkManager, use nmcli or the GUI to add routes to a connection.
Binding multiple IPs to one interface
You can assign multiple addresses, useful for hosting multiple SSL sites or isolating services. Examples:
- Netplan: list multiple addresses under
addresses. - Ifupdown: use
post-up ip addr add ...oraliasstyle configs. - systemd-networkd: add multiple
Address=entries.
IPv6 static addressing
All the managers support IPv6. Example Netplan snippet:
<pre>eth0:
addresses: [203.0.113.42/24]
gateway4: 203.0.113.1
nameservers:
addresses: [1.1.1.1, 8.8.8.8, 2001:4860:4860::8888]
dhcp6: no
addresses: [2001:db8::42/64]
gateway6: 2001:db8::1
</pre>
NAT and forwarding considerations
If the server sits behind NAT but needs static internal addressing, set internal static IPs and configure the external NAT device to forward ports. For servers acting as routers, enable IP forwarding:
<pre>sudo sysctl -w net.ipv4.ip_forward=1
To make permanent: edit /etc/sysctl.conf and set net.ipv4.ip_forward=1
</pre>
Troubleshooting checklist
- Check link and interface state: ip link show eth0
- Verify address assignment: ip addr show eth0
- Check routes: ip route show
- Test gateway reachability: ping -c 4 203.0.113.1
- DNS resolution: dig +short @1.1.1.1 example.com or host example.com
- Conflicting DHCP clients: Ensure dhclient or NetworkManager isn’t overriding static settings.
- System logs: journalctl -u systemd-networkd or journalctl -b for network-related errors.
- Firewall rules: iptables/nftables can block traffic; temporarily flush to test connectivity.
Use cases and real-world scenarios
Web hosting and reverse DNS
Public web services require a stable IP for DNS A records and for generating TLS certificates via some CA validation flows. Many providers also allow configuring reverse DNS (PTR) only for static public IPs — essential for email deliverability when running mail servers.
VPN and secure tunnels
VPN endpoints need stable IPs for clients to connect reliably. Setting static IPs prevents frequent client reconfiguration and simplifies firewall rules.
High-availability and clustering
Clusters often rely on fixed endpoint addresses for membership, quorum, or VIPs (virtual IP addresses). Static configuration reduces failure surface in failover scenarios.
Advantages comparison: static vs DHCP
- Static: Predictable, simpler DNS and firewall mapping, better SLA for services. Requires manual management and risk of conflict if misconfigured.
- DHCP: Easier central management, graceful reassignment, lease management. Not suitable when a service strictly requires a known IP unless DHCP reservations are used.
Hybrid approaches — using DHCP with static leases or reservations on the DHCP server — combine convenience with stability and are worth considering if you operate a private network with a capable DHCP service.
How to choose a VPS or server when static IP matters
When selecting a VPS for services that need static IPs, consider:
- Public static IP availability: Confirm the provider can allocate fixed public IPv4/IPv6 addresses and whether reverse DNS (PTR) is supported or configurable.
- Network performance: Check uplink bandwidth, data center location, and peering quality — latency affects user experience.
- Control plane: Ability to manage IPs via a control panel or API (useful for automated provisioning).
- Price transparency: Some providers charge per extra IP; verify costs for additional IP allocations.
- OS support: Ensure the distribution and network stack you prefer (Netplan vs ifupdown) is supported or can be installed without vendor lock-in.
For US-based deployments where low-latency access in North America is important, look for providers with multiple US data centers and straightforward static IP provisioning.
Conclusion and recommended next steps
Configuring a static IP on Linux servers is straightforward once you identify the network manager in use. Use Netplan on modern Ubuntu systems, ifupdown on classic Debian systems, systemd-networkd for lightweight server setups, and NetworkManager where dynamic or GUI-managed networking is needed. Always ensure correct gateway, DNS, and routes — and validate configuration with the ip and ping commands. For production services, also confirm reverse DNS and provider policies for static IP allocation.
If you’re provisioning new instances and need reliable static addresses with good North American coverage, consider providers that offer clear IP provisioning and control. For example, VPS.DO provides a range of VPS offerings in the USA; see details and options here: USA VPS at VPS.DO. This can be a practical starting point for deploying servers that require stable public IPs and predictable networking.