Change IP-numbers, finding all files to change

Discussion in 'Plugins/Modules/Addons' started by Taleman, Mar 17, 2017.

  1. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    I am going to use Migration Tool to move an ISPConfig multiserver setup. My plan is to change the IP numbers, so the new hosts get the same IP-numbers the old hosts had after the migration. So far I know these places where I have to change the IP number:
    • /etc/hosts (or just copy this from old host)
    • /etc/network/interfaces
    • /etc/mysql/my.cnf
    • /etc/postfix/
    • /etc/amavis/conf.d/60-<servername>
    • /etc/apache2/sites-available/ some vhosts have IP-number
    Are there any more files to check and change?
  2. iNet Specialists

    iNet Specialists New Member

    You can do an extensive search using the "grep" tool combined with "less".
    # cd /etc
    # grep -r -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\." | less
    You will get a lot of results (not all IPs), but then you can search inside "less"...
    Where those are the first three octets of the networks you are concerned about.
    Just make notes or copy and paste filenames where your IP addresses appear.
    till likes this.
  3. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    I just noticed the IP-number is in ISPConfig web interface. What are all the places where IP-numbers appear there?
  4. iNet Specialists

    iNet Specialists New Member

    Various tables in the dbispconfig structure contain IP addresses for different purposes...
    • Any of the dns_* tables (especially dns_rr)
    • firewall (if you use that feature)
    • mail_relay_recipient (if you identify relays using IPs)
    • openvz_* tables (if you use that feature)
    • server (if servers are identified using IPs and not FQDNs)
    • server_ip (for sure)
    • web_domain (if websites are assigned specific IPs)
    There is one place that MAY have IPs that you may not expect:
    • the mysql.user table that holds the schema for database access credentials
  5. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Maybe I was wrong assuming it is simpler to change the new hosts to the IP-numbers of the old hosts. This is a multiserver setup, and now that I am setting up the new multiservers setup, I realized also the MySQL databases have permissions assigned to root@<ipnumber>, so even thos have to be changed after the migration.
    If I let the new hosts keep the IP-numbers they have now, what all do I need to change? The DNS database has the IP-number for all websites, maybe a SQL query to change every instance of old number to new?
  6. iNet Specialists

    iNet Specialists New Member

    Yes, that would be the mysql user table I warned of:

    If you look in the /usr/local/ispconfig/server/lib/ file and the /usr/local/ispconfig/interface/lib/ file on each server in the multi-server set, you will find the relevant user@host for each server, as well as the database that user is accessing. There will also be a ['server_id'] that will need to be migrated.

    I would just create a new user@host (like: ispconfigsrvN@<newIPnumber>) with the exact same privileges and table access privileges as the old user@host (like: ispconfigsrvN@<oldIPnumber>). In that way you can give each new server that is moved access to the old server database tables.

    This is most important for the master_db, but you should also check that the local database is correct as well if MySQL is running on every one of the servers in the multi-server setup.

    In my experience, phpMyAdmin works really well doing this. You can export the privileges for each user@host, use a text editor to search and replace the necessary items, and then re-import the SQL statement to create a new user with the correct privileges. You can also export/import the tables for the new server on the localhost, either by command line (mysql) or using a browser (phpMyAdmin)

    Then edit the files appropriately on the new server.

    Once the new multi-server set is operating correctly, you should be able to remove the old user@host credentials from the mysql.user table.

Share This Page