When you create a server from a Snapshot or Backup, or clone it, some files still contain the old IP address. As a result, the domain will not work and will point to the old IP address. To make it work, you will need to update those files with the current IP address.
In this article, we refer to the source IP address and the destination IP address. Wherever [IP_ORIGEN] appears in the commands below, replace it with the source IP address, and wherever [IP_DESTINO] appears, replace it with the destination IP address.
Steps to update the IP address in HestiaCP
Start by modifying the file /etc/apache2/conf.d/ip_origen.conf. You will need to copy it using the name new _IP.conf and replace the old IP address with the new one:
# mv /etc/apache2/conf.d/[ip_origen].conf /etc/apache2/conf.d/[ip_destino].confThen use this command to verify that it has been modified:
# cat /etc/apache2/conf.d/[ip_destino].confDo the same for the nginx server:
# mv /etc/nginx/conf.d/[ip_origen].conf /etc/nginx/conf.d/[ip_destino].confVerify that it has been modified:
# cat /etc/nginx/conf.d/[ip_destino].confNow modify a series of files where only the contents need to change. You can do this using the same command with two different paths:
# find /etc -iname '*.conf' -exec sed -i -r 's/[ip_origen]/[ip_destino]/g' {} \;
# find /usr/local/hestia -iname '*.conf' -exec sed -i -r 's/[ip_origen]/[ip_destino]/g' {} \;You will also need to change the IP address in IpTables
sed -i 's/[ip_origen]/[ip_destino]/g' /etc/iptables.rulesModify the file and rename it to the new IP address.
# mv /usr/local/hestia/data/ips/[ip_origen] /usr/local/hestia/data/ips/[ip_destino]Before continuing, reboot the server to restart all services.
Finally, this command will update HestiaCP with everything it needs. Remember to run it for each user:
# v-rebuild-all admin yesAlso, keep in mind that some addresses may not have been changed, so you will need to change them manually. To do this, we recommend running a recursive grep to search for the source IP address in /etc/:
# grep -HRF "ip.de.origen" /etc/*