How to Configure Multiple Network Interfaces on Ubuntu 20.04

How to Configure Multiple Network Interfaces


Additional settings must be performed to guarantee the server is available at these additional addresses if the Ubuntu 20.04 serverhas two or more network interfaces with public IP addresses. Because the default routing strategy transmits all network packets through a single interface with a default route, this is the case. It makes no difference which interface the packet arrived at the server over in this scenario. As a result, even if the Netplan configuration is right, the server will not reply to extra IP addresses unless additional settings are made. We’ll look at how to set up numerous network interfaces in Ubuntu 20.04.
Configure Multiple Network Interfaces

How to Configure Multiple Network Interfaces on Ubuntu 20.04:

Netplan automatic configuration

 

Linux OpenSource Listing are intended to make users’ lives easier. They have the capability of automatically configuring network interfaces when they are added to the control panel or when a server is created. However, we must make adjustments to the Netplan settings in order to assure the operation of policy-based routing and the server’s availability on many network interfaces at the same time. We must stop automatic network configuration to prevent our settings from being overwritten on a reboot. Create a file on the server after you’ve verified that the required number of interfaces have been added:

vim /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

Add a parameter to it:

network: {config: disabled}

Subsequent Netplan updates will no longer be overridden when the computer is rebooted.

Configuring Policy-Based Routes

Tables support policy-based routing. Each table has its own set of policies and routes. Let’s see if the iproute2 package is installed on the system. Install it if it isn’t already installed.

apt install iproute2

Open the routing tables file:

vim /etc/iproute2/rt_tables

Finally, add the number of tables that match to the number of interfaces you’re configuring:

800 800
801 801

Record format: priority (number) space table name (number).

Now open the Netplan file that contains the network interface configurations. It has the.yaml extension and is situated along the route /etc/netplan/. The path in my instance is as follows:

vim /etc/netplan/50-cloud-init.yaml

This file contains a settings block for each interface. We’ll add settings for policies and routing rules for the interface at the conclusion of this block. It’s critical to pay attention to the number of spaces before each parameter and value in this file, and to avoid using tabs instead of spaces. Concentrate on current entries’ indentation and add by analogy.

Add routes and routing-policy blocks to each network interface. For one interface, the final record will be as follows:

network:
version: 2
ethernets:
enp0s5:
addresses:
- 78.89.90.12/24
gateway4: 78.89.90.1
match:
macaddress: 54:43:32:21:10:09
mtu: 1500
nameservers:
addresses:
- 8.8.8.8 - 1.1.1.1
- 8.8.4.4
search: []
set-name:
enp0s5 routes:
- to: 0.0.0.0/0
via: 78.89.90.1
table: 800
routing-policy:
- from: 78.89.90.12
table: 800
priority: 300

Other interfaces will have the same entries, starting with the interface name (enp0s5), but they will not include the gateway4 option because there should only be one default gateway. Routes and settings for routing policies:

    •  
    • to – the packet’s destination address. Any (0.0.0.0/0) (0.0.0.0/0) (0.0.0.0/0) (0.0.0.0/0) (0.0.0.0

    • through – this interface’s gateway address

    • The routing table’s name is table. For one interface, the same values must be defined in routes and routing-policy, but they must differ from interface to interface. These tables were built in the rt tables file

    • from – the package’s source address. This is the interface’s IP address for the purposes of this handbook

    • priority – a numerical value that must be met

Check the configuration for mistakes after you’ve made the settings and saved the file:

netplan generate

Output like this will indicate an error if present (in this case, a space is missing.):

vim /etc/netplan/50-cloud-init.yaml:23:12

The output will be missing if the config is correctly compiled. This signifies it’s time to put the modifications into action:

netplan apply

The network interfaces set in this manner will become available from the outside at their public IP addresses after applying the adjustments.

Follow us TwitterFacebookLinkedIn

Open Source Listing

Previous Post
Next Post

Leave a Reply