How to Configure Multiple Network Interfaces on Ubuntu 20.04
Why multiple networks may be needed?
Multiple networks may be needed in various scenarios due to several reasons:
- Distributed Computing: In largescale systems, multiple networks can be employed to distribute the computational load across different machines or nodes. This approach improves performance and fault tolerance by allowing tasks to be executed concurrently.
- Specialization: Different networks can be designed to specialize in specific tasks or domains. For example, in deep learning, there are separate networks for image recognition, text generation, and speech synthesis. Each network focuses on a particular area, leveraging its strengths and optimizing performance.
- Domains with Heterogeneous Data: In cases where the data is heterogeneous or multimodal (e.g., including images, text, and audio), separate networks can be employed to handle each modality. These individual networks can process the specific data type effectively before combining the results for a final decision.
In summary, multiple networks are beneficial in scenarios involving distributed computing, specialization, ensemble learning, transfer learning, complex model architectures, scalability, resource constraints, and domains with heterogeneous data. They enable improved performance, flexibility, robustness, and efficiency in various machine learning and artificial intelligence applications.
Multiple IPs to the multiple adapters
Using the "one IP one interface" network configuration in the network to organize a local and Internet connection on the router has several reasons:
- Separation of functions: The use of separate IP addresses on each interface allows you to clearly distinguish the functions of a local network and Internet access. Each interface can be connected to a specific segment of the local network and have its own rules for routing and filtering traffic.
- Traffic Management: Using separate IP addresses on each interface simplifies traffic control and management. You can apply different routing, filtering, and traffic prioritization policies for each interface independently. This makes it possible to efficiently use the available bandwidth and ensure the quality of service for different network segments.
- Isolation of problems: The "one IP one interface" configuration also helps to isolate problems in the network. If something happens to one interface or IP address, the other interfaces and addresses remain functional. This simplifies troubleshooting without seriously affecting other network segments.
Don't remember to update system package for properly work OS:
apt update && upgrade -y
Next, we need to check available interfaces on our machine as superuser, for that login as root user or use command sudo:
ip link show
We have several options to change configuration file: make new config file in folder and work with them or use one default config for all interfaces. For us example let's choose second way. Open the configuration plan , I will config static address for one of them.
ls /etc/netplan
You will see name of your configuration file, for the next step take in mind it. Attention! In your case you choose your name for file as we knew them before!
nano /etc/netplan/50-init-cloud.conf
Then you will see the file with default configuration, change settings for the displayed below:
network:
version: 2
ethernets:
enp0s5:
addresses:
- 109.207.173.205/24
mtu: 1500
nameservers:
addresses:
- 8.8.8.8
-1.1.1.1
-8.8.4.4
search: []
routes:
- to: default
via: 109.207.173.1
enp0s6:
addresses:
- 10.10.10.1/24
mtu: 1500
nameservers:
addresses:
- 8.8.8.8
-1.1.1.1
- 8.8.4.4
search: []
routes:
- to: 10.10.10.0/24
via: 10.10.10.1
Change 10.10.10.1, 10.10.10.0/24, 109.207.173.205/24 for your's IP. Let's have a look for changes via command below:
netplan generate && netplan apply && ip a
Secondary IPs to the one interface
Why are we in need of this?
Secondary IP addresses can be used in different situations and for different purposes. Here are some of them:
- Separation of Services: If you have a single physical device that provides multiple network services or hosts multiple virtual machines, secondary IP addresses can be used to bind each service or virtual machine to a separate IP address. For example, you can have a server that provides both a web server and a mail server, and you can use two secondary IP addresses to associate each service with a separate address.
- Additional Connectivity: Secondary IP addresses can be used to add additional connectivity paths to the network. For example, if you have a router or switch with multiple interfaces, each interface can be assigned a secondary IP address to be able to communicate with different parts of the network.
- Service Isolation: Secondary IP addresses can be used to isolate network services from each other. For example, if you have a web server and a database on the same physical server, you can assign one IP address to the web server and another IP address to the database. This helps to establish stricter access rules and controls between services.
- Testing and Debugging: Secondary IP addresses can be used to test and debug network settings without interrupting the main connection. For example, you can create a secondary IP address to test new network configurations or settings without affecting the operation of the main services.
Secondary IP addresses have a wide range of applications and can be useful in various situations where additional flexibility or isolation in the network is required.
Even if your server has one network adapter you can configure additional IPs onto. Just one exception: if you add more then one IP to the same interface, you can't use DHCP. To add IP alias just "insert" secondary address to current interface config near the exist address:
Then apply and check changes:
netplan generate && netplan apply && ip a
Conclusion
After this article reading you are knew how to configure multiple network interfaces on Ubuntu 20.04.