Lab 1 nbar – khám phá những lưu lượng chạy qua router
1. LAB 1 : NBAR – Khám phá những lưu lượng chạy qua router
Sơ đồ:
Hình 1
Tóm tắt
Cơ chế nhận dạng lưu lượng ứng dụng NBAR phục vụ mục đích thống kê các loại ứng
dụng chạy qua thiết bị theo cả 2 chiều. Để chạy được tính năng này, cơ chế chuyển mạch
CEF phải được bật lên trước.
Yêu cầu
Xây dựng hệ thống như hình 75, bảo đảm các máy trạm có thể ra được internet và cuộc
thoại có thể thực hiện thành công giữa 2 máy điện thoại 1111 và 2222
Cổng Fa0/1 trên thiết bị R2 được lấy địa chỉ tự động bằng DHCP ( dùng câu lệnh ip
address dhcp)
Thực hiện:
A.Cấu hình ban đầu:
Cấu hình R1:
2. R1#sh run
Building configuration...
Current configuration : 1149 bytes
!
version 12.4
!
hostname R1
!
!
ip cef
!
ip dhcp pool 10
network 10.10.20.0 255.255.255.0
default-router 10.10.20.1
dns-server 203.162.4.1 203.162.4.190 203.162.4.191
!
!
interface FastEthernet0/0
ip address 10.10.10.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 10.10.20.1 255.255.255.0
duplex auto
speed auto
!
interface Serial0/1/0
ip address 192.1.1.1 255.255.255.0
clock rate 2000000
!
ip forward-protocol nd
ip route 0.0.0.0 0.0.0.0 192.1.1.2
!
line con 0
exec-timeout 0 0
logging synchronous
line aux 0
line vty 0 4
privilege level 15
no login
!
end
Cấu hình R2
R2#sh run
Building configuration...
3. Current configuration : 1178 bytes
!
version 12.4
!
hostname R2
!
ip cef
!
interface FastEthernet0/0
ip address 20.20.20.1 255.255.255.0
ip nat inside
ip virtual-reassembly
duplex auto
speed auto
!
interface FastEthernet0/1
ip address dhcp
ip nat outside
ip virtual-reassembly
duplex auto
speed auto
!
interface Serial0/1/0
ip address 192.1.1.2 255.255.255.0
ip nat inside
ip virtual-reassembly
!
ip route 10.10.0.0 255.255.0.0 192.1.1.1
!
ip http server
no ip http secure-server
ip nat inside source list 1 interface FastEthernet0/1 overload
!
access-list 1 permit 10.10.0.0 0.0.255.255
!
line con 0
exec-timeout 0 0
privilege level 15
logging synchronous
line aux 0
line vty 0 4
privilege level 15
logging synchronous
no login
!
scheduler allocate 20000 1000
!
end
Cấu hình trên thiết bị C2600-1:
c2600_1#sh run
4. Building configuration...
Current configuration : 832 bytes
!
version 12.3
!
hostname c2600_1
!
ip subnet-zero
ip cef
!
interface Ethernet0/0
ip address 10.10.10.2 255.255.255.0
half-duplex
!
ip classless
ip route 0.0.0.0 0.0.0.0 10.10.10.1
!
voice-port 1/0/0
!
voice-port 1/0/1
!
dial-peer voice 1 pots
destination-pattern 1111
port 1/0/0
!
dial-peer voice 2 voip
destination-pattern 2222
session target ipv4:20.20.20.2
!
line con 0
exec-timeout 0 0
logging synchronous
line aux 0
line vty 0 4
privilege level 15
no login
!
!
end
Cấu hình trên thiết bị C2600_2:
c2600_2#sh run
Building configuration...
Current configuration : 854 bytes
!
version 12.3
!
hostname c2600_2
!
5. ip subnet-zero
ip cef
!
interface Ethernet0/0
ip address 20.20.20.2 255.255.255.0
half-duplex
!
ip classless
ip route 0.0.0.0 0.0.0.0 20.20.20.1
!
voice-port 1/0/0
!
voice-port 1/0/1
!
dial-peer voice 1 pots
destination-pattern 2222
port 1/0/0
!
dial-peer voice 2 voip
destination-pattern 1111
session target ipv4:10.10.10.2
!
line con 0
exec-timeout 0 0
logging synchronous
line aux 0
line vty 0 4
privilege level 15
logging synchronous
no login
!
!
end
Bước 1:
Xem trước thông tin những giao thức được xây dựng sẵn trong hệ điều hành sẽ được sử
dụng bởi NBAR
R1#sh ip nbar port-map
port-map bgp udp 179
port-map bgp tcp 179
port-map bittorrent tcp 6881 6882 6883 6884 6885 6886 6887 6888
6889
port-map citrix udp 1604
port-map citrix tcp 1494
port-map cuseeme udp 7648 7649 24032
port-map cuseeme tcp 7648 7649
port-map dhcp udp 67 68
port-map directconnect tcp 411 412 413
port-map dns udp 53
port-map dns tcp 53
7. port-map secure-irc tcp 994
port-map secure-ldap udp 636
port-map secure-ldap tcp 636
port-map secure-nntp udp 563
port-map secure-nntp tcp 563
port-map secure-pop3 udp 995
port-map secure-pop3 tcp 995
port-map secure-telnet tcp 992
port-map sip udp 5060
port-map sip tcp 5060
port-map skinny tcp 2000 2001 2002
port-map smtp tcp 25
port-map snmp udp 161 162
port-map snmp tcp 161 162
port-map socks tcp 1080
port-map sqlnet tcp 1521
port-map sqlserver tcp 1433
port-map ssh tcp 22
port-map streamwork udp 1558
port-map sunrpc udp 111
port-map sunrpc tcp 111
port-map syslog udp 514
port-map telnet tcp 23
port-map tftp udp 69
port-map vdolive tcp 7000
port-map winmx tcp 6699
port-map xwindows tcp 6000 6001 6002 6003
Người dùng có thể chỉnh sửa thông tin cho các ứng dụng đã xây dựng sẵn trong IOS
Ví dụ nếu muốn chỉnh telnet thêm port 1123
Xem thông tin nhận dạng lưu lượng telnet:
R1#sh ip nbar port-map | include telnet
port-map secure-telnettcp 992
port-map telnet tcp 23
R1#
Dùng câu lệnh sau để chỉnh:
R1(config)#ip nbar port-map telnet tcp 23 1123
Kiểm tra:
R1(config)#do sh ip nbar port-map | include telnet
port-map secure-telnettcp 992
port-map telnet tcp 23 1123
R1(config)#
Người dùng cũng có thể khai báo thêm giao thức riêng cho mình:
8. Trong ví dụ sau người dùng tạo thêm 2 ứng dụng riêng của mình, 1 ứng dụng tên mypro
dùng udp port 3999 và một ứng dụng tên tennet dùng port tcp 3999
R1(config)#ip nbar custom mypro udp 3999
R1#sh ip nbar port-map | include 3999
port-map myproudp 3999
R1(config)#ip nbar custom tennet tcp 3999
R1#sh ip nbar port-map | include 3999
port-map mypro udp 3999
port-map tennet tcp 3999
Bước 2: Tiến hành kích hoạt tính năng tìm kiếm thống kê giao thức dùng NBAR
R1(config)#
R1(config)#int s0/1/0
R1(config-if)#ip nbar protocol-discovery
Khi chưa tạo lưu lượng chạy qua hệ thống, tiến hành kiểm tra các lưu lượng chạy qua hệ
thống
R1#sh ip nbar protocol-discovery
Serial0/1/0
Input Output
----- ------
Protocol Packet Count Packet Count
Byte Count Byte Count
5min Bit Rate (bps) 5min Bit Rate (bps)
5min Max Bit Rate (bps) 5min Max Bit Rate (bps)
------------------------ ------------------------ -----------------
bgp 0 0
0 0
0 0
0 0
Bittorrent 0 0
0 0
0 0
0 0
citrix 0 0
0 0
0 0
0 0
cuseeme 0 0
0 0
....................... thông tin bị lược bỏ.......
Unknown 0 0
0 0
0 0
0 0
9. Total 0 0
0 0
0 0
0 0
Chú ý việc thống kê được thực hiện theo số đếm tổng gói tin (Packet Count), tổng số byte
sinh ra từ các gói tin (Byte Count), tốc độ của loại giao thức trong vòng 5 phút và tốc độ
tính theo khối 5 phút lớn nhất từ lúc thống kê đến tại thời điểm xem thông tin.
Bắt đầu tạo lưu lượng chạy qua hệ thống
Từ các PC thực hiện lướt web, gọi thoại (1 cuộc từ 1111 đến 2222, nghe nhạc mp3....)
Kiểm tra lại thông tin 10 lưu lượng dữ liệu nhiều nhất
R1#sh ip nbar protocol-discovery top-n 10
Serial0/1/0
Input Output
----- ------
ProtocolPacket Count Packet Count
Byte Count Byte Count
5min Bit Rate (bps) 5min Bit Rate (bps)
5min Max Bit Rate (bps) 5min Max Bit Rate (bps)
------------------------ ------------------------
------------------------
http 7578 3779
9081778 506811
157000 21000
157000 21000
rtp 7196 6440
460419 411854
25000 25000
25000 25000
secure-http 40 34
35712 3964
0 0
3000 1000
novadigm 50 0
40695 0
0 0
3000 0
Dns 52 52
16096 3548
0 0
3000 0
rtcp 30 30
4876 4876
0 0
13. Protocol Packet Count Packet Count
Byte Count Byte Count
5min Bit Rate (bps) 5min Bit Rate (bps)
5min Max Bit Rate (bps) 5min Max Bit Rate (bps)
--------------- ---------------------- --------------------
tennel 0 3
01 56
00
0 0
Có thể dùng lệnh clear counters để reset các thông số về từ đầu
R1#clear counters
Clear "show interface" counters on all interfaces [confirm]^[
R1#clear counters
Clear "show interface" counters on all interfaces [confirm]
R1#sh ip nbar protocol-discovery
*Sep3 15:23:25.511: %CLEAR-5-COUNTERS: Clear counter on all interfaces
by console
R1#sh ip nbar protocol-discovery
Serial0/1/0
Input Output
----- ------
Protocol Packet Count Packet Count
Byte Count Byte Count
5min Bit Rate (bps) 5min Bit Rate (bps)
5min Max Bit Rate (bps) 5min Max Bit Rate (bps)
------------------- ------------------------ ----------------------
Rtp 62 62
3968 3968
0 0
0 0
Bgp 0 0
0 0