|
Trong bài viết hôm nay, tôi xin giới thiệu bài lab về ứng dụng route-map trong quá trình redistribution giữa các giao thức định tuyến, để lọc route theo ý muốn. Topo mạng khá đơn giản, R2 chạy RIPv2, với các loopback tương ứng, R1 chạy RIPv2 và OSPF, R3 chạy OSPF, cùng với các loopback tương ứng. Kết nối giữa các router R1,R2,R3 là FastEthernet, sử dụng lần lượt là R2-R1: 1.1.1.0/30; R1-R3:1.1.2.0/30.

Sau khi cấu hình RIP và OSPF trên các router, đây là bảng định tuyến của các router sau khi hội tụ.
R1#show ip route 1.0.0.0/30 is subnetted, 2 subnets C 1.1.1.0 is directly connected, FastEthernet0/1 C 1.1.2.0 is directly connected, FastEthernet0/0 192.168.10.0/24 is variably subnetted, 4 subnets, 2 masks R 192.168.10.32/28 [120/1] via 1.1.1.1, 00:00:10, FastEthernet0/1 R 192.168.10.0/28 [120/1] via 1.1.1.1, 00:00:10, FastEthernet0/1 R 192.168.10.0/24 [120/1] via 1.1.1.1, 00:02:31, FastEthernet0/1 R 192.168.10.16/28 [120/1] via 1.1.1.1, 00:00:10, FastEthernet0/1 10.0.0.0/32 is subnetted, 3 subnets O 10.10.10.1 [110/2] via 1.1.2.1, 00:00:39, FastEthernet0/0 O 10.10.10.17 [110/2] via 1.1.2.1, 00:00:39, FastEthernet0/0 O 10.10.10.33 [110/2] via 1.1.2.1, 00:00:39, FastEthernet0/0
R2:
R2#show ip route Gateway of last resort is not set
1.0.0.0/30 is subnetted, 2 subnets C 1.1.1.0 is directly connected, FastEthernet0/1 R 1.1.2.0 [120/1] via 1.1.1.2, 00:00:00, FastEthernet0/1 192.168.10.0/28 is subnetted, 3 subnets C 192.168.10.32 is directly connected, Loopback2 C 192.168.10.0 is directly connected, Loopback0 C 192.168.10.16 is directly connected, Loopback1
Và R3:
R3#show ip route Gateway of last resort is not set 1.0.0.0/30 is subnetted, 1 subnets C 1.1.2.0 is directly connected, FastEthernet0/0 10.0.0.0/28 is subnetted, 3 subnets C 10.10.10.0 is directly connected, Loopback0 C 10.10.10.16 is directly connected, Loopback1 C 10.10.10.32 is directly connected, Loopback2
Đương nhiên, tại thời điểm này từ R3 chưa thể đến được mạng của R2 (Các mạng Loopback cũng như đến đầu Fe của R2)
R3#ping 192.168.10.1
Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.10.1, timeout is 2 seconds: ..... Success rate is 0 percent (0/5) Ta sẽ thực hiện redistribution trên R1 để cho phép 2 giao thức này hiểu được nhau. Trên R1 cấu hình ở mức router RIP.
R1(config-router)#redistribute ospf 5 metric 5
Sau khi thời gian hội tụ kết thúc, trên R2 đã xuất hiện các mạng của R3 đã được R1 chuyển từ OSPF sang RIP
R2#show ip route Gateway of last resort is not set
1.0.0.0/30 is subnetted, 2 subnets C 1.1.1.0 is directly connected, FastEthernet0/1 R 1.1.2.0 [120/1] via 1.1.1.2, 00:00:01, FastEthernet0/1 192.168.10.0/28 is subnetted, 3 subnets C 192.168.10.32 is directly connected, Loopback2 C 192.168.10.0 is directly connected, Loopback0 C 192.168.10.16 is directly connected, Loopback1 10.0.0.0/32 is subnetted, 3 subnets R 10.10.10.1 [120/5] via 1.1.1.2, 00:00:01, FastEthernet0/1 R 10.10.10.17 [120/5] via 1.1.1.2, 00:00:01, FastEthernet0/1 R 10.10.10.33 [120/5] via 1.1.1.2, 00:00:01, FastEthernet0/1
Tương tự, trên R1 tiếp tục redistrubute những gì học được từ RIP sang OSPF R1(config-router)#redistribute rip subnets metric 25
Và lúc này, trên bảng định tuyến trên R3 đã được cập nhật
R3#show ip route Gateway of last resort is not set
1.0.0.0/30 is subnetted, 2 subnets O E2 1.1.1.0 [110/25] via 1.1.2.2, 00:00:06, FastEthernet0/0 C 1.1.2.0 is directly connected, FastEthernet0/0 192.168.10.0/28 is subnetted, 3 subnets O E2 192.168.10.32 [110/25] via 1.1.2.2, 00:00:06, FastEthernet0/0 O E2 192.168.10.0 [110/25] via 1.1.2.2, 00:00:06, FastEthernet0/0 O E2 192.168.10.16 [110/25] via 1.1.2.2, 00:00:06, FastEthernet0/0 10.0.0.0/28 is subnetted, 3 subnets C 10.10.10.0 is directly connected, Loopback0 C 10.10.10.16 is directly connected, Loopback1 C 10.10.10.32 is directly connected, Loopback2.
Và bây giờ, ta sẽ dùng route-map để lọc route. Ví dụ, trên ta muốn R1, khi redistrubute từ RIP sang OSPF thì phải loại trừ mạng 192.168.10.32/28. Nói cách khách, sau khi học được mạng 192.168.10.32 từ giao thức RIP, thì ta muốn R1 khi quảng bá sang cho R3, tuyến đường này sẽ bị chặn. Ta làm như sau.
Trên R1 tạo access-list 10
access-list 10 deny 192.168.10.32 0.0.0.15 access-list 10 permit any
Tạo route-map có tên Loc_Route và match vào access-list 10.
Redistribute lại cho OSPF
R1(config-router)#redistribute rip subnets route-map Loc_route metric 15
Sau khi thời gian hội tụ, trong bảng định tuyến của R3, tuyến đường 192.168.10.32 đã bị mất
R3#show ip route Gateway of last resort is not set 1.0.0.0/30 is subnetted, 2 subnets O E2 1.1.1.0 [110/15] via 1.1.2.2, 00:00:18, FastEthernet0/0 C 1.1.2.0 is directly connected, FastEthernet0/0 192.168.10.0/28 is subnetted, 2 subnets O E2 192.168.10.0 [110/15] via 1.1.2.2, 00:00:18, FastEthernet0/0 O E2 192.168.10.16 [110/15] via 1.1.2.2, 00:00:18, FastEthernet0/0 10.0.0.0/28 is subnetted, 3 subnets C 10.10.10.0 is directly connected, Loopback0 C 10.10.10.16 is directly connected, Loopback1 C 10.10.10.32 is directly connected, Loopback2
Và như chúng ta thấy, từ R3 vẫn sang được mạng 192.168.10.16/28 nhưng mạng 192.168.10.32/28 thì không được.
R3#ping 192.168.10.17 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.10.17, timeout is 2 seconds: !! *Mar 1 00:32:41.851: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 428/716/864 ms R3#ping 192.168.10.33 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.10.33, timeout is 2 seconds: ..... Success rate is 0 percent (0/5) R3#
HoàNĐ is a member of CMgroupVN |