Assigning a subnet to a server with AlmaLinux 8-9 OS: Step-by-Step Guide

While a management IP address provides a fixed address for each server, assigning a public IP subnet allows for multiple IP addresses to be used on the same server, with specific IPs reserved for essential network functions.

This guide will explain how to set up and assign a public IP subnet to your dedicated server running AlmaLinux 8-9 by creating a new sub-interface and configuring the necessary network settings.

Some key points to consider:

  • Subnets work exclusively with dedicated servers.
  • This guide applies to dedicated servers running AlmaLinux 8 and 9 operating systems.
  • Ensure you have root access to the server.
  • The example provided assumes the use of the bond0 interface. Adjust the interface name according to your server setup.

Step-by-Step Instructions

Step 1: Access the Client Portal 

  1. Log in to your client portal. 
  2. Click on the "Network" button at the top of the menu bar (see Fig. 1). 

    Fig. 1. Access the ”Network” section in the client portal. 

Step 2: Verify your subnet allocation and assign IP addresses

  1. In the "Network" section of the client portal, click on the "Subnets" button to view all available subnets (see Fig. 2).

    Fig. 2. Access the subnets section.
  2. You will now see a list of all available subnets. Locate the subnet you wish to configure.
  3. To assign individual IP addresses from the subnet, click on the subnet in the list. This will display all available IP addresses within that subnet (see Fig. 3).

    Fig. 3. Viewing available public IP subnet list in the client portal.
  4. Once you've identified the IP address you want to assign to your server, click the "Attach +" button next to that IP address. This action lets you to associate the selected IP address with your server (see fig. 4).

    Fig. 4. Verify and attach an IP address from the subnet in the client portal.

Step 3: Identify your primary network interface

  1. Use the ip a command to identify your primary network interface (e.g., eth0, bond0):
    $ ip a

    This will return the available network interfaces and their current configurations (see Fig. 5).


    Fig. 5: Output of ip a command showing the main network interface.

Step 4: Create a sub-interface for the subnet

  1. Navigate to the network-scripts directory:
    $ cd /etc/sysconfig/network-scripts/
  2. Create a new sub-interface configuration file for the public subnet. For example, if your main interface is bond0, the new file will be named ifcfg-bond0-range0:
    $ sudo nano ifcfg-bond0-range0
  3. Add the following configuration to the file:
    CLONENUM_START=10              # Starting position of subnet

    GATEWAY=x.x.x.x                # Gateway of ordered subnet

    IPADDR_START=x.x.x.x           # First usable IP in subnet

    IPADDR_END=x.x.x.x             # Last usable IP in subnet

    PREFIX=29                      # Subnet prefix (use the appropriate one for your IP range)

    ONBOOT=yes                     # Enable the interface on boot

    TYPE=Ethernet                  # Type of connection

    USERCTL=no                     # Prevent non-root users from managing this interface
    • Replace x.x.x.x with the actual IP range and gateway for your ordered subnet.
    • Adjust the PREFIX to match your IP range (e.g., /29 for 8 IP addresses).

    Fig. 6: Example of a completed configuration file.

Step 5: Save and apply changes

  1. Save the configuration and exit the editor:

    • Press Ctrl + X, then Y, and Enter, in nano,
  2. Restart the network service to apply the changes:
    $ sudo systemctl restart NetworkManager
  3. If the settings do not apply after restarting, reboot the server to ensure the configuration takes effect:
    $ sudo reboot

Step 6: Verify the configuration

  1. Once the server is back online, verify the assigned IP addresses by running the ip a command again:
    $ ip a
    You should see both the primary IP and the new subnet IP addresses listed under the appropriate interface (see Fig. 7).

    Fig. 7: Output of ip a command showing the added subnet.

Step 7: Test connectivity

  1. Finally, ping the new IP address from the subnet to test the connection:
    $ ping -c 5 <new-ip-address>
    Replace <new-ip-address> with one of the IPs from the subnet. A successful response indicates that the IP addresses are correctly configured.

Summary

Following these steps, you can successfully assign and configure a public IP subnet on your AlmaLinux 8-9 server. This setup enables multiple IP addresses for different services on a single server, enhancing scalability and flexibility for your network configuration. Verify the configuration and test the connectivity to ensure everything is working as expected.