Static IP Configuration: Assign Fixed IP to VPS
Configure static IP on VPS for stability. Learn Netplan, Debian/Ubuntu, CentOS configuration, verify changes, troubleshooting.
On this page
Static IPs stay the same—essential for servers, DNS records, firewall rules, and VPNs. Dynamic IPs (change on reboot) cause constant issues. Every VPS should have a static IP.
Why Static IP?
- DNS pointing: Your domain points to this IP—changing it breaks everything
- Firewall rules: Rules referencing the IP stay valid
- VPN/Tunnels: Require consistent IP for connections
- Mail servers: Depend on stable IP for reputation
- Remote access: SSH/RDP to known IP address
Check Current IP
ip addr show
# Output shows current IP, e.g., 192.168.1.100/24
hostname -I
# Quick IP check
Configure with Netplan (Modern)
Edit /etc/netplan/01-netcfg.yaml:
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
dhcp6: no
addresses:
- 192.168.1.100/24
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
routes:
- to: 0.0.0.0/0
via: 192.168.1.1
Apply changes:
sudo netplan apply
# Test immediately:
ping 8.8.8.8
Debian/Ubuntu (/etc/network/interfaces)
Edit /etc/network/interfaces:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
Restart networking:
sudo systemctl restart networking
CentOS/RHEL Configuration
Edit /etc/sysconfig/network-scripts/ifcfg-eth0:
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
Restart networking:
sudo systemctl restart network
Verify Configuration
# Check IP is static
ip addr show eth0
# Test internet
ping google.com
# Check DNS
nslookup google.com
# Verify gateway
route -n
Update DNS Records
After changing IP, update your domain's DNS A record to point to new IP:
- DNS provider (Cloudflare, Route53, etc.)
- Find A record for your domain
- Change IP to new static IP
- Wait 24 hours for propagation (usually faster)
Troubleshooting
| Problem | Solution |
|---|---|
| No internet after change | Check gateway IP, verify netmask, restart networking |
| DNS not working | Check nameservers in config, test with nslookup |
| Old IP still showing | Reboot VPS: sudo reboot |
Your VPS control panel (aaPanel, CloudPanel) shows the correct static IP, netmask, gateway. Copy these exact values into your config.
Related: Advanced VPS networking | DNS configuration | Firewall setup
Need a Cloud VPS?
Launch an UnderHost Cloud VPS when you need root access, dedicated resources, custom software, or more control than shared hosting.





















