[BlueOnyx:00795] Re: Lazy way to change a domain IP for multiple domains (pointing to the same website)
Michael Stauber
mstauber at blueonyx.it
Mon Mar 16 13:39:23 -05 2009
Hi Jeff,
> OK so lets say I have someone on a BO box - and they host the
> following domains via BO DNS:
>
> bigboobies.com
> big-boobies.com
Did someone say boobies? ;o)
> Does anyone here know any clever way (perhaps some perl?) that I could
> run that would just change the IP addresses all these boobie domains?
Here are some scripts from my toolbox for such tasks:
1.) Mass IP change (changes IPs of Vsites only, not the DNS!). It changes the
IP's of ALL sites to the new IP.
If you want to change the IP's of only selected sites, then comment out the
line ...
system("ls -k1 /home/sites/ > /tmp/sitelist.txt");
... and create a /tmp/sitelist.txt file that contains just the names of the
domains which it should perform the task on.
_______________________________________________
#!/usr/bin/perl
# List of all sites can be generated with this command:
# ls -k1 /home/sites/ > sitelist.txt
system("ls -k1 /home/sites/ > /tmp/sitelist.txt");
$newip = "192.168.100.100";
$sitelist = "/tmp/sitelist.txt";
open(CONFIG, $sitelist);
@list = <CONFIG>;
close (CONFIG);
foreach $site (@list) {
$size = length($site);
unless ($size < 3) {
chomp $site;
print "Changing IP of site " . $site . " to the IP $newip \n";
system("cmodvsite --fqdn $site --ipaddress $newip");
}
}
_______________________________________________
2.) Canges all existing DNS records that have the IP $oldip to the IP $newip.
_______________________________________________
#!/usr/bin/perl -I/usr/sausalito/perl
# $Id: dns-masschange.pl, v1.1.0.0 Mon 23 Apr 2008 04:30:09 PM CEST
# Copyright 2006-2008 Solarspeed Ltd. All rights reserved.
use CCE;
my $cce = new CCE;
$cce->connectuds();
$oldip = '192.168.99.99';
$newip = '192.168.100.100';
&feedthemonster;
&setdirty;
$cce->bye('SUCCESS');
exit(0);
sub feedthemonster {
(@oids) = $cce->find('DnsRecord', { 'ipaddr' => $oldip });
for $object (@oids) {
print $object . "\n";
($ok) = $cce->set($object, '',{
'ipaddr' => $newip
});
}
}
sub setdirty {
# Get 'System' details:
@system_main = $cce->find('System');
if (!defined($system_main[0])) {
print "Sorry, no 'System' object found in CCE!\n";
exit(1);
}
else {
# Build Records:
#($ok, $my_system_main) = $cce->get($system_main[0]);
($ok) = $cce->set($system_main[0], 'DNS', {
'dirty' => time()
});
}
}
_______________________________________________
--
With best regards
Michael Stauber
More information about the Blueonyx
mailing list