Tcpdump unique host filter

Filter for unique host:

#!/usr/bin/perl
#
# Unique line filter
#
# Usage:
#
# tcpdump -i ethX -nn -s 0 [optional tcpdump filter] | grep --line-buffered [optional filter]
   | awk {'print $3'} | awk -F"[ .]" '{print $1"."$2"."$3"."$4}' | ./thisFilter
#

use Socket;
use Net::DNS;

# Collectie aanmaken
my %hosts;
my $answer;
my $namer;

# DNS
my $DnsServer = "172.16.32.1";
my $res = new Net::DNS::Resolver;
$res->nameservers($DnsServer);
my $ip;

# Resolve DNS Name
sub myCheckDNSName
{
   $ipnumber = $_[0];

   $ip = new Net::IP($ipnumber,4);

   if ($ip)
   {
        # resolved host
        $answer = $res->query($ip->reverse_ip(),'PTR');
        $namer = $answer->{'answer'}[0];
        $resolved = $namer->{'ptrdname'};
        return ($resolved);
   }
   else
   {
        return ("Not resolved");
   }
}

while (<>) {
        my $line = $_;
        $line =~ s/\r?\n//g;

        if ($line =~ m/^(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)/ )
        {
         if (exists $hosts{$line})
         {
            # bestaat al, niks doen!
            # print "exists: $line";
         }
         else
         {
            $now = localtime(time);

            # reverse dns
            $resolved_name = myCheckDNSName($line);
            $hosts{$line} = "($resolved_name) $now ";

            print "-----------------------------------<<<< update >>>>----------------------------------\n\n";
            foreach $value (sort {$hosts{$a} cmp $hosts{$b} } keys %hosts)
            {
               print " $value $hosts{$value} \n";
            }
            print "\n";
         }
        }
}

Mount a windows share on Linux

Login on the linux system with sufficient rights:

Create a share in the mount directory (/mnt):

root# mkdir /mnt/SHARE

Make a connection to the server:

root# mount -t smbfs -o username=arjen \\SERVER\SHARE /mnt/SHARE

View your files:

root# ls /mnt/share

Release the share:

root# umount /mnt/share

Thats all folks!

MyFirstPost

MyFirstPost… As a network administrator you’re learning every day. Practically you’re using sources like Google to translate user problems -I know, we should name them challenges- into solutions.

This blog will be a collection of my searchquest on Internet, my personal ‘same-shit-different-day’-wiki of all network- and computer-related knowledge. So I don’t have to remember them…

Have fun reading!