Home > Plesk > How To Change A Server’s Main IP Address (including DNS records) In Plesk

How To Change A Server’s Main IP Address (including DNS records) In Plesk

July 26th, 2009

This applies to a Windows Plesk server, running any kind of 8.x Plesk. First of, change your IP address through RDP in the Network Settings of Windows, then it’s time to update Plesk – like this.

Update Host’s IP address in Plesk
update psa.ip_addresses set ip_address = ‘<new-ip-address>’ where ip_address=’<old-ip-address>’

Changing DNS records for all hosts:
update psa.dns_recs set host = ‘<new-ip-address>’ where host = ‘<old-ip-address>’;
update psa.dns_recs set displayHost = ‘<new-ip-address>’ where displayHost = ‘<old-ip-address>’;
update psa.dns_recs set val = ‘<new-ip-address>’ where val = ‘<old-ip-address>’;
update psa.dns_recs set displayVal = ‘<new-ip-address>’ where displayVal = ‘<old-ip-address>’;

Then run the following command:
websrvmng.exe --reconfigure-all

This will rebuild all Plesk-generated configs (in this case, for Apache) according to what’s known within Plesk. This way, you can fairly quickly change the main IP address of a server, without a lot of hassle. However, this does not update the DNS config files.

The following should, in theory, also be possible:
websrvmng.exe --change-ip-address --new-ip-address=<new-ip-address> --old-ip-address=<old-ip-address>

Next, you have to start the command that rebuilds the DNS config, based on what’s known within Plesk (as the websrvmng.exe does not update DNS records). The downside: the command needs to be entered for each domain in Plesk, so here’s a script to make this slightly easier:

<?php
	$conn = mysql_connect("localhost:8306", "admin", "<plesk-pass>") or die (mysql_error());
	$dbconn = mysql_select_db("psa", $conn) or die (mysql_error());
 
	$sql = "SELECT * FROM domains AS d";
	$result = mysql_query($sql) or die (mysql_error());
 
	$output = "";
	$newline = "\n";
	while ($row = mysql_fetch_object($result)) {
		$output .= "DNSMng.exe update ". $row->name . $newline;
	}
 
	echo $output;
?>

This will generate all the commands, so you can copy paste them to a “execute.bat” file, and save that in the Plesk/Admin/Bin folder, so it can now execute the DNSMng.exe executable for each and every domain.

Spread the word
If you liked the content of this article, please vote for it on the following websites - thanks.
  • Digg
  • del.icio.us
  • DZone
  • Reddit
  • StumbleUpon
  • Sphinn
  • Facebook
  • Live
  • Mixx
  • Technorati
  • TwitThis

Matti Plesk , , , ,