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.

Seamless way to change IP on website

Discussion in 'General Discussion' started by control1110, Nov 20, 2009.

  1. control1110

    control1110 Registered

    Joined:
    Nov 20, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    I have a dedicated server with 5 ips. I want to change the ip for one of my sites to a different ip. I am told pretty much the site has to be down for a few hours while it propagates.My host tell me there is nothing I can do, but let it be down. Is there a Seamless way to change this?
     
    #1 control1110, Nov 20, 2009
    Last edited: Nov 20, 2009
  2. JawadArshad

    JawadArshad Well-Known Member
    PartnerNOC

    Joined:
    Apr 8, 2008
    Messages:
    447
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    PK
    cPanel Access Level:
    DataCenter Provider
    You can change TTL in the DNS zone of the site to a much lower value and change the site's IP after the current value of TTL before editing. Say your current value of TTL is 86400, you can lower this value and change site's IP after 24 hours (86400 seconds).
     
  3. InstaCarma_Tech

    InstaCarma_Tech Well-Known Member

    Joined:
    Apr 22, 2009
    Messages:
    228
    Likes Received:
    1
    Trophy Points:
    18
    Nowadays, DNS propagation does not take long hours. If you do it in the off-peak hours then you should be all good.
     
  4. wizzy420

    wizzy420 Well-Known Member

    Joined:
    Nov 13, 2007
    Messages:
    125
    Likes Received:
    2
    Trophy Points:
    18
    OP, don't take this persons advice and blindly do it at "off-hours". The propagation can take as long as the TTL is set for.

    Listen to the other person. Check the TTL values on the zone and hostnames, note what they are. Propagation can take up to that many seconds. If you're okay with it, then do it.

    If not set the TTL low (like 300 = five minutes) and then after updating zone wait at least (old TTL seconds) before changing the IP. Once you have done the change you can up the TTL.

    If you have the TTL set to 86400 and listen to the advice of "do it off-peak" you really will have some people not getting the site up to 24-hours later, with an average prop time of 12-hours.
     
  5. eth00

    eth00 Well-Known Member
    PartnerNOC

    Joined:
    Mar 30, 2003
    Messages:
    723
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    NC
    cPanel Access Level:
    Root Administrator
    If you don't mind getting your hands dirty and are familiar with apache take a copy of the domains vhost and put it in one of the configs that cpanel has that do not get updated. Then change the ip. Now you will have 2 vhosts, one for the old IP and one for the new. No matter what IP they hit they still get the site.

    If you don't do it this way lowering the TTL a few days before and then doing it late at night is your best bet.
     
  6. d_t

    d_t Well-Known Member

    Joined:
    Sep 20, 2003
    Messages:
    243
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Bucharest
    eth00 is right, this is the best way to do (having 2 vhosts until new IP propagate). This should be a feature for next cPanel versions.
     
  7. madaboutlinux

    madaboutlinux Well-Known Member

    Joined:
    Jan 24, 2005
    Messages:
    1,052
    Likes Received:
    2
    Trophy Points:
    38
    Location:
    Earth
    What "eth00" said is possible but what "InstaCarma_Tech" said is not false either. Nowadays, propagation does take a 2-3 hours and if you change the website IP during off hours, you should be fine.
     
  8. d_t

    d_t Well-Known Member

    Joined:
    Sep 20, 2003
    Messages:
    243
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Bucharest
    @madaboutlinux, do you think few years ago DNS propagation took more? It's all about TTL but some ISP DNS servers ignore the value from the zone and keep the old info in cache. More, if you check the logs after you move a website, you can see that some spiders (like yahoo) keep visiting the old IP for days.

    Why should you have a website down for 2-3 hours when you can keep it alive on the old IP (whenever is possible).
     
  9. eth00

    eth00 Well-Known Member
    PartnerNOC

    Joined:
    Mar 30, 2003
    Messages:
    723
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    NC
    cPanel Access Level:
    Root Administrator
    Exactly! It only takes a few minutes to setup the other vhost, really 1-2 if you know what you are doing. That 1-2 minutes will save you a lot of possible headaches, why not just do it?
     
  10. keddie

    keddie Well-Known Member

    Joined:
    Nov 17, 2007
    Messages:
    50
    Likes Received:
    0
    Trophy Points:
    6
    I have a similar need to migrate an important account to a new IP.

    Having an apache vhost entry for both IPs sounds like a good solution.

    Would this work with SSL?
     
  11. keddie

    keddie Well-Known Member

    Joined:
    Nov 17, 2007
    Messages:
    50
    Likes Received:
    0
    Trophy Points:
    6
    So, I've been doing some experimenting with the duplicate vhosts on a test domain.

    I've been using the following doc for guidance:

    cPanel - The Easy Apache Configuration System - Adding Custom Directives to httpd.conf

    My first mistake was to take the httpd.conf comments too literally:

    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/std/2/test/test.abc123.co.uk/*.conf"

    I created an include file in the specified location which consisted of a copy and paste of the standard (non SSL) vhost section in httpd.conf. I then ran:

    /scripts/verify_vhost_includes

    Which returned:

    Testing /usr/local/apache/conf/userdata/std/2/test/test.abc123.co.uk/std.conf...ok

    then I ran:

    /scripts/ensure_vhost_includes --user=test

    Which returned:

    Syntax error on line 1 of /usr/local/apache/conf/userdata/std/2/test/test.abc123.co.uk/std.conf:
    <VirtualHost> cannot occur within <VirtualHost> section

    So I now see that using this kind of include won't work for creating duplicate vhosts as it applies literally to the directives *within* the <VirtualHost> tags.

    I'm now thinking I need to use another included method...
     
    #11 keddie, Nov 30, 2009
    Last edited: Nov 30, 2009
  12. keddie

    keddie Well-Known Member

    Joined:
    Nov 17, 2007
    Messages:
    50
    Likes Received:
    0
    Trophy Points:
    6
    The solution is extremely simple and it works with SSL :)

    Here's what I did:

    1) Edit /usr/local/apache/conf/httpd.conf and copy the current vhost entries that you want to duplicate.
    2) In WHM, go to: Main >> Service Configuration >> Apache Setup >> Include Editor.
    3) Scroll down to "Post VirtualHost Include" and select "All versions" from the dropdown.
    4) Paste the vhost directives in to the box and then update the IP addresses to the new ones.
    5) Click "Update" then "Restart Apache"

    I used my local hosts file to test the new aliased IPs and they worked great.

    Thanks for the pointers OPs

    Al
     
  13. paulkoan

    paulkoan Well-Known Member

    Joined:
    Nov 24, 2006
    Messages:
    80
    Likes Received:
    0
    Trophy Points:
    6
    The term "propagate" suggests to many that something actually is moving across the internet and is no doubt the source of the earlier poster's confusion in thinking that this movement will somehow go quicker at "night" when things are less busy.

    It is a convenient word to use for those who understand what it is actually saying but we could do with something else for those who don't.

    To anyone happening across this thread, it works like this: You request the IP for a server from your local DNS server. The DNS server will go and ask the authoritative DNS server for that domain, who will respond with the IP address, plus a TTL value which lets the local DNS server know how long that response is good for. Lets say it gives a TTL of a week. This means that for subsequent requests for this same server, the local DNS server will not bother asking the authoritave DNS as it already knows the answer - until the week expires.

    So if you change your IP address during this week, then this change will not 'propagate' to this local DNS server until a week has passed since the last time it asked, whereupon it will go back to the authoritative DNS server and get the new IP.

    As DNS servers all over the planet will be asking the question at different times, some will update immediately, some will take a full week.
     
Loading...

Share This Page