Find the answer to your Linux question:
Results 1 to 8 of 8
Hello, i have an CentOS (Redhat) Linux server and on it is installed OpenVZ which allows creating virtual machines there. Now to my CentOS host server is pointed a few ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User postcd's Avatar
    Join Date
    Apr 2011
    Posts
    346

    How to redirect an IP to a new IP


    Hello,

    i have an CentOS (Redhat) Linux server and on it is installed OpenVZ which allows creating virtual machines there.

    Now to my CentOS host server is pointed a few IP-RIPE addresses, these IPs are mentioned in several domains nameservers, i want to migrate virtual machines to another server and my question is how i can achieve that websites which domains pointing to old server will resolve and work and load from a new server? (meaning there will be redirection on server which redirect old ip request to a new IP of new server) If it would be possible, redirecting all kind of requests, but for simplicity, HTTP most important

    Thank you
    "Avoid the Gates of Hell. Use Linux affordable VPS."

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,422
    My suggestion is to update the dns zone files.
    You must always face the curtain with a bow.

  3. #3
    Linux User postcd's Avatar
    Join Date
    Apr 2011
    Posts
    346

    Question

    Quote Originally Posted by Irithori View Post
    My suggestion is to update the dns zone files.
    Thanks, i edited: /home/vps/190/home/apache/conf/domains/mydomain.com.conf

    and replaced IPs there by new IPs, but the website still loading OK, i even added some random IP..

    <VirtualHost \
    XX.XX.XX.XX:80\
    XX.XX.XX.XX:443\
    >

    ServerName mydomain.com
    ServerAlias \
    www.mydomain.com

    DocumentRoot "/home/admin/mydomaindirectory/"
    Do you mean this, or another way how to achieve it?
    "Avoid the Gates of Hell. Use Linux affordable VPS."

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,422
    Assuming the new server also has a public IP, the workflow would be:
    - configure the new webserver and possibly other daemons (ntp, rsyslog, db, mail, etc)
    - copy/import/migrate data from the old machine
    - test the new services and content via IP or better via staging hostnames
    - lower the ttl of the dns zones containing the records of your old server
    - Modify the records to point to the new server


    Sent from my GT-I9505 using Tapatalk
    You must always face the curtain with a bow.

  6. #5
    Linux User postcd's Avatar
    Join Date
    Apr 2011
    Posts
    346

    Question

    Quote Originally Posted by Irithori View Post
    - lower the ttl of the dns zones containing the records of your old server
    - Modify the records to point to the new server
    I would appreciate if anyone can help with these two, i have centos redhat, but i dont know which files i need to edit and how to input the new IP to the file. That is why i quoted what i quoted in my first post.
    "Avoid the Gates of Hell. Use Linux affordable VPS."

  7. #6
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,422
    It depends whether you maintain the DNServers yourself or if you use the ones of your domain registrar.
    If the dns is with the domain registrar, then there will be a way for customers to change their own zones. e.g. via a web gui.
    If you host your own dns, then you can edit the zone files there.
    You must always face the curtain with a bow.

  8. #7
    Linux User postcd's Avatar
    Join Date
    Apr 2011
    Posts
    346

    Lightbulb

    Quote Originally Posted by Irithori View Post
    It depends whether you maintain the DNServers yourself or if you use the ones of your domain registrar.
    If the dns is with the domain registrar, then there will be a way for customers to change their own zones. e.g. via a web gui.
    If you host your own dns, then you can edit the zone files there.
    Thanks, my aim is to prevent any downtime between transfer and customer changing his nameservers on registar.

    Thats why i want to do redirection to a new IP instantly after transfer of files....

    But i just dont know in which file to do it and how it can look like?
    "Avoid the Gates of Hell. Use Linux affordable VPS."

  9. #8
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,422
    If both servers have the same content, and the new server has been tested, then there will be no downtime via the dns method.
    There will be a timeframe, where browsers still get the old IP and therefore hit the old server. This is why I said to lower the ttl.
    After the ttl has passed and you see no more requests on the old webserver, you can then shutdown/decomission the old machine.

    Even if you redirect the requests from the old machine to the new via iptables, then you *still* have to do the changes in the dns zones.
    Otherwise, the old machine stays a dependency to the service and adds complexity and is a SPOF.
    You must always face the curtain with a bow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •