Showing posts with label wireshark. Show all posts
Showing posts with label wireshark. 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

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

28 August, 2014

Interpret Packet Captures

When troubleshooting packet loss at a remote location where a sniffer trace isn't available, it's hard to isolate it to the LAN or WAN. In the new Cisco IOS 12.4(20)T there is a packet capture feature. The filters can be set based on interface name, direction, ACL, and even if it's to be punted to process level.

! Create Buffer 
R1#monitor capture buffer MYBUFFER circular 

! Configure Interface for Capture
R1#monitor capture point ip cef MYCAP fastEthernet 0/0 both 
*Aug 28 22:49:13.135: %BUFCAP-6-CREATE: Capture Point MYCAP created.

! Configure Associate 
R1#monitor capture point associate MYCAP MYBUFFER

! Start Capture 
R1#monitor capture point start MYCAP 
*Aug 28 22:50:19.767: %BUFCAP-6-ENABLE: Capture Point MYCAP enabled.

! Stop Capture 
R1#monitor capture point stop MYCAP 
*Aug 28 22:52:03.479: %BUFCAP-6-DISABLE: Capture Point MYCAP disabled.

! Check Configuration 

R1#ping 10.10.10.2 repeat 10

! Verify Captured Packets
R1#show monitor capture buffer all parameters 
Capture buffer MYBUFFER (circular buffer)
Buffer Size : 1048576 bytes, Max Element Size : 68 bytes, Packets : 20           (10 in, 10 out ICMP Packets)
Allow-nth-pak : 0, Duration : 0 (seconds), Max packets : 0, pps : 0
Associated Capture Points:
Name : MYCAP, Status : Inactive
Configuration:
monitor capture buffer MYBUFFER circular 
monitor capture point associate MYCAP MYBUFFER

R1#show monitor capture buffer MYBUFFER dump 
22:52:24.743 UTC Aug 28 2014 : IPv4 CEF Turbo  : Fa0/0 None
66910D80:          CA030A54 0008CA04 0A540008      J..T..J..T..
66910D90: 08004500 00640000 0000FE01 94820A0A  ..E..d....~.....
66910DA0: 0A020A0A 0A010000 B9CA0000 00000000  ........9J......
66910DB0: 00000007 CC78ABCD ABCDABCD ABCDABCD  ....Lx+M+M+M+M+M
66910DC0: ABCDABCD ABCDABCD 00                 +M+M+M+M.       

! How to export CAP file.
R1#monitor capture buffer MYBUFFER export tftp://192.168.1.132/buffer.cap

! Note: Then you can open it with Wireshark.

! You Can Filter With Access-List

R1(config)#access-list 100 permit icmp host 2.2.2.2 any
R1#monitor capture buffer MYBUFFER filter access-list 100

R1#show monitor capture buffer MYBUFFER parameters
Capture buffer MYBUFFER (circular buffer)
Buffer Size : 1048576 bytes, Max Element Size : 68 bytes, Packets : 4
Allow-nth-pak : 0, Duration : 0 (seconds), Max packets : 0, pps : 0
Associated Capture Points:
Name : MYCAP, Status : Active
Configuration:
monitor capture buffer MYBUFFER circular
monitor capture point associate MYCAP MYBUFFER

monitor capture buffer MYBUFFER filter access-list 100

04 August, 2014

NTP,Syslog,SNMPv3

Keeping Track of the Network

- NTP 
- Logging
- SNMPv3

# NTP

R1#show clock
*14:23:17.119 UTC Mon Aug 4 2014

! Change time zone
R1(config)#clock timezone PST -8

R1(config)#clock summer-time PDT recurring

! Configure NTP Server
R1(config)#ntp server 38.229.71.1

! For Debug Use: 
R1#debug ntp packets

! Verify NTP server configuration 
R1#show ntp associations
      address         ref clock     st  when  poll reach  delay  offset    disp
*~38.229.71.1      204.123.2.72      2    59    64  377   135.8   -1.20     1.0
* master (synced), # master (unsynced), + selected, - candidate, ~ configured

R1#show ntp associations detail
38.229.71.1 configured, our_master, sane, valid, stratum 2
ref ID 204.123.2.72, time D789FAD1.1ACDEE21 (12:28:01.104 UTC Mon Aug 4 2014)
our mode client, peer mode server, our poll intvl 64, peer poll intvl 64
root delay 54.52 msec, root disp 22.20, reach 377, sync dist 119.720
delay 135.85 msec, offset -1.1982 msec, dispersion 2.33
precision 2**20, version 3
org time D789FB2C.A11B70B4 (12:29:32.629 UTC Mon Aug 4 2014)
rcv time D789FB2C.C27C97CA (12:29:32.759 UTC Mon Aug 4 2014)
xmt time D789FB2C.8B331998 (12:29:32.543 UTC Mon Aug 4 2014)
filtdelay =   215.19  139.95  143.98  139.95  139.50  135.85  135.88  135.83
filtoffset =  -22.79   -2.95    1.56    0.30   -0.32   -1.20   -0.26    0.16
filterror =     0.02    0.99    1.01    1.02    1.04    1.05    1.07    1.08

R1#show ntp status
Clock is synchronized, stratum 3, reference is 38.229.71.1
nominal freq is 250.0000 Hz, actual freq is 250.0000 Hz, precision is 2**18
reference time is D789FB2C.C27C97CA (12:29:32.759 UTC Mon Aug 4 2014)
clock offset is -1.1982 msec, root delay is 190.37 msec
root dispersion is 25.74 msec, peer dispersion is 2.33 msec

! If using Authentication
R1(config)#ntp update-calendar
R1(config)#ntp authentication-key 1 md5 cisco123
R1(config)#ntp authenticate
R1(config)#ntp trusted-key 1
R1(config)#ntp server x.x.x.x key 1 source fas0/0 prefer

# Logging 

R1(config)#logging on
R1(config)#logging buffered informational
R1(config)#logging host 192.168.1.129
R1(config)#logging trap debugging

R1(config)#do show logging
Syslog logging: enabled (12 messages dropped, 0 messages rate-limited,
                0 flushes, 0 overruns, xml disabled, filtering disabled)
No Active Message Discriminator.
No Inactive Message Discriminator.
    Console logging: level debugging, 261 messages logged, xml disabled,
                     filtering disabled
    Monitor logging: level debugging, 0 messages logged, xml disabled,
                     filtering disabled
    Buffer logging:  level informational, 261 messages logged, xml disabled,
                     filtering disabled
    Logging Exception size (8192 bytes)
    Count and timestamp logging messages: disabled
    Persistent logging: disabled
No active filter modules.
ESM: 0 messages dropped
    Trap logging: level debugging, 25 message lines logged
        Logging to 192.168.1.129  (udp port 514,  audit disabled,
              authentication disabled, encryption disabled, link down),
              0 message lines logged,
              0 message lines rate-limited,
              0 message lines dropped-by-MD,
              xml disabled, sequence number disabled
              filtering disabled
Log Buffer (8192 bytes):

# SNMP

! Create access list for SNMP
R1(config)#access-list 10 permit 192.168.1.129
R1(config)#access-list 10 deny any log
R1(config)#do show access-list
Standard IP access list 10
    10 permit 192.168.1.129
    20 deny   any log

! Configure SNMP v3 
R1(config)#snmp-server engineID local 123456789A
R1(config)#snmp-server group G1 v3 priv access 10

* Note: 
  auth    (Authentication, No Encryption)
  noauth  (No Authentication, No Encryption)
  priv    (Authentication, Encryption)
  
Create User 
R1(config)#snmp-server user U1 G1 v3 auth sha a-Pass priv aes 128 e-Pass
Aug  4 13:35:23.133: Configuring snmpv3 USM user, persisting snmpEngineBoots. Please Wait...

* Note: This configuration do not save in running-config
R1(config)#do show run | in U1
Blank

