Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

robj's avatar
Level 9

Forge & Digital Ocean - using reserved IP for outbound traffic

Hi all. I'm using Digital Ocean & Forge to host some applictions and have a reserved IP.

I've changed the IP in the Forge control panel for the server to the reserved one and done things like rebooted the server however when I check what IP the application calls out from it uses the old one.

Googling doesn't seem to come up with anything other than the above so I'm left with changing the networking config on the server - does anyone know if that is correct?

I've pointed domains to the reserved IP and these are working OK.

Thanks, RobJ.

0 likes
1 reply
LaryAI's avatar
Level 58

To ensure that your server uses the reserved IP for outbound traffic, you need to configure the server's network settings to use the reserved IP as the source IP for outgoing connections. This typically involves modifying the network interface configuration on your server. Here's a general approach to achieve this:

  1. Identify Network Interface: First, identify the network interface associated with your reserved IP. You can use the ip addr command to list all network interfaces and their associated IP addresses.

    ip addr
    
  2. Modify Network Configuration: You need to modify the network configuration file for the identified interface. This file is usually located in /etc/network/interfaces on Ubuntu or /etc/sysconfig/network-scripts/ on CentOS/RHEL.

    For Ubuntu, you might add something like this to your /etc/network/interfaces file:

    auto eth0
    iface eth0 inet static
        address <your-reserved-ip>
        netmask <your-netmask>
        gateway <your-gateway>
    

    Replace <your-reserved-ip>, <your-netmask>, and <your-gateway> with the appropriate values for your network.

  3. Set Up IP Routing: You may need to set up IP routing rules to ensure that outbound traffic uses the reserved IP. This can be done using ip route and ip rule commands.

    ip route add default via <your-gateway> dev eth0 src <your-reserved-ip>
    
  4. Restart Networking Service: After making changes, restart the networking service to apply the new configuration.

    sudo systemctl restart networking
    
  5. Verify Configuration: Verify that the changes have taken effect by checking the outbound IP. You can use a service like curl ifconfig.me to see the IP address being used for outbound traffic.

    curl ifconfig.me
    
  6. Firewall and Security Groups: Ensure that any firewall or security group settings on Digital Ocean allow outbound traffic from your reserved IP.

By following these steps, your server should use the reserved IP for outbound traffic. If you encounter any issues, double-check the network configuration and ensure that there are no conflicting settings.

Please or to participate in this conversation.