Docs / Networking / How to Configure Static IP Addresses on Linux

How to Configure Static IP Addresses on Linux

By Admin · Mar 15, 2026 · Updated Apr 23, 2026 · 251 views · 1 min read

Most VPS providers pre-configure your network settings, but understanding how to manually configure static IPs is essential for adding secondary addresses, configuring private networking, and troubleshooting connectivity issues.

Netplan (Ubuntu 18.04+)

# View current config
ls /etc/netplan/
cat /etc/netplan/50-cloud-init.yaml

# Configure static IP
# /etc/netplan/01-static.yaml
network:
  version: 2
  ethernets:
    eth0:
      addresses:
        - 198.48.63.50/27
      routes:
        - to: default
          via: 198.48.63.33
      nameservers:
        addresses:
          - 1.1.1.1
          - 8.8.8.8

# Apply changes
sudo netplan apply

# Test before applying (auto-reverts after 120s)
sudo netplan try

NetworkManager (RHEL/Rocky)

# View connections
nmcli connection show

# Configure static IP
sudo nmcli connection modify eth0 ipv4.method manual
sudo nmcli connection modify eth0 ipv4.addresses "198.48.63.50/27"
sudo nmcli connection modify eth0 ipv4.gateway "198.48.63.33"
sudo nmcli connection modify eth0 ipv4.dns "1.1.1.1 8.8.8.8"
sudo nmcli connection up eth0

Adding Secondary IP Addresses

# Temporary (lost on reboot)
sudo ip addr add 198.48.63.51/27 dev eth0

# Permanent via Netplan
network:
  version: 2
  ethernets:
    eth0:
      addresses:
        - 198.48.63.50/27
        - 198.48.63.51/27
      routes:
        - to: default
          via: 198.48.63.33

sudo netplan apply

# Verify
ip addr show eth0

Troubleshooting Network Configuration

# Check interface status
ip link show

# Check IP configuration
ip addr show

# Test connectivity
ping -c 4 8.8.8.8          # Test Internet
ping -c 4 198.48.63.33     # Test gateway
ip route get 8.8.8.8       # Check routing

# Check DNS resolution
dig google.com
cat /etc/resolv.conf

Was this article helpful?