! To Verify SNMP user
R1(config)#do show snmp user
User name: U1
Engine ID: 123456789A
storage-type: nonvolatile        active
Authentication Protocol: SHA
Privacy Protocol: AES128
Group-name: G1

! Configure SNMP Host
R1(config)#snmp-server host 192.168.1.129 traps version 3 auth U1
R1(config)#snmp-server enable traps syslog

! Configure ManageEngine MibBrowser
* Note: Use free SNMP (ManageEngine MIB Browser)

! Verify CPU Usage
R1(config)#do show proce cpu sor | in ^CPU|SNMP ENGINE
CPU utilization for five seconds: 14%/100%; one minute: 13%; five minutes: 6%
 233        8932      1044       8555  0.00%  4.77%  2.36%   0 SNMP ENGINE

*Note: SNMP is configured and Works fine

! Check Encryption using Wireshark
! Capture SNMP Traffic 
* Note : All SNMP packets are Encrypted

! Configure Wireshark with User and Pass to see Content of SNMP

Steep 1:
Steep 2:
Steep 3:
* Note : Now we can read information from SNMP Packets.

19 November, 2013

Wireshark

### Add Column:
Rigth click on packet details (host,src port, dst port) and click "Apply as column"

### How to generate ACLs,iptabes,Windows Firewall,IPFirewall Commands: 
Select any Packet -> Click Tools -> "Firewall ACL Rules"

### Start Capturing At Open Wireshark: 
Add -i # -k to the end of the shortcut, replacing # with 
the number of the interface you want to use. The -i option 
specifies the interface, while the -k option tells Wireshark 
to start capturing immediately.
"C:\Program Files\Wireshark\wireshark.exe" -i 2 -k

### Configure Remote capturing:
services.msc -> 
Remote Packet Capture Protocol v.0 (START)
Click the Capture Options link in Wireshark, then select "Remote"
Enter the address of the remote system and 2002 as the port

### How to change Mac resolv (c4:7d:4f:11:11:11 to cisco_11:11:11)
C:\Program Files\Wireshark\manuf (change this file)

### How to change Port Name  (22 to ssh)
C:\Program Files\Wireshark\services (change this file)

### Capture in Terminal: (as administrador)
C:\Program Files\Wireshark>tshark.exe -i 2 (Real Time Without saving any capture)
C:\Program Files\Wireshark>tshark.exe -i 2 -w c:\capture-01
Capturing on Microsoft
431
Note: (-i [interface number]) (-w [directory where save captured file])

### Download Files From Capture:
File -> Export Objects -> HTTP 

### Download FTP data 
Search ftp data conversation after 3 way handshake -> open first packet and click "save as" (pic1.jpg)

### Start Graphs Monitor:
Click "Statistics" ->  IO Gaphs 
Configure Filters 

###Display filter: 

#Hide Protocol (s)
!(ipv6)
!(dns) && !(dhcp)

#Capture Network 
net 192.168.1.0/24 
ip.addr == 172.16.0.0/16
vlan.id==10

#Adding Simple Regular expressions:

"[aA][bB][cC]"  or  "(?i)abc"     -  Abc,ABC,AbC

"(?i)(abc|xyz)"  -  ABc,AbC or xyz,XyZ,XYz    | = or

"(?i)(a.c|x..)"  -  AxC,AGc or Xhu,xgr,xJi    . = any single character

Ejample :

frame matches "pass"
frame matches "(?i)pass"
frame matches "(?i)(pass|success)"
frame matches "(?i)(pa.s|su..ess)"
frame matches "(?i)(go{2}e)"

Equal to           eq   ==    ip.dst == a.b.c.d
Not equal to       ne   !=    udp.dstport != 53
less than          lt   <     ip.ttl < 45 
greater or equal   ge   >=    tcp.analysis.bytes_in_flight >= 1000
contains          contains    dns.resp.name contains "google"
AND                 &&        (udp) && (dhcp)
or                 ||         (dns) || (http.response.code == 404)