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.

change site's ip from command line.

Discussion in 'General Discussion' started by kabaras, Apr 19, 2006.

  1. kabaras

    kabaras Member

    Joined:
    Apr 10, 2006
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    I can change site's ip from whm:
    Account Functions->Change Site's IP Address

    How can i do the same from command line?

    Thanks!
     
  2. kabaras

    kabaras Member

    Joined:
    Apr 10, 2006
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Guys, please help! It is very impotance for me.
     
  3. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    Perhaps we've all grown fat and lazy in our old age and never tried it. Well actually for me thinner and lazy but you get the idea.

    I suspect it goes something like:

    - Changeover DNS zone files to new IP addresses (edit them and update the serial numbers). This could be done manually, or with a tool to do it. It's not that hard to write a tool to do it. [But djbdns would be a much better solution :)] [ignore that comment!!] You could probably get away without increasing the serial numbers if you don't have an off-machine secondary server (which doesn't help much anyway) and you do a "service named restart" to reload the zones when you're done editing.

    - Edit /etc/httpd/conf/httpd.conf and modify the VirtualHosts container lines for each affected site. You should initially put *both* the new and the old IPs into the container lines, so that apache will listen on *both* new AND old IPs for the affected sites. Otherwise the sites will be unavailable until DNS propagation completes - probably not something you want! The reason for this is that the cpanel httpd.conf explicitly states which IPs each website will respond to in VirtualHosts lines, and you get a cpanel "no site configured" if you try to access the site on IPs other than those defined in httpd.conf. The VirtualHosts lines are the lines controlling which IPs will respond to which site, and they should go from what they are currently, ie with one IP, something like:
    Code:
    <VirtualHost 72.257.212.226>
    (ie just the old IP) to
    Code:
    <VirtualHost 72.257.212.226 72.257.212.227>
    (ie both the new and old IPs while you wait for DNS to settle), to:
    Code:
    <VirtualHost 72.257.212.227>
    (ie just the new IP after DNS propagation has settled). You want to wait at least 72 hours for propagation to complete - some large ISPs offer special cache machinery which ignores TTLs as a trade-off for speed, so they'll need a good 24 hours to clear out the old IP. Note that other services like mail and ftp (AFAIK) don't care about the IP on which the request arrives so shouldn't cause problems.

    BTW, if you want to change *all* the sites on the server, go for cpanel's wonderful IP migration Wizard. You may have to add NameVirtualHost entries to httpd.conf for each new IP after it completes, but that's about it (except, give it a full 48 hours, 72 is better, after the first pass before you "complete" the operation in WHM). This tool is only lacking the ability to do migrations of subsets of the system (eg by reseller) and the ability to automatically complete an operation ("at" is your friend).

    Don't try and change the server main IP since the cpanel licence is generated off it, and cpanel will probably stop working rather suddenly and you may end up unable to log in via ssh. :confused:

    I don't really know for sure whether this is all that's involved. There may be something in /var/cpanel so a good "grep -r 72.257.212.226 /var/cpanel /usr/cpanel" would probably help in discovering that. Perhaps someone more knowledgeable than myself would care to comment.

    Hey let us know how you go with this, if it you try it manually and it works out for you I could write some perl/PHP to automate it, possibly even a WHM addon if I get overexcited or have a sleepless night.... anybody done this and wanna comment on my above methods?
     
    #3 brianoz, Apr 20, 2006
    Last edited: Apr 20, 2006
  4. Kasper

    Kasper Active Member

    Joined:
    Aug 26, 2004
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Chicago
    Hello,

    Probably you want to try to use
    /scripts/updatedomainips

    :D
     
  5. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    Hey Kasper, thanks for the guess, but as far as I can see all updatedomainips does (despite the promising name!) is rebuild /etc/domainips, and call /scripts/buildpureftproot. For a moment there I thought someone had already done the hard work.

    I had to spend 30 minutes reading bad perl code to understand this, I wish Cpanel could learn to comment their stuff - as in "this script does this" (this is not to dis cpanel, they have produced a result beyond what I could have done, just dising their coding!).
     
Loading...

Share This Page