Select your operating system to configure IP aliases:
For Linux (Ubuntu/Debian)
1. Edit Network Configuration
sudo nano /etc/network/interfaces
2. Add IP Alias Configuration
Add the alias IP configuration under the primary network interface configuration. For example, if your primary interface is eth0
:
auto eth0
iface eth0 inet static
address <PRIMARY_IP>
netmask <PRIMARY_NETMASK>
gateway <GATEWAY>
auto eth0:0
iface eth0:0 inet static
address <NEW_IP_ADDRESS_1>
netmask 255.255.255.255
auto eth0:1
iface eth0:1 inet static
address <NEW_IP_ADDRESS_2>
netmask 255.255.255.255
3. Restart Networking Service
sudo systemctl restart networking
For Linux (CentOS/RHEL)
1. Create Network Script for IP Alias
Create a new network script for each IP alias. For example:
sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0:0
Add the following configuration for the first alias:
DEVICE=eth0:0
BOOTPROTO=static
IPADDR=<NEW_IP_ADDRESS_1>
NETMASK=255.255.255.255
ONBOOT=yes
Repeat the steps for the second alias by creating another script:
sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0:1
Add the following configuration for the second alias:
DEVICE=eth0:1
BOOTPROTO=static
IPADDR=<NEW_IP_ADDRESS_2>
NETMASK=255.255.255.255
ONBOOT=yes
2. Restart Network Service
sudo systemctl restart network
For Linux using systemd-networkd
1. Check if systemd-networkd is enabled
Ensure that systemd-networkd
is the network manager in use.
sudo systemctl status systemd-networkd
If it is not enabled, enable it:
sudo systemctl enable systemd-networkd
sudo systemctl start systemd-networkd
2. Edit Network Configuration
Open the network configuration file. This file may vary, but a common default is /etc/systemd/network/50-default.network
.
sudo vim /etc/systemd/network/50-default.network
3. Add IP Aliases
Add or modify the configuration to include the primary IP and the alias IPs. Here is an example configuration:
[Match]
Name=eth0
[Network]
Address=<PRIMARY_IP_ADDRESS>/<PRIMARY_NETMASK>
Gateway=<GATEWAY>
[Address]
Address=<NEW_IP_ADDRESS_1>/32
[Address]
Address=<NEW_IP_ADDRESS_2>/32
4. Restart systemd-networkd
sudo systemctl restart systemd-networkd
Example Configuration
Here's an example configuration assuming your primary interface is eth0
, your primary IP address is 192.168.1.10
, and you're adding 192.168.1.11
and 192.168.1.12
as aliases:
[Match]
Name=eth0
[Network]
Address=192.168.1.10/24
Gateway=192.168.1.1
[Address]
Address=192.168.1.11/32
[Address]
Address=192.168.1.12/32
For Windows Server
1. Open Network Connections
Go to the Control Panel, navigate to Network and Sharing Center, and click on Change adapter settings.
2. Configure IP Alias
Right-click the network adapter connected to the network and select Properties. Select Internet Protocol Version 4 (TCP/IPv4) and click Properties. Click Advanced to open the Advanced TCP/IP Settings dialog. In the IP Addresses section, click Add and enter the new IP address and subnet mask. Repeat the process for each additional IP you want to add. Click OK to close each dialog box.
3. Verify Configuration
ipconfig
Verify Configuration
Check IP Configuration
Verify the new IP addresses are configured.
ip addr show eth0
Ping the New IPs
From another machine, try to ping the new IP addresses to ensure they are reachable.
Conclusion
By following these steps, you can successfully add additional IP addresses as aliases on your server. This configuration can be useful for various purposes, such as hosting multiple websites or services on different IP addresses.