content type

Written by

in

Configuring a network alias—also known as IP aliasing—allows you to assign multiple IP addresses to a single physical network interface. This technique is essential for hosting multiple websites on a single server or grouping network objects together in firewalls for simplified security management.

Here is how to configure a network alias using standard command-line methods for Linux-based systems. Prerequisites Root or sudo administrative access.

A designated secondary IP address and its corresponding subnet mask.

Knowledge of your primary network interface name (e.g., eth0 or ens33). Step 1: Identify Your Primary Network Interface

Find the active, physical interface name where you want to bind your new alias. Open your terminal. Run the command: ip address show (or ip a).

Locate your primary connected interface name from the output. Step 2: Create a Temporary Network Alias (Optional Testing)

Test your new IP address immediately without making permanent system changes.

Run the ip command to map your new alias:sudo ip addr add [ADDITIONAL_IP]/[MASK] dev [INTERFACE_NAME] Example: sudo ip addr add 192.168.1.⁄24 dev eth0 Step 3: Access the Permanent Configuration Directory

Ensure your network alias stays active after a system reboot by altering system files.

Navigate to your operating system’s network configuration path. For RHEL/CentOS systems: cd /etc/sysconfig/network-scripts/

For Ubuntu/Debian systems: Modern versions utilize Netplan, so you will head to cd /etc/netplan/. Step 4: Create and Edit the Interface Configurations

Declare the specific technical settings for your secondary network connection. On RHEL/CentOS:

Create a virtual script copy of your main interface file by appending a colon and a number ID (e.g., ifcfg-eth0:0). Update the internal parameters using a text editor:

DEVICE=eth0:0 ONBOOT=yes BOOTPROTO=static IPADDR=192.168.1.50 NETMASK=255.255.255.0 “` Use code with caution. On Ubuntu/Debian (Netplan):

Open your existing .yaml configuration file (e.g., 01-netcfg.yaml).

Add the extra IP directly under the addresses block for your target interface:

ethernets: eth0: addresses: - 192.168.1.⁄24 - 192.168.1.⁄24 Use code with caution. Step 5: Restart the Network Service and Verify

Apply the new configuration modifications and check if the alias works.

Reload the active daemon by executing the proper command for your OS: RHEL/CentOS: sudo systemctl restart NetworkManager Ubuntu/Debian: sudo netplan apply

Verify the alias is working by pinging it from an external computer or checking your network status again with ip a.

If you are looking to configure this on a specific platform, please let me know: Problem configuring Network aliases – Server Fault

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *