Adding internal ip address of main domains

Geo Grav

Member
Feb 7, 2016
8
0
1
Victorial, Australia
cPanel Access Level
Root Administrator
We have a NAT'ed cpanel server and we have been find that some web plugins will look up the address for the and obtain the external address. Requests to that address will not come back to the server.

We have been manually adding entries into the /etc/hosts file to over come this issue.

Does someone have a script that will do this automatically?

As very rough pseudocode:
whmapi1 listaccounts
for each non-suspended account, get the ip address via dns.
if returned address is external server address, add the host-name alongwith internal address to /etc/hosts

Oh, there probably needs to be a remove step there also.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
We have been manually adding entries into the /etc/hosts file to over come this issue.

Does someone have a script that will do this automatically?

As very rough pseudocode:
whmapi1 listaccounts
for each non-suspended account, get the ip address via dns.
if returned address is external server address, add the host-name alongwith internal address to /etc/hosts

Oh, there probably needs to be a remove step there also.
Hello,

I'm not aware of any existing scripts that will perform those actions, however we provide a list of system admin services if you need help developing the custom script:

System Administration Services | cPanel Forums

Thank you.