Showing posts with label ICMP. Show all posts
Showing posts with label ICMP. Show all posts

24 February, 2017

Types and Codes


Type 3
Codes :

- Network Unreachable  (Router does not have route and can not send)
- Host Unreachable     (Router knows about network but cant send packet to the host for any reason. ej: L2 problem with host)
- Protocol Unreachable (Packet are delivered but some L4 Problem, does not know Protocol)
- Port Unreachable     (Port Problem, no open service on that port)
- Fragmentation        (MTU Problems / Fragmentation needed but DF Set)
- Source Routing       (IP Source Routing problem / no ip source-route)
- Obsolete Code        (Obsolete Code)
- Obsolete Code        (Obsolete Code)
- Obsolete Code        (Obsolete Code)
- Admin Prohibited     (Access-List or Wirewall Host Was prohibited)
10
- Admin Prohibited     (Access-List or Wirewall Network Was Prohibited)
11
- QoS, ToS and IP Precedence Problems
12
- QoS, ToS and IP Precedence Problems
13
- Admin Prohibited     (Access-List or Wirewall General Prohibited msg)
14
- QoS, ToS and IP Precedence Problems
15
- QoS, ToS and IP Precedence Problems

--------------------------------------------------------------------------------

Code 4: Fragmentation

- Route-map Configuration
route-map clear-df permit 36
match ip address 136
set ip df 0
 
- Access list 2.2.2.2 is the offending website and 3.3.3.0 is the remote site subnet.
access-list 136 permit tcp host 2.2.2.2 3.3.3.0 0.0.0.255
 
- Appply on interface:
ip policy route-map clear-df

Note:
Configure bit to “0” (zero) to allow fragmentation.
DF=1= Don’t allow fragmentation


-------------------------------------------------------------------------------------------------------------------------

ICMP Redirect (Type 5)

Type 5, Codes 0 - 3 :
 
- 0 Network 
- Host
- Service / Network 
- Service / Host


Questions router asks before sending a redirect :
- Is route outthe same interface ?
 
- Are ip redirectsenabled on that interface ?  
- Is source IP from same network as the better next hop ?

