30 Haziran 2017 Cuma

Netflow

Version 5
Version 5 ile sadece ingress yönündeki yani dışardan içeri giren trafik monitor edilir. Egress komutu version 5 te calışmaz.

CONF T

SNMP-SERVER IFINDEX PERSIST
IP FLOW-EXPORT DESTINATION 23.0.0.3 9996
IP FLOW-EXPORT VERSION 5
IP FLOW-CACHE  TIMEOUT ACTIVE 1
IP FLOW-CACHE  TIMEOUT INACTIVE 10
IP FLOW-CACHE  ENTRIES 4096

INT FA0/0
NO IP FLOW INGRESS

Router flow oluşturup cache gonderir , cache'den de bu datayı istediğimiz ip adresine gönderir.


BİR FLOW u oluşturan FIELD ler nelerdi ?
  1. Source IP
  2. Destination IP
  3. Source Port
  4. Destination Port
  5. Protocol Type
  6. ToS
  7. Input Ifindex ( Hangi interface den girdiği bilgisi
CONF T
SNMP-SERVER IFINDEX PERSIST

Bu komutu girmemin sebebi şudur,
Router arada bir reboot falan olursa
bu interfacelere verdigi sayılar değişebilir,
onun için ne veriyorsa sabit kalsın diye girdik.

CONF T
IP FLOW-EXPORT VERSION 5 ( Komutun ne olduğu açık )
IP FLOW-EXPORT DESTINATION 23.0.0.3 9996 ( Komutun ne olduğu açık )
KOntrol edelim :

R2#sh ip flow  export
Flow export v5 is enabled for main cache
    Destination(1)  23.0.0.3 (9996)

IP FLOW-CACHE TIMEOUT ACTIVE 1 ( Bir Dakika )
IP FLOW-CACHE TIMEOUT INACTIVE 10  ( 10 Saniye )
IP FLOW-CACHE ENTRIES 4096

Kod:
INT FA0/0
IP FLOW INGRESS (dışarı cıkıcak paketleri)

FLOW ların geldiği bir CACHE vardır.
YUkarda girdiğimiz 4096 ile kaç tane FLOW alabileceğini belirledik. Burası açık.

Bir FLOW un ACTIVE yada INACTIVE olması durumu vardır.
Yani X den Y ye sürekli PING atıyorsanız bu FLOW ACTIVE dir 
Artık PING atma işlemi durmuşsa INACTIVE dir .

Normalde ( default olarak ) bir FLOW eger ACTIVe ise tam 30 dakika boyunca CACHE de tutulur!!!
SONRA COLLECTOR a gönderilir !
Onun için ben bu degeri 1 Dakika yaptım.

Ve eger bir FLOW INACTIVE ise yani şuan durmuş ise default olarak 15 saniye tutulur CACHE de sonra COLLECTOR a gönderilir. 
Ben bu degeri 10 yaptım.

Onun için hemen gidip COLLECTOR a bakınca FLOW göreceğini düşünmek yanlış olur. 

Ve AKLINIZDA olsun HER FLOW un kendi ACTIVE ve INACTIVE timeout u vardır doğal olarak.


Aklımıza şu gelebilir :

Dünya kadar paket giriyor Router a , yazık mı değil.
Bu baya bir YÜK demektir diye düşünebiliriz.

Onun için INTERFACE den giren her paketi inceleyip CACHE e atması problem olabilir.

Onun için biz bunu biraz FILTRELEYELİM !

FILTERING
_________


Öncelikle INTERFACE altıdaki IP FLOW INGRESS komutunu silicem. 
Çünkü TÜM PACKET leri incele ve FLOW yapıp CACHE e at demektir.

Kod:
CONF T
INT FA0/0
NO IP FLOW INGRESS

Şimdi şöyle bir konfigurassyon yapıcam :

Kod:
CONF T
FLOW-SAMPLER-MAP CISCOTR
MODE RANDOM ONE-OUT-OF 10

INT FA0/0
FLOW-SAMPLE CISCOTR

Kısaca CISCOTR diye bir Sampler oluşturdum.
SAMPLE zaten ÖRNEK demek İngilizce.
Ve Randomize olarak 10 packet den 1 ni İNCELE dedim.
Bunu da Interface e uyguladım.

KOntrol edelim :

Kod:
R2#show flow-sampler

 Sampler : ciscotr, id : 1, packets matched : 0, mode : random sampling mode
  sampling interval is : 10

Hemen PC den 100 tane PING gonderdim...


Kod:
PC#ping 12.0.0.2 repeat 100
Type escape sequence to abort.
Sending 100, 100-byte ICMP Echos to 12.0.0.2, timeout is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Wireshark a gidip baktım ve BİR FLOW gördüm,
içinde 10 PACKET var 

MQC ile Daha detaylı FILTRELEME YAPABİLİRİZ.
Onuda Version 9 da göreceğiz.

Sona sakladığım bir şey var.
Cisco cihazımız aslında EXPORTER idi ya.
Ve FLOW ları COLLECTOR a gönderirdi.

Aslında Cisco cihazın içinde küçük bir COLLECTOR var !!!

Yani istersek biz tüm FLOW ları o küçük COLLECTOR a gönderebiliriz.
Onun için SANAL OLARAK ANLIK CACHE oluşturulur Cihazımızda.

Adıda TOP-TALKERS !__________________

Yani Cisco cihazımız içindende istatistiksel verileri görebileceğiz.

Hemen açıklayarak konfigurasyon yapalım :


Kod:
R1#

CONF T
IP FLOW-TOP-TALKERS
TOP 5
SORT-BY PACKETS
CACHE-TIMEOUT 5000
bitti bu kadar.

5 , PACKETS ve 5000 kelimelerini kullanarak cümle kurucam.

Packets sayısını baz alarak, CACHE deki en çok PACKET i olan ilk 5 FLOW u al, ( burda TIMEOUT falan beklenmez )
Onlar için GEÇİCİ bir CACHE oluştur,
Ve bu CACHE in için 5000 ( 5 saniye ) tut !

Demektir.


SHOW IP FLOW TOP-TALKERS 

komutu ile görebiliriz...
R2#sh ip flow top-talkers

*Sep  6 17:44:31.259: %SYS-5-CONFIG_I: Configured from console by console

SrcIf         SrcIPaddress    DstIf         DstIPaddress    Pr SrcP DstP  Pkts
Fa0/0         12.0.0.1        Local         12.0.0.2        01 0000 0800     1
1 of 5 top talkers shown. 1 flows processed.

 



PC den Ping gönderdim ve





R1(config)#ip flow-export destination 192.168.1.1 2055



The router will export all flows to 192.168.1.1 with destination UDP port 2055. NetFlow supports multiple versions so if you want to use a specific version, here’s how to do it:

R1(config)#ip flow-export version 9



I will configure the router to use version 9. Optionally, we can configure what interface the router should use to source the updates from:

R1(config)#ip flow-export source FastEthernet 0/0



The last thing we have to do is tell the router on what interfaces to track the flows:

R1(config)#interface FastEthernet 0/1 R1(config-if)#ip route-cache flow



I will use the ip route-cache flow command for this. When you use this command, it will track all flows on the physical and all sub-interfaces. You can also use the ip flow egress or ip flow ingress commands if you only want to enable it on one sub-interface or in one direction.




Cisco 6500


flow record ipv4flow
match ipv4 tos
match ipv4 protocol
match ipv4 source address
match ipv4 destination address
match transport source-port
match transport destination-port
collect routing source as
collect routing destination as
collect routing next-hop address ipv4
collect ipv4 source mask
collect ipv4 destination mask
collect transport tcp flags
collect interface input
collect interface output
collect counter bytes
collect counter packets
collect timestamp sys-uptime first
collect timestamp sys-uptime last
!

Step 2. Create exporters:

Code:
!
flow exporter ipv4exp1
destination <COLLECTOR_IP_ADDR>
source Loopback0
transport udp 9999
!


Step 3. Create monitor with using exporters and template:

Code:
!
flow monitor ipv4mon
exporter ipv4exp1
cache timeout active 60
record ipv4flow
!


Step 4. Apply settings to interface:

Code:
!
interface XXXXXXXXEthernetx/x/x
ip flow monitor ipv4mon input
ip flow monitor ipv4mon output


Hiç yorum yok:

Yorum Gönder