UnderHost
Knowledgebase Docs

Advanced VPS Networking: IP Configuration & Routing

Configure advanced VPS networking: static IPs, IPv6, bonding, routing, DNS, firewalls. Master network architecture for complex setups.

On this page

VPS networking involves configuring IP addresses, routing, DNS, and firewalls. Unlike shared hosting (everything managed for you), VPS gives you full control—and responsibility—for network configuration. Understanding networking is essential for running reliable applications.

Networking Basics

Key concepts:

  • IP Address: Unique identifier for your VPS (e.g., 192.168.1.100)
  • Subnet Mask: Defines network range (e.g., 255.255.255.0)
  • Gateway: Router that connects your network to the internet
  • DNS: Translates domain names to IP addresses
  • Port: Specific application endpoint (e.g., port 80 for HTTP)

Check current network config:

ip addr show           # Show all IP addresses
ip route show         # Show routing table
cat /etc/resolv.conf  # Show DNS servers
netstat -tulpn        # Show listening ports
ss -tulpn             # Alternative to netstat

IPv4 Configuration

View current IPv4 settings:

ip -4 addr show
# Output example:
# 2: eth0: 
# inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0

Temporary IP change (lost on reboot):

sudo ip addr add 192.168.1.101/24 dev eth0
sudo ip route add default via 192.168.1.1

Persistent IPv4 (Debian/Ubuntu - /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

After editing: systemctl restart networking

Using Netplan (Modern Debian/Ubuntu):

# Edit /etc/netplan/01-netcfg.yaml
network:
  version: 2
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 192.168.1.100/24
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]

Apply: sudo netplan apply

IPv6 Setup

Check IPv6 configuration:

ip -6 addr show
# Modern VPS usually has IPv6 configured automatically

Enable IPv6 in Netplan:

network:
  version: 2
  ethernets:
    eth0:
      dhcp6: yes           # Auto-configure IPv6
      addresses:
        - 2001:db8::1/64   # Static IPv6 if needed

Test IPv6 connectivity:

ping6 google.com
curl -6 https://ipv6.google.com

Routing & Gateways

View routing table:

ip route show
# Output:
# default via 192.168.1.1 dev eth0
# 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.100

Add custom route (temporary):

# Route traffic for 10.0.0.0/8 through specific gateway
sudo ip route add 10.0.0.0/8 via 192.168.1.254

# Remove route
sudo ip route del 10.0.0.0/8 via 192.168.1.254

Persistent custom routes (Debian/Ubuntu):

# Edit /etc/network/interfaces
up route add -net 10.0.0.0/8 gw 192.168.1.254

DNS Configuration

Current DNS servers:

cat /etc/resolv.conf
# Shows nameserver entries

Set DNS permanently (Netplan):

network:
  version: 2
  ethernets:
    eth0:
      nameservers:
        addresses: [1.1.1.1, 8.8.8.8]  # Cloudflare and Google DNS

Test DNS resolution:

nslookup example.com
dig example.com
host example.com

If you send email from the VPS or need the IP to identify as a specific hostname, also configure reverse DNS from CustomerPanel. See How to set Reverse DNS / rDNS for your server IP.

Network Bonding

Combine multiple network interfaces for redundancy and load balancing:

# Create bonded interface
# Edit /etc/network/interfaces
auto bond0
iface bond0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1
    bond-slaves eth0 eth1
    bond-mode active-backup
    bond-miimon 100

Bond modes:

  • active-backup: One interface active, failover if fails
  • balance-alb: Load-balanced traffic, automatic address updating
  • 802.3ad: IEEE standard, maximum throughput

Firewall & Filtering

UFW (simple firewall):

ufw enable                    # Enable firewall
ufw default deny incoming     # Block all incoming by default
ufw default allow outgoing    # Allow all outgoing
ufw allow 22/tcp              # Allow SSH
ufw allow 80/tcp              # Allow HTTP
ufw allow 443/tcp             # Allow HTTPS
ufw status                    # Show rules

iptables (advanced firewall):

# Block specific IP
iptables -A INPUT -s 192.168.1.50 -j DROP

# Allow only specific port range
iptables -A INPUT -p tcp --dport 3306 -s 192.168.1.0/24 -j ACCEPT

# Save rules persistently
iptables-save > /etc/iptables/rules.v4

Network Troubleshooting

ProblemDiagnosticSolution
No internet accessping 8.8.8.8Check gateway route and IP config
DNS not resolvingnslookup google.comCheck /etc/resolv.conf
Slow networkiperf or speedtestCheck for packet loss, interference
Port not accessiblenetstat -tulpnCheck firewall rules, service listening
MTU issuesip link showMay need to adjust MTU for VPN/tunnels
Firewall misconfiguration = lockout

Be careful with firewall rules—a mistake can block your SSH access. Always test changes carefully and have console access ready to revert.

Related: Static IP setup | How to set Reverse DNS / rDNS for your server IP | NAT & port forwarding | VPS management

Was this article helpful?

Need a Cloud VPS?

Launch an UnderHost Cloud VPS when you need root access, dedicated resources, custom software, or more control than shared hosting.

Related articles

Back to Cloud VPS