Tag: amazon ec2 cpanel

  • Amazon Ec2 Fixing Cpanel IP after restore from snapshot

    On an Amazon EC2 server running Cpanel, i had to restore from Snapshot as some data was missing. Once restored, i changed Elastic IP to new EC2 instance. But sites did not work. This is because Internal IP of EC2 instance got changed when you restore from snapshot.

    In httpd.conf VirtualHosts where using old internal IP 10.0.0.200. But this IP was no longer available in the server, new Internal IP was 10.0.0.204.

    rm -f /var/cpanel/cpnat
    /scripts/build_cpnat
    

    Check if sites are still using old internal IP address

    grep -RH "ip: 10.0.0.200" /var/cpanel/userdata/*  
    

    To change IP, you need to do the following

    WHM >> Home >> Multi Account Functions >> Change Multiple Sites’ IP Addresses

    1. Select all the accounts showing 10.0.0.200 for the current ip
    2. Select “Change IPs of Selected Accounts”
    3. In the New Address dropdown, you would select the External IP for all the accounts
    4. Select Change IPs

    In Change Multiple Sites’ IP Addresses, drop down listed 52.4.207.175 (Elastic IP Address) and 10.0.0.204. I selected 52.4.207.175 for all sites and is working fine now.

    Now rebuild httpd.conf file with

    /scripts/rebuildhttpdconf 
    

    See Cpanel Server Behind NAT (Amazon AWS), Cpanel Server