While a static IP address provides a fixed address for each server, floating IP addresses can be moved from one server to another as needed.
A floating IP address helps handle various services or applications on the same server. This guide will explain how to set up a floating IP address on your server by editing the network interfaces configuration file using “NetworkManager”.
Some key points to consider:
- This guide applies to VPS, VDS, and Bare Metal servers running AlmaLinux 8 and 9.
- RockyLinux 8 and 9 are only available for VPS/VDS servers.
- CloudLinux 7 is only available for Bare Metal servers.
- CentOS 7 and 8 are available for VPS, VDS, and Bare Metal servers.
- AlmaLinux, RockyLinux, CloudLinux, and CentOS use "NetworkManager" for network configurations.
- Ensure you have root access to the server.
Step-by-Step instructions
Step 1: Access the Client Portal
- Log in to your client portal.
- Click on the "Network" button at the top of the menu bar (see Fig. 1).
Fig. 1. Accessing the” Network” section in the client portal.
Step 2: Verify your floating IP address
- In the "Network" section, confirm that a floating IP address is linked to an instance.
- Assign it using the "Attach +" button (see Fig. 2).
Fig. 2. Verify and attach a floating IP address in the client portal.
Step 3: Identify your primary network interface
- Use the “ip route” command to find the primary network interface (see Fig. 3):
$ ip route show default
Fig. 3. The ”ip route show default” command output indicates the primary network interface (eth0).
This command will show the default route, which includes the primary network interface (e.g., eth0, bond0).
Step 4: Configure the Floating IP address manually
- Optional: Install the “nano” text editor if you prefer it over “vi” (which is pre-installed):
$ sudo dnf install nano
- Change the directory to the network-scripts directory:
$ cd /etc/sysconfig/network-scripts/
- Identify the appropriate configuration file for your network interface (e.g., ifcfg-eth0) (see Fig. 4):
$ ls
Fig. 4. The output of the "ls" command shows the network configuration files, including "ifcfg-eth0" for the already identified "eth0" interface. - Edit the identified network interface configuration file:
$ sudo nano ifcfg-eth0
or use “vi”:$ sudo vi ifcfg-eth0
- Under the current configuration, add your new floating IP address using the /32 subnet notation (e.g., 93.115.24.186/32). This should be added below your primary IP address (see Fig. 5).
Example configuration:
Fig. 5. Add the Floating IP configuration
- Save the changes:
- In “nano” : Press Ctrl + X, Y, and Enter to save.
- In “vi” : Press Esc, type :wq, and press Enter to save and exit.
- Restart the networking service to apply the changes:
$ sudo systemctl restart NetworkManager
Step 5: Verify configuration persistence
- Verify your IP addresses (see Fig. 6):
$ nmcli device show eth0
Fig. 6. The output of the ”nmcli device show eth0” command shows the primary and floating IP addresses. - Test connectivity:
$ ping -c 5 93.115.24.186
Replace the IP address with your own and check that the floating IP address responds correctly.
Summary
Following these steps, you can successfully set up a floating IP on your AlmaLinux server, ensuring it remains persistent through reboots. This process allows for flexible IP management and improves the scalability and reliability of your services.