This guide provides simple and clear instructions for configuring additional IP addresses on your existing Virtual Private Servers (VPS) using CubePath. It focuses solely on the IP configuration process, assuming that your VPS instances are already set up and running.

Prerequisites

Before you begin, ensure you have the following:

  • Dedicated Server Access: Root or sudo privileges on your dedicated server hosting the VPS instances.
  • Additional IP Addresses: Extra IPs allocated and assigned to your dedicated server.
  • VPS Instances: Existing virtual machines set up using CubePath.
  • Basic Linux Knowledge: Familiarity with command-line operations and network configuration.

Step 1: Enable IP Forwarding on the Dedicated Server

IP forwarding allows your dedicated server to route traffic between the external network and your VPS instances. Follow these steps to enable it:

  1. Access Your Dedicated Server via SSH

    Open your terminal or SSH client and connect to your dedicated server:

    ssh root@your_dedicated_server_ip

    Replace your_dedicated_server_ip with the actual IP address of your dedicated server.

  2. Enable IP Forwarding Temporarily

    To enable IP forwarding immediately (this setting will reset after a reboot):

    sudo sysctl -w net.ipv4.ip_forward=1

  3. Enable IP Forwarding Persistently

    To ensure IP forwarding remains enabled after reboots:

    echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf sudo sysctl -p

  4. Verify IP Forwarding

    Confirm that IP forwarding is enabled:

    sysctl net.ipv4.ip_forward

    Expected output:

    net.ipv4.ip_forward = 1

Step 2: Assign Additional IPs to the Dedicated Server

Assigning additional IPs to your server's network interface is essential before routing them to the VPS instances.

  1. Identify Your Network Interface

    Determine the name of your primary network interface (commonly eth0, ens18, etc.):

    ip addr

    Look for the interface connected to the internet.

  2. Edit the Network Configuration File

    Depending on your Linux distribution, edit the appropriate network configuration file:

    • For Debian/Ubuntu:

      sudo nano /etc/network/interfaces

    • For CentOS/RHEL:

      sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0

  3. Add Additional IPs

    Append the additional IP configurations. Use a /32 subnet mask for each additional IP to ensure proper routing.

    Debian/Ubuntu Example (/etc/network/interfaces):

    ```

    Primary IP Configuration

    auto eth0 iface eth0 inet static address [PRIMARY_IP] netmask 255.255.255.0 gateway [PRIMARY_GATEWAY]

    Additional IP 1

    auto eth0:0 iface eth0:0 inet static address [ADDITIONAL_IP_1] netmask 255.255.255.255

    Additional IP 2

    auto eth0:1 iface eth0:1 inet static address [ADDITIONAL_IP_2] netmask 255.255.255.255 ```

    CentOS/RHEL Example (/etc/sysconfig/network-scripts/ifcfg-eth0):

    ```

    Primary IP Configuration

    DEVICE=eth0 BOOTPROTO=static ONBOOT=yes IPADDR=[PRIMARY_IP] NETMASK=255.255.255.0 GATEWAY=[PRIMARY_GATEWAY]

    Additional IP 1

    DEVICE=eth0:0 BOOTPROTO=static ONBOOT=yes IPADDR=[ADDITIONAL_IP_1] NETMASK=255.255.255.255

    Additional IP 2

    DEVICE=eth0:1 BOOTPROTO=static ONBOOT=yes IPADDR=[ADDITIONAL_IP_2] NETMASK=255.255.255.255 ```

    Note: Replace [PRIMARY_IP], [PRIMARY_GATEWAY], [ADDITIONAL_IP_1], and [ADDITIONAL_IP_2] with your actual IP addresses.

  4. Save and Close the File

    In Nano, press Ctrl + O to save and Ctrl + X to exit.

  5. Restart the Network Service to Apply Changes

    Restart the network service based on your distribution:

    • Debian/Ubuntu:

      sudo systemctl restart networking

    • CentOS/RHEL:

      sudo systemctl restart network

  6. Verify IP Assignments

    Ensure that all additional IPs are correctly assigned:

    ip addr show eth0

    You should see the additional IPs listed under the primary network interface with a /32 subnet mask.

Step 3: Configure Networking for Each VPS

Each VPS needs to be configured to use its assigned additional IP with the correct network settings. Important: The gateway for each VPS should be set to the primary IP of the dedicated server (the node), and the additional IP should be configured with a /32 subnet mask.

1. Assign Additional IPs to VPS Instances via CubePath

Depending on CubePath's interface, you may need to assign the additional IPs to each VPS. Typically, you would:

  • Log in to your CubePath dashboard.
  • Navigate to the VPS management section.
  • Select the VPS you want to assign an additional IP.
  • Assign one of the additional IPs from your pool to the selected VPS.

Refer to CubePath's documentation for specific instructions if needed.

2. Configure the Network Interface Inside Each VPS

