Some VPS configurations include multiple network interfaces — for example, a public-facing interface and a private network interface. This guide covers configuring and using them correctly.
Common Reasons for Multiple Interfaces
- Separating public internet traffic from private inter-server communication
- Dedicated interfaces for specific traffic types (management vs application traffic)
- Provider-specific private networking features (see How to Set Up a Private Network Between Multiple VPS Instances)
Viewing Current Network Interfaces
ip addr show
Lists all network interfaces and their assigned IP addresses — identify which is your public-facing interface (typically eth0) and which might be a private/secondary interface.
Configuring a Second Interface (Netplan, Ubuntu 20.04+)
sudo nano /etc/netplan/50-cloud-init.yaml
network:
version: 2
ethernets:
eth0:
dhcp4: true
eth1:
addresses:
- 10.0.0.5/24
dhcp4: false
sudo netplan apply
Understanding Routing with Multiple Interfaces
ip route show
With multiple interfaces, understand which one is used as the default route (for general internet traffic) versus specific routes for private network traffic — misconfigured routing can cause traffic to go out the wrong interface.
Binding a Specific Service to a Specific Interface
# Example: bind Nginx to listen only on the private interface
listen 10.0.0.5:80;
Useful for ensuring internal-only services (database connections, internal APIs) are only reachable via the private interface, not accidentally exposed on the public one.
Firewall Rules Per Interface
sudo ufw allow in on eth1 to any port 5432
Restrict specific rules to apply only on a specific interface — letting you have different, appropriate security postures for public vs private-facing traffic.
Checking Which Interface Handles a Specific Connection
ss -tulnp
Shows which interfaces/addresses each listening service is actually bound to, useful for verifying your configuration matches your intent.
Common Use Case: Database on Private Interface Only
# PostgreSQL example
listen_addresses = '10.0.0.5'
Configuring a database to listen only on the private interface ensures it's reachable from other servers on your private network but never directly from the public internet — a meaningful security improvement over binding to all interfaces.
Common Errors
Service unreachable after binding to a specific interface — verify you're connecting from a client that can actually reach that specific interface (e.g. another server on the same private network), not attempting to reach a private-interface-only service from the public internet.
Netplan configuration doesn't apply correctly — check YAML syntax carefully (indentation matters significantly); use sudo netplan try to test changes safely with automatic rollback if connectivity breaks.
Continue Reading
- How to Set Up a Private Network Between Multiple VPS Instances
- Understanding NAT and How It Affects Your VPS
- How to Configure a Static IP on a Linux VPS
Browse more articles in Networking & DNS.