Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix local IP in Nat Configuration on WHM/Cpanel on Centos 6 on Google Compute Engine

If you deleted a VM on Google Compute Engine on a Centos 6 Cpanel server and then create it with the same disk, you often are assigned a new local IP address even if you kept the static IP. This does not properly update in the NAT configuration on Cpanel/WHM servers.

This stops any sites from working and the only way to fix it is manually edit the http.conf file. Inside Web Host Manager you can fix the public facing IP, but there is no place to edit the local IP. Does anyone know how to edit the nat configuration on centos 6 on Google Compute Engine to fix the local IP so that all new sites created will have the correct local IP in the http.conf?

Here is a pic of the current nat configuration on my Centos 6 server. enter image description here

Here is a pic showing my correct local IP in Compute Engine, you can see it does not match the one Cpanel has, which causes the http.conf file to generate new virtual hosts with the wrong IP. enter image description here

like image 720
Michael Falciglia Avatar asked Dec 05 '25 13:12

Michael Falciglia


2 Answers

Its a configuration issue within WHM/Cpanel that can not be corrected with any configuration settings in the interfaces. I contacted Cpanel Support and they provided me with a command line shell script to run from root to fix the issue. It worked flawlessly:

# /scripts/build_cpnat

This resolved the issue, but they gave this additional info if that does not solve your problem:

If this does not resolve your issue, please review our NAT documentation and ensure that your server is configured in a supported 1:1 NAT configuration: http://documentation.cpanel.net/display/ALD/1%3A1+NAT

like image 80
Michael Falciglia Avatar answered Dec 07 '25 05:12

Michael Falciglia


The Compute Engine does not allow you to create an instance with a specific network IP address. You will have to use a combination of routes and an instance's --can-ip-forward ability to add an IP address as a static network IP address that then maps to your desired virtual machine instance.

For example, if you want to assign 10.1.1.1 specifically as a network IP address to a virtual machine instance, you can create a static route that sends traffic from 10.1.1.1 to your instance, even if the instance's network IP address assigned by Compute Engine doesn't match your desired network IP address.

Take a look at this link: https://cloud.google.com/compute/docs/instances-and-network#staticnetworkaddress

like image 31
Kamran Avatar answered Dec 07 '25 05:12

Kamran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!