View
38
Download
0
Embed Size (px)
Citation preview
LAB 3: Phân loại dùng NBAR
Tóm tắt
Việc phân loại lưu lượng dùng trong mô hình cấu hình MQC trở nên mạnh mẽ khi kết hợp với cơ chế phân loại lưu lượng dùng NBAR. Ngoài việc phân loại các giao thức bình thường như http, ftp... dựa trên cổng ứng dụng (port), NBAR còn cho phép người dùng phân loại sâu bên trong nội dung gói tin giúp có thể phân loại chi tiết chẳng hạn: phân loại những lưu lượng nào đến trang web cụ thể, url tương ứng .... Cách cấu hình được nhận dạng qua câu lệnh match protocol.
Sơ đồ:
Hình 1
Thực hiện
A.Cấu hình ban đầu của hệ thống:
Cấu hình R1:R1#sh runBuilding 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 ndip route 0.0.0.0 0.0.0.0 192.1.1.2!!line con 0 exec-timeout 0 0 logging synchronousline aux 0line vty 0 4 privilege level 15 no login!scheduler allocate 20000 1000!end
Cấu hình R2R2#sh runBuilding configuration...
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!interface Serial0/3/0 no ip address shutdown clock rate 2000000!ip route 10.10.0.0 255.255.0.0 192.1.1.1!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 synchronousline aux 0line 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 Building configuration...
Current configuration : 832 bytes!version 12.3!hostname c2600_1!ip subnet-zeroip cef!!interface Ethernet0/0 ip address 10.10.10.2 255.255.255.0 half-duplex!ip http serverno ip http secure-serverip classlessip 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 synchronousline aux 0line vty 0 4 privilege level 15 no login!end
Cấu hình trên thiết bị C2600_2:c2600_2#sh runBuilding configuration...
Current configuration : 854 bytes!version 12.3!hostname c2600_2!
ip subnet-zeroip cef!interface Ethernet0/0 ip address 20.20.20.2 255.255.255.0 half-duplex!ip classlessip 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 synchronousline aux 0line vty 0 4 privilege level 15 logging synchronous no login!end
Yêu cầu 1:
Dùng cách cấu hình theo kiểu MQC cấu hình phân loại các lưu lượng sau kết hợp với NBAR:
Phân loại web tổng quát Phân loại lưu lượng tải gói voip Phân loại lưu lượng điều khiển thoại
Cấu hình:
R1#conf tR1(config)#class-map webR1(config-cmap)#match protocol http << phân loại web tổng quátR1(config-cmap)#exit
R1(config)#class-map voip
R1(config-cmap)#match protocol rtp audio << phân loại lưu lượng voipR1(config-cmap)#exit
R1(config)#class-map voip-controlR1(config-cmap)#match protocol rtcp << phân loại lưu lượng điều khiển voip
R1(config)#policy-map classify R1(config-pmap)#class webR1(config-pmap-c)#exitR1(config-pmap)#class voipR1(config-pmap-c)#exitR1(config-pmap)#class voip-controlR1(config-pmap-c)#exitR1(config-pmap)#end
Kiểm tra cấu hình:
R1#sh policy-map Policy Map classify Class web Class voip Class voip-control
Xem thông tin trạng thái trước khi gửi dữ liệu chạy qua:
R1#sh policy-map int s0/1/0 Serial0/1/0
Service-policy output: classify
Class-map: voip (match-all) 0 packets, 0 bytes 5 minute offered rate 0 bps Match: protocol rtp audio
Class-map: voip-control (match-all) 0 packets, 0 bytes 5 minute offered rate 0 bps Match: protocol rtcp
Class-map: web (match-all) 0 packets, 0 bytes 5 minute offered rate 0 bps Match: protocol http
Class-map: class-default (match-any) 0 packets, 0 bytes 5 minute offered rate 0 bps, drop rate 0 bps Match: any
Khởi tạo traffic web, thực hiện gọi thoại giữa 1111 và 2222 và xem kết quả
R1#sh policy-map int s0/1/0 Serial0/1/0
Service-policy output: classify
Class-map: voip (match-all) 1375 packets, 87789 bytes 5 minute offered rate 6000 bps Match: protocol rtp audio
Class-map: voip-control (match-all) 8 packets, 1288 bytes 5 minute offered rate 0 bps Match: protocol rtcp
Class-map: web (match-all) 951 packets, 170759 bytes 5 minute offered rate 0 bps Match: protocol http
Class-map: class-default (match-any) 3963 packets, 362192 bytes 5 minute offered rate 0 bps, drop rate 0 bps Match: any
Yêu cầu 2: Phân loại dựa trên các thông tin trong nội dung lưu lượng
Phân loại lưu lượng của trang web có tên cisco.com theo hướng phân loại dữ liệu
R1(config)#class-map web-ciscoR1(config-cmap)#match protocol http host cisco.comR1(config-cmap)#R1(config)#policy-map classifyR1(config-pmap)#no class web << xóa cấu hình cũR1(config-pmap)#no class rtp << xóa cấu hình cũR1(config-pmap)#no class voip << xóa cấu hình cũR1(config-pmap)#no class voip-control << xóa cấu hình cũR1(config-pmap)#class web-cisco << áp dụng cấu hình mớiR1(config-pmap-c)#exitR1(config-pmap)#endR1#sh policy-map Policy Map classify Class web-cisco
Gửi lưu lượng yêu cầu thông tin từ trang web cisco.com
Hình 2
Kiểm tra thông tin trạng thái
R1#sh policy-map int s0/1/0 Serial0/1/0
Service-policy output: classify
Class-map: web-cisco (match-all) 29 packets, 6536 bytes << số lượng gói tin tăng lên 5 minute offered rate 3000 bps Match: protocol http host "cisco.com"
Class-map: class-default (match-any) 15761 packets, 1231469 bytes 5 minute offered rate 38000 bps, drop rate 0 bps Match: any
Xóa cấu hình service-policy đã cấu hình chuẩn bị cho phần lab tiếp theo
Yêu cầu: Phân loại dựa trên giá trị URL
Phân loại các gói tin của lưu lượng đi đến bất kỳ trang web nào có thông tin /web/learning/ trong đường dẫn.
R1(config)#policy-map urlR1(config-cmap)#match protocol http url */web/learning/*R1(config-cmap)#end
R1(config)#int s0/1/0R1(config-if)#service-policy output urlR1(config-if)#end
Kiểm tra thông tin trạng thái:R1#sh policy-map int s0/1/0 Serial0/1/0
Service-policy output: url
Class-map: url (match-all) 0 packets, 0 bytes 5 minute offered rate 0 bps Match: protocol http url "*/web/learning/*"
Class-map: class-default (match-any) 1 packets, 340 bytes 5 minute offered rate 0 bps, drop rate 0 bps Match: any
Tiến hành lướt web
Hình 3
R1#sh policy-map int s0/1/0 Serial0/1/0
Service-policy output: url
Class-map: url (match-all) 12 packets, 5700 bytes << số lượng gói tin thỏa điều kiện tăng lên 5 minute offered rate 2000 bps Match: protocol http url "*/web/learning/*"
Class-map: class-default (match-any) 453 packets, 47061 bytes 5 minute offered rate 4000 bps, drop rate 0 bps Match: any
Yêu cầu: Phân loại lưu lượng dựa trên các thông tin về mime tương ứng
Yêu cầu phân loại những lưu lượng mang file image có định dạng jpeg
R1(config)#class-map match-all MIMER1(config-cmap)# match protocol http mime "image/jpeg"
Trong trường hợp này sẽ so trùng kiểu mime là image với dạng file là jpeg, jpg, jpe, jfif, pjpeg, pjp
R1(config)#policy-map http-mimeR1(config-pmap)#class MIME
Áp dụng lên cổng:
R1(config)# int s0/1/0R1(config-if)#service-policy input http-mime
Trước khi gửi thông tin tiến hành kiểm tra trạng thái:
R1(config)#do sh policy-map int s0/1/0 Serial0/1/0
Service-policy input: http-mime
Class-map: MIME (match-all) 0 packets, 0 bytes 5 minute offered rate 0 bps Match: protocol http mime "image/jpeg"
Class-map: class-default (match-any) 751 packets, 521590 bytes 5 minute offered rate 4000 bps, drop rate 0 bps Match: any
Sau đó tiến hành duyệt web xem hình
Hình 4
Kiểm tra thông tin trạng thái: Serial0/1/0
Service-policy input: http-mime
Class-map: MIME (match-all) 91 packets, 67559 bytes << số lượng gói tin thỏa điều kiện tăng
lên 5 minute offered rate 2000 bps Match: protocol http mime "image/jpeg"
Class-map: class-default (match-any) 759 packets, 525425 bytes 5 minute offered rate 4000 bps, drop rate 0 bps Match: any