Forum Discussion

Carlyle's avatar
Carlyle
Level 2
11 years ago

How to show cluster ids on a physical network

Hello. We are looking for a way to discover all cluster ids visible on the physical network in order to choose a unique id. How can we do this? Regards, Carlyle
  • Carlyle's avatar
    11 years ago

    I sincerely thank you all for trying to help. My final solution is as follows.

     

    First I used tcpdump to gather the llt broadcasts and cut out the MAC addresses and the cluster IDs.

    <code>tcpdump -a -X -c 1000 broadcast and ether proto 0xcafe 2>/dev/null |
    sed -n '
    /^[012][0-9]:/{
        s/^[^ ]* \([^ ]*\) .*/\1/
        h
        n
        s/^[  ][  ]*[^ ]*  *[^ ]*  *\([^ ]*\) .*$/\1/
        H
        g
        s/\n/ /
        p
    }
    ' | sort -uk2</code>

    This would actualy have been enough to answer my original question but I was curious which clusters have which IDs.

    Then I used arp to gather the MAC addresses together with the IP information. Of course I needed to feed the arp cache on the local server first so I chose to use a SYN request in perl.

    <code>function sshping
    {
    typeset -x SERVER=$1
    typeset -x PORT=22
            [[ -n $2 ]] && PORT=$2

            /usr/bin/perl -w -e '
            use strict;
            use Net::Ping;
            use Socket;

            my $ip;
            my $host = $ENV{"SERVER"};;
            my $packed_ip = gethostbyname($host);
            if (defined $packed_ip) {
                            $ip = inet_ntoa($packed_ip);
            } else {
                            print "$host ssh port is unreachable.\n";
                            exit( 1 );
            }
            my $p = Net::Ping->new("tcp", 6);

            $p->{port_num} = $ENV{"PORT"};

            if( $p->ping($ip) ) {
              print "$host port $p->{port_num} is reachable.\n";
              exit( 0 );
            } else {
              print "$host port $p->{port_num} is unreachable.\n";
              exit( 1 );
            }
            '
    }
    i=1;while ((i<255)) ; do sshping 10.217.130.$i >/dev/null 2>&1 ; ((i+=1)) ; done</code>

    Then I was ready for my arp requst.

    <code>arp -a | tr -d '][)(' | sed -n '
            /ethernet/{
                    s/\([ :]\)\([0-9]\)\([ :]\)/\10\2\3/g
                    s/at //
                    s/ ethernet .*$//
                    p
            }
    '</code>