Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED Server Main IP Change

Discussion in 'Bind / DNS / Nameserver Issues' started by Krydos, Oct 10, 2017.

  1. Krydos

    Krydos Well-Known Member

    Joined:
    Jun 2, 2012
    Messages:
    48
    Likes Received:
    4
    Trophy Points:
    58
    cPanel Access Level:
    Root Administrator
    I recently changed the main IP address of one of my servers. The reason was because of a licensing issue with another paid service, and I couldn't change the IP in their system so I just started a new license on a fresh IP. But my reasons for changing the IP don't really matter.

    The issue I'm having now is I can't get the IP in httpd.conf to update. I tried manually editing it, and then immediately running /usr/local/cpanel/bin/apache_conf_distiller --update but the old IP came right back after I did /scripts/rebuildhttpdconf

    Any ideas of what to try next? I don't really want to have to move every single account to another server, wipe this one, and reinstall a fresh OS and cpanel just to change the ip in httpd.conf. That seems like overkill, and a huge waste of time.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,424
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You will need to change the IP address assigned to the accounts to ensure it's updated in the Apache configuration file and DNS zone. The following option is available for this purpose:

    "WHM Home » Multi Account Functions » Change Multiple Sites’ IP Addresses"

    Or, you could also use the following feature:

    "WHM Home » IP Functions » IP Migration Wizard"

    Thank you.
     
  3. SB-Nick

    SB-Nick Well-Known Member

    Joined:
    Aug 26, 2008
    Messages:
    175
    Likes Received:
    9
    Trophy Points:
    68
    cPanel Access Level:
    Root Administrator
    Assuming your network config in /etc/sysconfig/network-scripts is properly setup, have you updated your server IP under WHM > Basic cPanel & WHM Setup?

    There is also an utility in Home > Main > Account Functions >> Change Site's IP Address.
     
  4. Krydos

    Krydos Well-Known Member

    Joined:
    Jun 2, 2012
    Messages:
    48
    Likes Received:
    4
    Trophy Points:
    58
    cPanel Access Level:
    Root Administrator
    I was under the impression that the basic setup option was which IP new accounts would be created on, rather than the server's main IP. Likewise I figured the IP migration tool was to move user accounts not the server's main IP. I guess I'll try it.
     
  5. Krydos

    Krydos Well-Known Member

    Joined:
    Jun 2, 2012
    Messages:
    48
    Likes Received:
    4
    Trophy Points:
    58
    cPanel Access Level:
    Root Administrator
    Neither the IP Migration Wizard nor the Change A Site's IP Address page lists the server's main domain...
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,424
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Could you clarify which IP address you are attempting to change? There's technically no "main domain" on a cPanel server. What's the specific entry in the Apache configuration file you are attempting to modify?

    Thank you.
     
  7. Krydos

    Krydos Well-Known Member

    Joined:
    Jun 2, 2012
    Messages:
    48
    Likes Received:
    4
    Trophy Points:
    58
    cPanel Access Level:
    Root Administrator
    Ok, I know you all hate when people use actual IPs and actual host names, but here goes.

    Say my companies main website is example.com and all of our servers are named something like one.example.com and two.example.com, etc.

    Then our servers have user accounts on them like userdomain1.com and userdomain2.com.

    I'm trying to change the IP of one.example.com. I already have the DNS set up, and everything else is working, but I can't get the httpd.conf to update. Here's some obfuscated snippets of httpd.conf:

    Code:
    PidFile /usr/local/apache/logs/httpd.pid
    LockFile /usr/local/apache/logs/accept.lock
    Listen 0.0.0.0:80
    Listen [::]:80
    User nobody
    Group nobody
    ExtendedStatus On
    ServerAdmin email@address.com
    ServerName one.example.com
    LogLevel warn
    
    ...
    
    <VirtualHost 64.x.x.x:80>
        ServerName userdomain1.com
        ServerAlias mail.userdomain1.com www.userdomain1.com
        DocumentRoot /home/user/public_html
        ServerAdmin webmaster@userdomain1.com
        UseCanonicalName Off
    
    ...
    
    <VirtualHost 64.x.x.x:80 127.0.0.1:80> # <---- THIS IS THE LINE I'M TRYING TO CHANGE
        ServerName one.example.com
    
        ServerAlias cpanel.* whm.* webmail.* webdisk.* cpcalendars.* cpcontacts.*
    
        DocumentRoot /usr/local/apache/htdocs
        ServerAdmin email@address.com
    
    ...
    
    The user accounts can and preferably should stay on 64.x.x.x, but I want the main server IP and the server name virtual host to change to 65.y.y.y
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,424
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Do you see references to the old IP address in the user data files within the /var/cpanel/userdata/nobody/ directory?

    Thank you.
     
  9. Krydos

    Krydos Well-Known Member

    Joined:
    Jun 2, 2012
    Messages:
    48
    Likes Received:
    4
    Trophy Points:
    58
    cPanel Access Level:
    Root Administrator
    Yes! That was what I was missing.

    For completeness of this thread, here is the process I took to change the main IP of a cpanel/whm server from 64.x.x.x to 65.y.y.y:

    --- WARNING! WARNING! WARNING! ---
    Messing up the IP settings on your server can leave your machine unable to connect to the internet thereby locking yourself out. Don't proceed unless you know what you're doing or you have a good backup plan to regain access in the case of a mistake.
    --- WARNING! WARNING! WARNING! ---

    Add the new IP at WHM >> IP Functions >> Add a New IP Address with the proper subnet mask.
    Edit /etc/sysconfig/network-scripts/ifcfg-eth0 and change the IPADDR= and the GATEWAY= lines to the new values.
    Edit /etc/ips and remove the new main IP 65.y.y.y and replace it with the old main IP in the format 64.x.x.x:<subnet mask>:<gateway>
    Edit /var/cpanel/mainip and replace the old IP 64.x.x.x with the new one 65.y.y.y
    Edit /etc/hosts and replace the old IP 64.x.x.x with the new one 65.y.y.y
    Restart the network service. On older init.d OS like CentOS 6 this is /sbin/service network restart or on newer systemd like CentOS 7 this is systemctl restart network.service
    You WILL lose your ssh connection at this point. If you did everything right you should be able to reconnect.
    Restart the ipaliases. On older init.d OS like CentOS this is /sbin/service ipaliases restart or on newer systemd like CentOS 7 this is systemctl restart ipaliases
    Go to WHM >> DNS Functions >> Edit DNS Zone
    Locate your server's main domain, and edit all 64.x.x.x to 65.y.y.y
    Log in to your cpanel account and update your license to the new IP address. If you don't do this your cpanel/whm will soon say it isn't licensed.
    Run /usr/local/cpanel/cpkeyclt to update the license to the new IP.

    OPTIONAL: Create your reverse DNS to the new IP address. This is beyond the scope of this guide, and only needed if you're going to send mail from this server's IP.

    That is where I got stuck, and with cPanelMichael's help I did the following:

    Rename /var/cpanel/userdata/nobody/64.x.x.x to 65.y.y.y and change all instances of the IP inside that file as well.
    Rename /var/cpanel/userdata/nobody/64.x.x.x.cache to 65.y.y.y.cache and change the IPs inside too.
    Edit /var/cpanel/userdata/nobody/main and main.cache to use the new IP.
    Then run /scripts/rebuildhttpdconf
    Then run /scripts/restartsrv_apache

    It all seems to be working now. Thanks everyone!
     
    #9 Krydos, Oct 10, 2017
    Last edited: Oct 10, 2017
Loading...

Share This Page