1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Add a block of IPs

Discussion in 'Plesk for Linux - 8.x and Older' started by CruzMark, Mar 31, 2006.

  1. CruzMark

    CruzMark Basic Pleskian

    Mar 6, 2006
    Likes Received:
    Here's a simple (and insecure) perl script that will add a block of IPs to plesk from the command line. I accept no responsibility for its use or mis-use. Since it uses the plesk ipmanage tool, it is unlikely that you'll cause your system to implode.


    # This script causes heavy load on the server and takes several minutes
    # to run.

    # The script assumes that the block is Class C or less.
    # IP_SUBNET should be the first three octets of the IP.
    # MASK should be in octet form (ex.
    # See (DIRECTORY)/psa/bin/ipmanage --help for more info

    if (@ARGV != 5) {
    print "Usage: create_ip_block.pl IP_SUBNET MASK INTERFACE TYPE CERT\n";

    # Turn debug 'on' to test script before actually adding IPs!
    # $debug = 'on';

    # Change count based on the IPs you are trying to add. Settings below
    # are for a class C subnet

    my $start_count = 1;
    my $end_count = 254;

    # replace with path to your psa/bin directory. Below is for FreeBSD
    my $psa_bin_path = "/usr/local/psa/bin";

    my $ip_subnet = $ARGV[0];
    my $mask = $ARGV[1];
    my $interface = $ARGV[2];
    my $type = $ARGV[3];
    my $ssl = $ARGV[4];

    for ($count="$start_count"; $count <= $end_count; $count++) {
    $ip = "$ip_subnet" . "." . "$count";
    if ($debug eq 'on') {
    print "$psa_bin_path/ipmanage -c $ip -mask $mask -interface $interface -type $type -ssl_certificate $ssl\n";
    } else {
    `$psa_bin_path/ipmanage -c $ip -mask $mask -interface $interface -type $type -ssl_certificate $ssl`;