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

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, July 26, 2009

Follow me on Twitter as @mattiasgeniar

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:

") 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.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.