Inquiry for server ip change. What steps should I follow ?

Discussion in 'ISPConfig 3 Priority Support' started by etruel, Nov 22, 2023.

Tags:
  1. etruel

    etruel Member HowtoForge Supporter

    I was looking for change server IP in the forums, but I did not find anything relevant, so this is the problem

    I was notified from the hosting that I will have to schedule a maintenance window for a v4 IP change (I have 5 v4 IPs and 3 v6 IPs) using at least 2 or 3 of them in different things.

    They would change the IPs in the OS (Linux 10 Buster), but I don't know what to take into account or steps to follow for the changes in ISPConfig.
    I have version 3.2.9p1 installed with several clients, about 20 sites, email accounts, and DNS for all that.

    NOTE (just in case): I have Roundcube, and when I bought the service one or two of the current IPs came dirty and blocked by some servers, so I think the change is good in that sense.
    I currently have Postfix configured to use Mailjet's external service for the domains that were blocking the IP (I could probably remove this with the IP change, but I would test it first).

    I know that there are many records in the DB with IP fields and also all the files that ISPConfig changes or creates that have the IP in their settings like some apache files....
    So what would be the best way to make these changes work well on ISPConfig?

    Thanks in advance for any help. Just tell me if you need more info or I missing something.
     
  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

  3. etruel

    etruel Member HowtoForge Supporter

    OK, that's weird as I find for that before but nothing found.
    Thanks Th0m.
    So, based on those topics should be:
    • Update /etc/hosts
    • Update /etc/network/interfaces
    • Update /etc/resolv.conf
    • Update the IP for the server in ISPConfig3 under "Server IP Addresses"
    • Code:
      ispconfig_update.sh --force
    First three will be make by the hosting, I would do last two.
    BUT what about the DNS entries and so on ? For example, I have many records with different IPs for NS...
    Do you think that after those steps I should do a search and replace in all ISPConfig tables for the old IPs by the new ones?
     
  4. pyte

    pyte Well-Known Member HowtoForge Supporter

    You have to update every DNS entry that pointed to the old ISPConfig Server/IP Adresse to the new one. All internal as well as all external records that might point to it.
     
  5. etruel

    etruel Member HowtoForge Supporter

    Thanks for the answer. Yes, I understand that, but I am looking for a more optimal way to do it than manually one by one because there are hundreds of records.
    And I think the ispconfig_update will not modify any records saved by the user.
     
  6. pyte

    pyte Well-Known Member HowtoForge Supporter

    You can just run a SQL Query on the database that updates the values to the new IP.

    The tables in question are dns_rr and dns_soa.
     
  7. etruel

    etruel Member HowtoForge Supporter

    This will have a right impact on Bind to take the correct IPs for the DNS records ? Or only affects the DB for ISPConfig ?
     
  8. pyte

    pyte Well-Known Member HowtoForge Supporter

    Trying to remember how i've done this in the past.
    You should use the API as ISPConfig will not be aware of the changes directly in the database.

    I can post a few more details tomorrow if you want
     
    Last edited: Nov 23, 2023
  9. etruel

    etruel Member HowtoForge Supporter

    Just trying to make a step by step guide to implement the changes without forgot nothing.
    After 5 steps I said above... I think... (after read a lot of topics)
    Maybe Resync Tool --> All services and DNS records would do the work after change the IPs in DB tables ?

    Yes please, everything is welcome as I am still looking for the right steps among a lot of old and new info.
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    Yes, you can use resync function to write out new config files.
     
    etruel, Th0m and pyte like this.
  11. pyte

    pyte Well-Known Member HowtoForge Supporter

    So with the API you can use it like shown in the following example.
    Code:
    $dns_records = $client->dns_a_get($session_id, array('data' => '%10.10.10.10%'));
    This will return every A record that has the IP 10.10.10.10 set in the data field. So all you have to do is, grab all the records that have to old IP address, loop through them and set the new address. Like so:

    Code:
    $dns_records = $client->dns_a_get($session_id, array('data' => '%10.10.10.10%'));
    
    foreach($dns_records as $record) {
    
      $client_data = $client->client_get_id($session_id, $record['sys_userid']);
      $record['data'] = '20.20.20.20';
     
      try {
        affected_rows = $client->dns_a_update($session_id, $client_data, $record['id'], $record);
        echo " Updated: " . $record['zone'];
      } catch {
        echo " Failed: " . $record['zone'];
        echo $client->_getLastResponse();
        die('SOAP Error: '.$e->getMessage());
      }
    }
    
    This is untested!
     
    etruel and Th0m like this.
  12. etruel

    etruel Member HowtoForge Supporter

    OK, I already have several steps that I believe would make up everything needed for the complete change of IPs.
    I will try to put it together here for others to use and then update it if I run into problems or find that there are other extra steps.

    If you see that I have some concept or steps wrong please correct me.

    From what I understood from Till answer with the Resync tools should not be necessary to do the script with the API calls and it can be done easier with some queries through phpmyadmin and do the resync later.
    I found these items by making a search in PHPmyadmin, database: dbispconfig
    These will be repeated for each IP (more or less)
    Code:
    Show search criteria
    Search results for "173.XX.XX.XX" at least one of the words:
    22 matches in dns_rr    Browse    Delete
    4 matches in dns_soa    Browse    Delete
    2 matches in monitor_data    Browse    Delete
    2 matches in remote_user    Browse    Delete
    1 match in server_ip    Browse    Delete
    3 matches in sys_datalog    Browse    Delete
    Total: 34 matches
    
    So, these are the steps that I was gathering:
    1. Update /etc/hosts
    2. Update /etc/network/interfaces
    3. Update /etc/resolv.conf
    4. Update the IP for the server in ISPConfig3 under "Server IP Addresses"
    5. ispconfig_update.sh --force
    6. Change all the IPs by the new ones with queries for Search and replace by table inside PHPmyadmin
    7. Do the Resync Tool for All services and DNS records. (Or maybe for all checkboxes there)
     
  13. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Do not replace the content in monitor_data and sys_datalog. The tables dns_rr, dns_soa, remote_user, and server_ip should all be OK to alter with your batch replacement.

    If you replace the content in server_ip, your step 4 would not be necessary, but it would be better to do step 4 - it would just mean there's nothing to replace in server_ip later on.

    As you stated that your provider will do the changes in Debian, I don't thin step 2 and 3 are necessary.

    If this is a slave server, you need to do step 5 and let the script reconfigure permissions for the master database. It might be necessary to create a new MySQL root user with the new source IP in MariaDB. The process for creating those is described here: https://www.howtoforge.com/tutorial...-the-remote-mysql-users-for-our-slave-servers - but if this is a master server, you don't have to reconfigure services.
     
    etruel likes this.
  14. etruel

    etruel Member HowtoForge Supporter

    Thom, excellent, thanks for clarifying everything. This helps a lot.
    This is simply a standalone server with no slave. So I have to run ispconfig_update.sh --force without to reconfigure services.
     
  15. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    You must reconfigure services, but not database permissions ;)
     
    etruel likes this.

Share This Page