Won`t send redirect for a source-routed packet. 





Wireshark Online Capture here :

We can see in debug:

R2#debug ip icmp
ICMP packet debugging is on
*Feb 28 08:50:53.750: ICMP: redirect sent to 10.123.0.1 for dest 4.4.4.4, use gw 10.123.0.3

Note: Use no ip redirects command on Interface to turn off ICMP Redirects. 


-------------------------------------------------------------------------------------------------------------------------

ICMP TYPE NUMBERS

The Internet Control Message Protocol (ICMP) has many messages that
are identified by a "type" field.

Type Name     Reference
---- -------------------------  ---------
  0 Echo Reply     [RFC792]
  1 Unassigned        [JBP]
  2 Unassigned        [JBP]
  3 Destination Unreachable    [RFC792]
  4 Source Quench      [RFC792]
  5 Redirect     [RFC792]
  6 Alternate Host Address       [JBP]
  7 Unassigned        [JBP]
  8 Echo      [RFC792]
  9 Router Advertisement   [RFC1256]
 10 Router Selection   [RFC1256]
 11 Time Exceeded     [RFC792]
 12 Parameter Problem    [RFC792]
 13 Timestamp     [RFC792]
 14 Timestamp Reply     [RFC792]
 15 Information Request    [RFC792]
 16 Information Reply    [RFC792]
 17 Address Mask Request                     [RFC950]
 18 Address Mask Reply    [RFC950]
 19 Reserved (for Security)      [Solo]
 20-29 Reserved (for Robustness Experiment)     [ZSu]
 30 Traceroute    [RFC1393]
 31 Datagram Conversion Error  [RFC1475]
 32     Mobile Host Redirect              [David Johnson]
 33     IPv6 Where-Are-You                 [Bill Simpson]
 34     IPv6 I-Am-Here                     [Bill Simpson]
 35     Mobile Registration Request        [Bill Simpson]
 36     Mobile Registration Reply          [Bill Simpson]
 37     Domain Name Request                     [Simpson]
 38     Domain Name Reply                       [Simpson]
 39     SKIP                                    [Markson]
 40     Photuris                                [Simpson]
 41-255 Reserved        [JBP]

Many of these ICMP types have a "code" field.  Here we list the types
again with their assigned code fields.

Type    Name                                    Reference
----    -------------------------               ---------
  0     Echo Reply                               [RFC792]

        Codes
            0  No Code

  1     Unassigned                                  [JBP]

  2     Unassigned                                  [JBP]

  3     Destination Unreachable                  [RFC792]

 Codes
     0  Net Unreachable
     1  Host Unreachable
            2  Protocol Unreachable
            3  Port Unreachable
            4  Fragmentation Needed and Don't Fragment was Set
            5  Source Route Failed
            6  Destination Network Unknown
            7  Destination Host Unknown
            8  Source Host Isolated
            9  Communication with Destination Network is
               Administratively Prohibited
           10  Communication with Destination Host is
               Administratively Prohibited
           11  Destination Network Unreachable for Type of Service
           12  Destination Host Unreachable for Type of Service
           13  Communication Administratively Prohibited      [RFC1812]
           14  Host Precedence Violation                      [RFC1812]
           15  Precedence cutoff in effect                    [RFC1812]


  4     Source Quench                            [RFC792]
        Codes
            0  No Code

  5     Redirect                                 [RFC792]

        Codes
            0  Redirect Datagram for the Network (or subnet)
            1  Redirect Datagram for the Host
            2  Redirect Datagram for the Type of Service and Network
            3  Redirect Datagram for the Type of Service and Host

  6     Alternate Host Address                      [JBP]

        Codes
            0  Alternate Address for Host

  7     Unassigned                                  [JBP]

  8     Echo                                     [RFC792]

        Codes
            0  No Code

  9     Router Advertisement                    [RFC1256]

        Codes
            0  No Code

 10     Router Selection                        [RFC1256]

        Codes
            0  No Code

 11     Time Exceeded                            [RFC792]

        Codes
            0  Time to Live exceeded in Transit
            1  Fragment Reassembly Time Exceeded

 12     Parameter Problem                        [RFC792]

        Codes
            0  Pointer indicates the error
            1  Missing a Required Option        [RFC1108]
            2  Bad Length


 13     Timestamp                                [RFC792]

        Codes
            0  No Code

 14     Timestamp Reply                          [RFC792]

        Codes
            0  No Code

 15     Information Request                      [RFC792]

        Codes
            0  No Code

 16     Information Reply                        [RFC792]

        Codes
            0  No Code

 17     Address Mask Request                     [RFC950]

        Codes
            0  No Code

 18     Address Mask Reply                       [RFC950]

        Codes
            0  No Code

 19     Reserved (for Security)                    [Solo]

 20-29  Reserved (for Robustness Experiment)        [ZSu]

 30     Traceroute                              [RFC1393]

 31     Datagram Conversion Error               [RFC1475]

 32     Mobile Host Redirect              [David Johnson]

 33     IPv6 Where-Are-You                 [Bill Simpson]

 34     IPv6 I-Am-Here                     [Bill Simpson]

 35     Mobile Registration Request        [Bill Simpson]

 36     Mobile Registration Reply          [Bill Simpson]

 39     SKIP                                    [Markson]

 40     Photuris                                [Simpson]

Code

0 Reserved
1 unknown security parameters index
2 valid security parameters, but authentication failed
3  valid security parameters, but decryption failed

===================================================================

26 September, 2014

Filter ICMP Traffic With Control-Plane

CCNA Security 

Filter ICMP Traffic

! Show Version
R1#show version | in IOS
Cisco IOS Software, 7200 Software (C7200-ADVSECURITYK9-M), Version 15.0(1)M, RELEASE SOFTWARE (fc2)

! Create Access list for ICMP
R1#configure terminal
R1(config)#access-list 100 permit icmp any any

! Create class map witch calls on the ACL
R1(config)#class-map ICMP
R1(config-cmap)#match access-group 100
R1(config-cmap)#exit

! Create Policy Map wich calls on the class map
R1(config)#policy-map ICMP-POLICY
R1(config-pmap)#class ICMP

! Tell the policy map that if ICMP traffic is seen, that this traffic should be rate limited down to 8Kbps, and anything over that should be droped.
R1(config-pmap-c)#police 8000 conform-action transmit exceed-action drop
R1(config-pmap-c-police)#exit
R1(config-pmap-c)#exit

! Apply the policy with to the logical "control-plane" with a service-policy command
! We need to go into controle-plane configuration:

R1(config-pmap)#control-plane ?
% Unrecognized command
! Note: This option is Hide

R1(config-pmap)#control-plane

Apply the service policy, so that when any ICMP traffic is being sent TO the router(regardless of physical interface) it will be policed (rate limited).
R1(config-cp)#service-policy input ICMP-POLICY
*Sep 27 01:51:30.047: %CP-5-FEATURE: Control-plane Policing feature enabled on Control plane aggregate path
R1(config-cp)#end

! To verify it is in place:
R1#show policy-map control-plane
 Control Plane
  Service-policy input: ICMP-POLICY
    Class-map: ICMP (match-all)
      0 packets, 0 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: access-group 100
      police:
          cir 8000 bps, bc 1500 bytes
        conformed 0 packets, 0 bytes; actions:
          transmit
        exceeded 0 packets, 0 bytes; actions:
          drop
        conformed 0 bps, exceed 0 bps
    Class-map: class-default (match-any)
      0 packets, 0 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any

! Now to test it !
R3#ping 10.0.0.1 size 700 repeat 10  (Ping to R1)
Type escape sequence to abort.
Sending 10, 700-byte ICMP Echos to 10.0.0.1, timeout is 2 seconds:
!!.!!.!!.!
Success rate is 70 percent (7/10), round-trip min/avg/max = 72/81/88 ms

! Verify again 
R1#show policy-map control-plane
 Control Plane
  Service-policy input: ICMP-POLICY
    Class-map: ICMP (match-all)
      184 packets, 86976 bytes
      5 minute offered rate 6000 bps, drop rate 1000 bps
      Match: access-group 100
      police:
          cir 8000 bps, bc 1500 bytes
        conformed 152 packets, 64128 bytes; actions:
          transmit
        exceeded 32 packets, 22848 bytes; actions:
          drop
        conformed 4000 bps, exceed 1000 bps
    Class-map: class-default (match-any)
      24 packets, 2924 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any