For future reference, here is the script I generated to provide a MAC
address for a given carp interface.  Much thanks to Stuart Henderson in
answering my original question on this topic.  This is no rocket
science, but it might save a few people 2 minutes in the future.

-Kevin


#!/usr/bin/perl
#
# This script takes a single carp interface name as an argument,
# collects the vhid from ifconfig, and then provides the appropriate
# MAC address for that interface.
#

if ( $#ARGV == 0 )
{
        if ($ARGV[0] =~ /carp[0-9]+/)
        {
                if (`ifconfig $ARGV[0]` =~ /.*?vhid\ ([0-9]+).*/)
                {
                        printf "00:00:5e:00:01:%02x\n",$1;
                }
        }
        else
        {
                print "Interface \"$ARGV[0]\" is invalid,
gen_carp_mac.pl only accepts carp interface names\n";
                exit;
        }
}
else
{
        print "Usage: gen_carp_mac.pl <interface>\nThis program requires
a single carp interface name as an argument.\n";
        exit;
}

Reply via email to