For Debian/Ubuntu-based VPS:

  1. Access the VPS via SSH

    ssh root@vps_ip_address

    Replace vps_ip_address with the current IP of the VPS.

  2. Edit the Network Configuration File

    sudo nano /etc/network/interfaces

  3. Add the Additional IP Configuration

    ```

    Primary IP Configuration

    auto eth0 iface eth0 inet static address [VPS_IP] netmask 255.255.255.255 gateway [DEDICATED_SERVER_PRIMARY_IP] ```

    Replace:

    • [VPS_IP] with the additional IP assigned to this VPS.
    • [DEDICATED_SERVER_PRIMARY_IP] with the primary IP of your dedicated server.
    • Save and Close the File

    In Nano, press Ctrl + O to save and Ctrl + X to exit.

  4. Restart the Network Service

    sudo systemctl restart networking

  5. Verify the Configuration

    ip addr show eth0

    Ensure that the additional IP is listed with the /32 subnet mask.

For CentOS/RHEL-based VPS:

  1. Access the VPS via SSH

    ssh root@vps_ip_address

    Replace vps_ip_address with the current IP of the VPS.

  2. Edit the Network Configuration File

    sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0

  3. Add or Modify the Configuration

    DEVICE=eth0 BOOTPROTO=static ONBOOT=yes IPADDR=[VPS_IP] NETMASK=255.255.255.255 GATEWAY=[DEDICATED_SERVER_PRIMARY_IP]

    Replace:

    • [VPS_IP] with the additional IP assigned to this VPS.
    • [DEDICATED_SERVER_PRIMARY_IP] with the primary IP of your dedicated server.
    • Save and Close the File

    In Nano, press Ctrl + O to save and Ctrl + X to exit.

  4. Restart the Network Service

    sudo systemctl restart network

  5. Verify the Configuration

    ip addr show eth0

    Confirm that the additional IP is correctly assigned with the /32 subnet mask.

3. Set the Default Gateway

Ensure that the default gateway in the VPS points to the dedicated server's primary IP.

ip route

Expected output:

default via [DEDICATED_SERVER_PRIMARY_IP] dev eth0

If the default route is incorrect, add or modify it:

sudo ip route add default via [DEDICATED_SERVER_PRIMARY_IP] dev eth0

Replace [DEDICATED_SERVER_PRIMARY_IP] with your dedicated server's main IP.

Step 4: Verify the Configuration

After completing the setup, ensure that everything is functioning correctly.

  1. Test Internet Connectivity from the VPS

    ping -c 4 8.8.8.8

    Successful replies indicate proper internet connectivity.

  2. Check IP Assignment

    ip addr show eth0

    Ensure that the additional IP is listed with the /32 subnet mask.

  3. Verify Routing Table

    ip route

    Ensure that the default route points to the dedicated server’s primary IP.

  4. Test Access to Services

    If you have services running on the VPS (e.g., web servers, SSH), verify that they are accessible via the assigned IP.

    For example, to test SSH access:

    ssh root@[VPS_IP]

    Replace [VPS_IP] with the additional IP assigned to the VPS.

Troubleshooting

If you encounter issues during or after the setup, consider the following steps:

1. No Internet Connectivity

  • Check IP Forwarding: Ensure that IP forwarding is enabled on the dedicated server.

sysctl net.ipv4.ip_forward

  • Verify Network Configurations: Ensure that both the dedicated server and VPS network configurations are correct.
  • Check Routing Tables: Confirm that the default gateway is set correctly in the VPS.

2. Additional IPs Not Responding

  • Confirm IP Assignment: Ensure that the additional IPs are correctly assigned to both the dedicated server and the VPSs.
  • Check for IP Conflicts: Ensure that no two devices are using the same IP address.
  • Verify Routing: Ensure that the routing tables on both the dedicated server and VPSs are correctly set up.

3. Routing Issues

  • Default Gateway: Ensure that the VPS’s default gateway points to the dedicated server’s primary IP.

ip route

  • NAT Configuration: If necessary, set up Network Address Translation (NAT) on the dedicated server to handle traffic appropriately.

4. DNS Configuration

  • DNS Settings: Ensure that DNS is correctly configured on the VPS for name resolution.

cat /etc/resolv.conf

Add DNS servers if necessary:

nameserver 8.8.8.8 nameserver 8.8.4.4

Conclusion

Configuring additional IPs on your virtualized VPS instances using CubePath involves enabling IP forwarding on your dedicated server, assigning additional IPs to both the server and VPSs with a /32 subnet mask, and ensuring that the default gateway for each VPS points to the node's primary IP. By following this guide, you can effectively manage multiple IP addresses across your VPS instances, enhancing your network's flexibility and scalability.

If you encounter any issues or need further assistance, consider reaching out to CubePath's technical support or consulting their official documentation for more detailed guidance.

Note: Always ensure that you replace placeholders (e.g., [PRIMARY_IP], [ADDITIONAL_IP_1], [DEDICATED_SERVER_PRIMARY_IP], [VPS_IP]) with your actual IP addresses and network information specific to your setup.