ICMP type codes

ICMP(Types/Codes)
Testing Destination Reachability & Status
(0/0) Echo-Reply
(8/0) Echo
Unreachable Destinations
(3/0) Network Unreachable
(3/1) Host Unreachable
(3/2) Protocol Unreachable
(3/3) Port Unreachable
(3/4) Fragmentaion Needed and DF set (Pkt too big)
(3/5) Source Route Failed
(3/6) Network Unknown
(3/7) Host Unknown
(3/9) DOD Net Prohibited
(3/10) DOD Host Prohibited
(3/11) Net TOS Unreachable
(3/12) Host TOS Unreachable
(3/13) Administratively Prohibited
(3/14) Host Precedence Unreachable
(3/15) Precedence Unreachable
Flow Control
(4/0) Source-Quench [RFC 1016]
Route Change Requests from Gateways
(5/0) Redirect Datagrams for the Net
(5/1) Redirect Datagrams for the Host
(5/2) Redirect Datagrams for the TOS and Net
(5/3) Redirect Datagrams for the TOS and Host
Router
(6/-) Alternate-Address
(9/0) Router-Advertisement
(10/0) Router-Solicitation
Detecting Circular or Excessively Long Routes
(11/0) Time to Live Count Exceeded
(11/1) Fragment Reassembly Time Exceeded
Reporting Incorrect Datagram Headers
(12/0) Parameter-Problem
(12/1) Option Missing
(12/2) No Room for Option
Clock Synchronization and Transit Time Estimation
(13/0) Timestamp-Request
(14/0) Timestamp-Reply
Obtaining a Network Address (RARP Alternative)
(15/0) Information-Request
(16/0) Information-Reply
Obtaining a Subnet Mask [RFC 950]
(17/0) Address Mask-Request
(18/0) Address Mask-Reply
Other
(30/0) Traceroute
(31/0) Conversion-Error
(32/0) Mobile-Redirect

RFC1918 Reserved namespaces

0.0.0.0/8		! broadcast
10.0.0.0/8	! RFC 1918 private
127.0.0.0/8	! loopback
169.254.0/16	! link local
172.16.0.0/12	! RFC 1918 private
192.0.2.0/24	! TEST-NET
192.168.0/16	! RFC 1918 private
224.0.0.0/4	! class D multicast
240.0.0.0/5	! class E reserved
248.0.0.0/5	! reserved
255.255.255.255/32	! broadcast

Network Classes

			       Net     Host    Total
Net      Addr                      Addr    Addr    Number
Class   Range      NetMask         Bits    Bits   of hosts
----------------------------------------------------------
A        0-127    255.0.0.0         8      24     16777216   (i.e. 114.0.0.0)
B      128-191    255.255.0.0      16      16        65536   (i.e. 150.0.0.0)
C      192-254    255.255.255.0    24       8          256   (i.e. 199.0.0.0)
D      224-239    (multicast)
E      240-255    (reserved)
F      208-215    255.255.255.240  28       4           16
G      216/8      ARIN - North America
G      217/8      RIPE NCC - Europe
G      218-219/8  APNIC
H      220-221    255.255.255.248  29       3            8   (reserved)
K      222-223    255.255.255.254  31       1            2   (reserved)
(ref: RFC1375 & http://www.iana.org/assignments/ipv4-address-space )
(               http://www.iana.org/numbers.htm                    )
----------------------------------------------------------

Subnetmask cheatsheet

Netmask              Netmask (binary)                 CIDR     Notes    
_____________________________________________________________________________
255.255.255.255  11111111.11111111.11111111.11111111  /32  Host (single addr)
255.255.255.254  11111111.11111111.11111111.11111110  /31  Unuseable
255.255.255.252  11111111.11111111.11111111.11111100  /30    2  useable
255.255.255.248  11111111.11111111.11111111.11111000  /29    6  useable
255.255.255.240  11111111.11111111.11111111.11110000  /28   14  useable
255.255.255.224  11111111.11111111.11111111.11100000  /27   30  useable
255.255.255.192  11111111.11111111.11111111.11000000  /26   62  useable
255.255.255.128  11111111.11111111.11111111.10000000  /25  126  useable
255.255.255.0    11111111.11111111.11111111.00000000  /24 "Class C" 254 useable
255.255.254.0    11111111.11111111.11111110.00000000  /23    2  Class C's
255.255.252.0    11111111.11111111.11111100.00000000  /22    4  Class C's
255.255.248.0    11111111.11111111.11111000.00000000  /21    8  Class C's
255.255.240.0    11111111.11111111.11110000.00000000  /20   16  Class C's
255.255.224.0    11111111.11111111.11100000.00000000  /19   32  Class C's
255.255.192.0    11111111.11111111.11000000.00000000  /18   64  Class C's
255.255.128.0    11111111.11111111.10000000.00000000  /17  128  Class C's
255.255.0.0      11111111.11111111.00000000.00000000  /16  "Class B"
     
255.254.0.0      11111111.11111110.00000000.00000000  /15    2  Class B's
255.252.0.0      11111111.11111100.00000000.00000000  /14    4  Class B's
255.248.0.0      11111111.11111000.00000000.00000000  /13    8  Class B's
255.240.0.0      11111111.11110000.00000000.00000000  /12   16  Class B's
255.224.0.0      11111111.11100000.00000000.00000000  /11   32  Class B's
255.192.0.0      11111111.11000000.00000000.00000000  /10   64  Class B's
255.128.0.0      11111111.10000000.00000000.00000000  /9   128  Class B's
255.0.0.0        11111111.00000000.00000000.00000000  /8   "Class A"
  
254.0.0.0        11111110.00000000.00000000.00000000  /7
252.0.0.0        11111100.00000000.00000000.00000000  /6
248.0.0.0        11111000.00000000.00000000.00000000  /5
240.0.0.0        11110000.00000000.00000000.00000000  /4
224.0.0.0        11100000.00000000.00000000.00000000  /3
192.0.0.0        11000000.00000000.00000000.00000000  /2
128.0.0.0        10000000.00000000.00000000.00000000  /1
0.0.0.0          00000000.00000000.00000000.00000000  /0   IP space

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!