IP aliasing is a special network configuration for your OVHcloud servers which allows you to associate multiple IP addresses with a single network interface. In this article, we will walk through how to configure IP aliasing on your VPS.
Prerequisites
- A additional IP address (/32 block only)
- Root access to the server
Topics
Debian 10
Step 1: Disable Automatic Network Configuration
First, create the following file in a text editor of your choice:
$ sudo vi /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
Next, enter the following text into the new file. This will prevent Debian from making automatic network configuration changes.
network: {config:disabled}
Save the file and exit the editor when you have confirmed the changes are correct.
Step 2: Edit the Network Configuration File
Next, open the network configuration file for editing with the following command:
$ sudo vi /etc/network/interfaces.d/50-cloud-init.cfg
Then edit the file with the following configuration, replacing the name of the network interface and additional IPs in red with the NIC name and additional IP address on your VPS:
auto eth0
iface eth0 inet dhcp
auto eth0:0
iface eth0:0 inet static
address 203.0.113.1
netmask 255.255.255.255
auto eth0:1
iface eth0:1 inet static
address 203.0.113.2
netmask 255.255.255.255
Finally, bring up the new interface you have created using the following command:
$ sudo ifup eth0:0
Next, we will take a look at how to do this same configuration in Ubuntu 20.04.
Ubuntu 20.04
To configure IP aliasing in Ubuntu 20.04, SSH into your server and open the interface configuration file in Netplan using the following command:
$ sudo vi /etc/netplan/50-cloud-init.yaml
In this file, one interface will already be configured: the default interface for your VPS. Add a second interface with the same name as the first one and use your additional IP instead of the IP for the VPS. The file will appear as follows:
network:
version: 2
ethernets:
ens3:
dhcp: true
match:
macaddress: 00:53:00:00:00:00
mtu: 1500
set-name: ens3
ens3:
dhcp: true
match:
macaddress: 00:53:00:00:00:00
set-name: ens3
addresses: [203.0.113.1/32]
Note: The items in red in the above file will be unique to your machine so change them accordingly.
Now apply the new file using the following command:
$ sudo netplan apply
Your additional IP will now be attached to your VPS's interface. Next, we will take a look at how to configure IP aliasing in CentOS 8.
CentOS 8
Before adding our additional IP to the interface, we will first determine our active interface by using the following command.
$ ifconfig
The interface with the VPS's IP address attached will be the active interface. In our example, we will use eth0
. To configure the additional IP as an alias, run the following command replacing the interface name and IP address in red with the correct ones for your VPS:
$ sudo ifconfig eth0:0 203.0.113.1 netmask 255.255.255.255 up
This command configures the alias and also brings it up so, once you have confirmed that the IP address pings, you are done. Next, we will take a look at how to configure IP aliasing in Windows Server 2019.
Windows Server 2019
By default, Windows Server will have DHCP enabled in the network configuration. If you have already set up a additional IP or switched your configuration to a fixed IP, go directly to the next step.
Otherwise, you need to first switch from a network-level DHCP configuration to a fixed IP configuration.
Open the command prompt by typing cmd
in the search bar. Then type the following command.
ipconfig /all
Identify and write down your IPv4 address, subnet mask, default gateway, and the name of the network adapter.
Once you have these pieces of information, proceed to the next step. We will cover how to perform these steps in cmd
as this is the easier method. We will use the following three commands to configure the additional IP.
Step One - Switch to a static IP
netsh interface ipv4 set address name="NETWORK_ADAPTER" static IP_ADDRESS SUBNET_MASK GATEWAY
Step Two - Set the DNS server
netsh interface ipv4 set dns name="NETWORK_ADAPTER" static 213.186.33.99
Step Three - Add the Additional IP
netsh interface ipv4 add address "Ethernet" ADDITIONAL_IP 255.255.255.255
Ping the additional IP to ensure the changes have worked.
Conclusion
Now that you have read this article, you should be able to configure IP aliasing on Debian 10, Ubuntu 20.04, CentOS 8, and Windows Server 2019.