31.01.2026

How to Configure Multiple Network Interfaces and IP Addresses on Ubuntu 20.04

In server environments, it is often necessary to configure multiple network interfaces or assign multiple IP addresses to a single interface. This is commonly used for traffic separation, service isolation, private networks, or high-availability setups.

In this guide, you will learn how to configure multiple network interfaces and assign static or secondary IP addresses on Ubuntu 20.04 using Netplan. We will cover common scenarios, practical configuration examples, and best practices to avoid network conflicts.

Multiple IPs to Multiple Adapters

The "one IP, one interface" network configuration is commonly used to organize local and internet connections on routers for several key reasons:

  1. Function Separation: Using separate IP addresses for each interface helps clearly distinguish the roles of the local network and internet access. Each interface can be connected to specific segments of the local network with individual routing and filtering rules.
  2. Traffic Management: Assigning separate IPs to each interface makes it easier to manage traffic. Different routing, filtering, and prioritization policies can be applied to each interface independently, optimizing bandwidth usage and ensuring quality of service.
  3. Problem Isolation: The "one IP, one interface" setup aids in isolating issues. If a problem arises on one interface or IP address, the other interfaces remain functional, which simplifies troubleshooting without impacting other network segments.

Update System Packages:

To ensure everything works properly, update your system packages:

sudo apt update && sudo apt upgrade -y

Our packages were already updated, so none of them were upgraded or newly installed

Next, check the available network interfaces on your system by logging in as the root user or using sudo:

ip link show


You may handle interface settings either by creating individual configuration files per interface or by defining everything in a single default file. For clarity, this example uses the second method and assigns a static IP to one of the network interfaces.

Find Network Configuration File:

ls /etc/netplan

You should see the configuration file name. Make sure to note it for the next step.

Edit Network Configuration:

Open the configuration file with the nano editor:

sudo nano /etc/netplan/50-init-cloud.conf

You will see a default configuration. Replace it with the following settings:

network:
version: 2
renderer: networkd
ethernets:
enp0s5:
addresses:
- 109.207.173.205/24
- 192.168.0.10/24 # Secondary IP
gateway4: 109.207.173.1
nameservers:
addresses:
- 8.8.8.8
- 1.1.1.1
enp0s6:
addresses:
- 10.10.10.1/24
nameservers:
addresses:
- 8.8.4.4
Replace 10.10.10.1, 10.10.10.0/24, and 109.207.173.205/24 with your own IP addresses.

Apply Changes:

Run the following commands to apply the changes and check your IP configurations:

netplan generate && netplan apply && ip a

Secondary IPs to One Interface

Why Do We Need Secondary IPs?

Secondary IP addresses can be useful for several scenarios:

  1. Service Separation: When a single physical device provides multiple network services, secondary IPs can bind each service to a different IP. For example, a server can host both a web server and a mail server, each using a separate IP address.
  2. Additional Connectivity: Secondary IPs allow for additional connectivity paths to the network. Multiple interfaces on a router or switch can each have a secondary IP to communicate with different network segments.
  3. Service Isolation: You can assign distinct IPs to different services on the same device to enforce stricter access controls between services. For instance, a web server and a database can each have separate IPs.
  4. Testing and Debugging: Secondary IPs provide a method to test new network configurations without interrupting primary services.

When multiple static IP addresses are assigned to an interface, DHCP should not be used for that interface. Mixing DHCP and static addressing on the same interface is not recommended.

Assign Secondary IP:

To assign a secondary IP to the same interface, modify the configuration as follows:

	enp0s5:
		addresses:
			- 109.207.173.205/24
			- 192.168.0.10/24  # Secondary IP

Apply and Check Changes:

After modifying the configuration, apply the changes and check your IPs with:

netplan generate && netplan apply && ip a
If you are connected via SSH, consider using:
sudo netplan apply --debug
or testing from console to avoid losing network access.

FAQ

Q: Why do I need multiple networks on a single server?

Q: Can I configure secondary IPs on a single interface?

Q: What if my server has multiple interfaces?

Q: How do I isolate network services using secondary IPs?

Q: Can I assign multiple default gateways?

Conclusion

In this guide, you learned how to configure multiple network interfaces and assign multiple IP addresses on Ubuntu 20.04 using Netplan.

You now know how to:

These configurations allow better service isolation, improved traffic management, and greater flexibility in complex server environments.