In the network administration world, the task of setting up additional IP addresses on a single network interface is commonly performed. The technique of IP aliasing, which is a system for a device to reply to several IP addresses on one network interface, penetrates this model. All Ubuntu users should be familiar with modifying and applying these settings to ensure robust networking administration.
This guide will detail the methods of creating an extra IP address in Ubuntu as an alias for both the versions of Ubuntu 24.04 and 22.04.
Obviously, one first needs to set up the system in a way that would allow for the manipulation of all IP addresses over the same network, using Ubuntu. Here is the list:
sudo
privileges)eth0
, ens3
)When troubleshooting problems, we are in danger of causing even more difficulty, as network interfaces provided by networks are not reliable. With this in mind, it would be wise to keep a backup of the configuration files before proceeding with the changes.
Ubuntu 24.04, the latest long-term support release, uses Netplan for network configuration. This configuration is also applicable for Ubuntu 22.04 and beyond.
Netplan is a utility for configuring networking on Linux systems. Here's how to create an additional IP address:
Primarily, it is necessary to define the network interface that will carry the new address. You can achieve this by running the following command:
ip addr show
The output of this command will display all the interfaces. Find the name of the interface (e.g. ens3
, eth0
) currently in use.
Normally Netplan configuration files are found in the /etc/netplan/
directory. The file name may be different but most of them end with a .yaml
extension. To change the file, use a text editor with root
privileges:
sudo nano /etc/netplan/50-cloud-init.yaml
In the YAML file, add the new IP address under the addresses
section of the appropriate network interface. The configuration may appear like this:
network:
version: 2
renderer: networkd
ethernets:
eth0:
addresses:
- "195.133.93.70/24"
- "166.1.227.189/24" #New IP address
- "192.168.1.2/24" #Private IP address
nameservers:
addresses:
- "1.1.1.1"
- "1.0.0.1"
dhcp4: false
dhcp6: false
routes:
- to: "0.0.0.0/0"
via: "195.133.93.1"
Upon saving your edits, you need to apply the new version of the configuration by running this command:
sudo netplan apply
After completing the steps above, you will need to repeat the ip addr show
command to confirm that the new IP address is in place. Now the output of this command should also include the new IP address.
The choices made by Netplan are stable and will last through the restart of the device. But, it's a good idea to verify the configuration with a system reboot to make sure everything goes well after the restart.
When adding a new IP address, you may need to update the firewall rules. Ubuntu traditionally uses UFW (Uncomplicated Firewall). To avoid blocking the new IP, you will have to create new rules to UFW.
If the system has some services running which are linked to specific IP addresses, then you must update their configurations to recognize and utilize the new IP address as well.
The above examples talk about IPv4. If you have to use IPv6 addresses, then the procedure is relatively the same; you will have to use a different style of address though. Netplan supports both IPv4 and IPv6 configurations.
In case of issues emerging during the configuration stage, try:
sudo netplan --debug generate
.journalctl -xe
.Network administrators can see how advanced IP aliasing plays a key role in improving network management: virtual interfaces make it possible to have several logical interfaces on a physical network interface, wherein all have their IP and network settings.
There are cases where network administrators would have to implement dynamic IP aliasing. With the help of scripts, it is possible to add or remove IP aliases according to certain conditions or occurrences. For example, a script can be made to insert an IP alias whenever a particular service starts and remove it every time the service stops.
The popularity of containerization in the present age necessitates having IP aliasing in order to control network configuration of Docker containers and any other containerized applications. In such cases, IP aliases are quite often employed to expose multiple services on a container at different IP addresses or assist containers to communicate with one another.
In Docker, network aliases can be used to allow multiple containers to respond to the same DNS name on a custom network. Among other things, this is indispensable in microservices architectures where service discovery is a very important issue.
Though IP aliasing has a multitude of advantages, the issue of security deserves also to be looked into. Among other things, the more IP addresses you put, the larger the possible security breach of a system. The network administrators must guarantee the applications are protected with:
Putting a new IP address as an alias into Ubuntu is a highly efficient process as their utility of Netplan helps greatly. Whether you are using Ubuntu 24.04 or 22.04, the steps remain the same including editing the Netplan configuration file, adding the new IP address, and applying the changes. A system with multiple IP addresses on a single network interface of a single computer can be used to do different tasks on such a network. The ability to respond to several IP addresses on one network interface becomes very useful in several networking situations.
Through these steps, you can increase the Ubuntu computer networking capabilities quickly and effectively. The sequence is always to first back up existing configurations then to make changes followed by in-depth test post-installation. With these skills, a network infrastructure manager or an IT technician can effectively manage and optimize his Ubuntu-powered network infrastructure to cater to diverse networking requirements.