Cấu hình:
R1
router eigrp 1
redistribute connected
redistribute ospf 1 metric 1000 100 255 1 1500
network 192.168.12.0
no auto-summary!
router ospf 1
log-adjacency-changes
redistribute connected subnets
redistribute eigrp 1 subnets
network 192.168.13.0 0.0.0.255 area 0
R2
router eigrp 1
network 1.1.1.0 0.0.0.255
network 10.1.1.0 0.0.0.255
network 172.16.1.0 0.0.0.255
network 192.168.1.0
network 192.168.12.0
no auto-summary
R3
router ospf 1
log-adjacency-changes
network 3.3.3.0 0.0.0.255 area 0
network 10.3.3.0 0.0.0.255 area 0
network 172.16.3.0 0.0.0.255 area 0
network 192.168.3.0 0.0.0.255 area 0
network 192.168.13.0 0.0.0.255 area 0
Kiểm tra bảng định tuyến, tất cả các mạng đã hội tụ:
R1
C 192.168.12.0/24 is directly connected, FastEthernet0/0
1.0.0.0/24 is subnetted, 1 subnets
D 1.1.1.0 [90/156160] via 192.168.12.2, 00:19:38, FastEthernet0/0
C 192.168.13.0/24 is directly connected, FastEthernet0/1
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/2] via 192.168.13.3, 00:15:49, FastEthernet0/1
172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
O 172.16.3.3/32 [110/2] via 192.168.13.3, 00:15:49, FastEthernet0/1
D 172.16.1.0/24 [90/156160] via 192.168.12.2, 00:19:38, FastEthernet0/0
C 172.16.2.0/24 is directly connected, Loopback1
10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
O 10.3.3.3/32 [110/2] via 192.168.13.3, 00:15:52, FastEthernet0/1
C 10.2.2.0/24 is directly connected, Loopback2
D 10.1.1.0/24 [90/156160] via 192.168.12.2, 00:19:41, FastEthernet0/0
D 192.168.1.0/24 [90/156160] via 192.168.12.2, 00:19:42, FastEthernet0/0
C 192.168.2.0/24 is directly connected, Loopback3
192.168.3.0/32 is subnetted, 1 subnets
O 192.168.3.3 [110/2] via 192.168.13.3, 00:15:54, FastEthernet0/1
R2
C 192.168.12.0/24 is directly connected, FastEthernet0/0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
D EX 192.168.13.0/24 [170/30720] via 192.168.12.1, 00:13:51, FastEthernet0/0
2.0.0.0/24 is subnetted, 1 subnets
D EX 2.2.2.0 [170/156160] via 192.168.12.1, 00:13:51, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
D EX 3.3.3.3 [170/2588160] via 192.168.12.1, 00:14:59, FastEthernet0/0
172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
D EX 172.16.3.3/32
[170/2588160] via 192.168.12.1, 00:14:59, FastEthernet0/0
C 172.16.1.0/24 is directly connected, Loopback2
D EX 172.16.2.0/24 [170/156160] via 192.168.12.1, 00:13:51, FastEthernet0/0
10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
D EX 10.3.3.3/32 [170/2588160] via 192.168.12.1, 00:14:59, FastEthernet0/0
D EX 10.2.2.0/24 [170/156160] via 192.168.12.1, 00:13:52, FastEthernet0/0
C 10.1.1.0/24 is directly connected, Loopback1
C 192.168.1.0/24 is directly connected, Loopback3
D EX 192.168.2.0/24 [170/156160] via 192.168.12.1, 00:13:52, FastEthernet0/0
192.168.3.0/32 is subnetted, 1 subnets
D EX 192.168.3.3 [170/2588160] via 192.168.12.1, 00:15:00, FastEthernet0/0
R3
O E2 192.168.12.0/24 [110/20] via 192.168.13.1, 00:16:31, FastEthernet0/1
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 192.168.13.1, 00:16:31, FastEthernet0/1
C 192.168.13.0/24 is directly connected, FastEthernet0/1
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [110/20] via 192.168.13.1, 00:14:16, FastEthernet0/1
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
172.16.0.0/24 is subnetted, 3 subnets
O E2 172.16.1.0 [110/20] via 192.168.13.1, 00:16:31, FastEthernet0/1
O E2 172.16.2.0 [110/20] via 192.168.13.1, 00:14:16, FastEthernet0/1
C 172.16.3.0 is directly connected, Loopback2
10.0.0.0/24 is subnetted, 3 subnets
C 10.3.3.0 is directly connected, Loopback1
O E2 10.2.2.0 [110/20] via 192.168.13.1, 00:14:17, FastEthernet0/1
O E2 10.1.1.0 [110/20] via 192.168.13.1, 00:16:33, FastEthernet0/1
O E2 192.168.1.0/24 [110/20] via 192.168.13.1, 00:16:33, FastEthernet0/1
O E2 192.168.2.0/24 [110/20] via 192.168.13.1, 00:14:17, FastEthernet0/1
C 192.168.3.0/24 is directly connected, Loopback3
R1(config)#access-list 1 permit 10.0.0.0 0.255.255.255
R1(config)#access-list 1 permit 172.16.0.0 0.0.255.255
R1(config)#access-list 1 permit 192.168.0.0 0.0.255.255
R1(config)#router eigrp 1
R1(config-router)#distribute-list 1 out ospf 1
R1(config)#router ospf 1
R1(config-router)#distribute-list 1 out eigrp 1
Kiểm tra lại bảng định tuyến R2:
R2#show ip route
(đã bỏ qua một số dòng)
C 192.168.12.0/24 is directly connected, FastEthernet0/0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
D EX 192.168.13.0/24 [170/30720] via 192.168.12.1, 00:00:08, FastEthernet0/0
2.0.0.0/24 is subnetted, 1 subnets
D EX 2.2.2.0 [170/156160] via 192.168.12.1, 00:00:08, FastEthernet0/0
172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
D EX 172.16.3.3/32 [170/2588160] via 192.168.12.1, 00:00:08, FastEthernet0/0
C 172.16.1.0/24 is directly connected, Loopback2
D EX 172.16.2.0/24 [170/156160] via 192.168.12.1, 00:00:08, FastEthernet0/0
10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
D EX 10.3.3.3/32 [170/2588160] via 192.168.12.1, 00:00:08, FastEthernet0/0
D EX 10.2.2.0/24 [170/156160] via 192.168.12.1, 00:00:09, FastEthernet0/0
C 10.1.1.0/24 is directly connected, Loopback1
C 192.168.1.0/24 is directly connected, Loopback3
D EX 192.168.2.0/24 [170/156160] via 192.168.12.1, 00:00:09, FastEthernet0/0
192.168.3.0/32 is subnetted, 1 subnets
D EX 192.168.3.3 [170/2588160] via 192.168.12.1, 00:00:11, FastEthernet0/0
Tạo access-list 3, chặn các route dạng private, chỉ cho qua các route dạng public (2.2.2.2):
R1(config)#access-list 3 deny 10.0.0.0 0.255.255.255
R1(config)#access-list 3 deny 172.16.0.0 0.0.255.255
R1(config)#access-list 3 deny 192.168.0.0 0.0.255.255
R1(config)#access-list 3 permit any
Tạo Distribute-list:
R1(config)#router eigrp 1
R1(config-router)#distribute-list 3 out connected
R1(config-router)#router ospf 1
R1(config-router)#distribute-list 3
R1(config-router)#distribute-list 3 out connected
Xem lại bảng định tuyến R2:
R2#show ip route
(đã bỏ qua một số dòng)
C 192.168.12.0/24 is directly connected, FastEthernet0/0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/24 is subnetted, 1 subnets
D EX 2.2.2.0 [170/156160] via 192.168.12.1, 00:00:06, FastEthernet0/0
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
D EX 172.16.3.3/32
[170/2588160] via 192.168.12.1, 00:00:06, FastEthernet0/0
C 172.16.1.0/24 is directly connected, Loopback2
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
D EX 10.3.3.3/32 [170/2588160] via 192.168.12.1, 00:00:06, FastEthernet0/0
C 10.1.1.0/24 is directly connected, Loopback1
C 192.168.1.0/24 is directly connected, Loopback3
192.168.3.0/32 is subnetted, 1 subnets
D EX 192.168.3.3 [170/2588160] via 192.168.12.1, 00:00:06, FastEthernet0/0
Quan sát bảng định tuyến hiện tại của R3:
R3#show ip route
(đã bỏ qua một số dòng)
C 192.168.13.0/24 is directly connected, FastEthernet0/1
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [110/20] via 192.168.13.1, 00:33:38, FastEthernet0/1
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
172.16.0.0/24 is subnetted, 2 subnets
O E2 172.16.1.0 [110/20] via 192.168.13.1, 00:03:45, FastEthernet0/1
C 172.16.3.0 is directly connected, Loopback2
10.0.0.0/24 is subnetted, 2 subnets
C 10.3.3.0 is directly connected, Loopback1
O E2 10.1.1.0 [110/20] via 192.168.13.1, 00:03:45, FastEthernet0/1
O E2 192.168.1.0/24 [110/20] via 192.168.13.1, 00:03:45, FastEthernet0/1
C 192.168.3.0/24 is directly connected, Loopback3
Ta sử dụng redistribute kèm với route – map để đáp ứng yêu cầu này:
R1(config)#access-list 10 permit 10.1.1.0 0.0.0.255
R1(config)#access-list 20 permit 172.16.1.0 0.0.0.255
R1(config)#access-list 30 permit any
R1(config)#route-map cau4 permit 10
R1(config-route-map)#match ip add 10
R1(config-route-map)#set metric 49
R1(config-route-map)#set metric-type type-1
R1(config-route-map)#exit
R1(config)#route-map cau4 permit 20
R1(config-route-map)#match ip add 20
R1(config-route-map)#set metric 69
R1(config-route-map)#set metric-type type-1
R1(config-route-map)#exit
R1(config)#route-map cau4 permit 30
R1(config-route-map)#match ip add 30
R1(config-route-map)#set metric 90
R1(config-route-map)#set metric-type type-2
R1(config)#router ospf 1
R1(config-router)#redistribute connected route-map cau4 subnets
R1(config-router)#redistribute eigrp 1 route-map cau4 subnets
Xem lại bảng định tuyến R3:
R3#show ip route
(đã bỏ qua một số dòng)
C 192.168.13.0/24 is directly connected, FastEthernet0/1
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [110/90] via 192.168.13.1, 00:05:28, FastEthernet0/1
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
172.16.0.0/24 is subnetted, 2 subnets
O E1 172.16.1.0 [110/70] via 192.168.13.1, 00:00:34, FastEthernet0/1
C 172.16.3.0 is directly connected, Loopback2
10.0.0.0/24 is subnetted, 2 subnets
C 10.3.3.0 is directly connected, Loopback1
O E1 10.1.1.0 [110/50] via 192.168.13.1, 00:01:34, FastEthernet0/1
O E2 192.168.1.0/24 [110/90] via 192.168.13.1, 00:05:08, FastEthernet0/1
C 192.168.3.0/24 is directly connected, Loopback3
Sử dụng access-list 1 đã tạo ở trên:
access-list 1 permit 192.168.0.0 0.0.255.255
access-list 1 permit 172.16.0.0 0.0.255.255
access-list 1 permit 10.0.0.0 0.255.255.255
Tạo các route – map:
route-map cau5 permit 10
match ip address 1
set metric 1000 100 255 1 1500
!
route-map cau5 permit 20
set metric 500 50 255 1 1500
Sử dụng route – map này trong câu lệnh redistribute:
router eigrp 1
redistribute connected route-map cau5
redistribute ospf 1 metric 1000 100 255 1 1500
Kiểm tra kết quả:
R2#show ip route 2.2.2.2
Routing entry for 2.2.2.0/24
Known via "eigrp 1", distance 170, metric 5135360, type external
Redistributing via eigrp 1
Last update from 192.168.12.1 on FastEthernet0/0, 00:05:15 ago
Routing Descriptor Blocks:
* 192.168.12.1, from 192.168.12.1, 00:05:15 ago, via FastEthernet0/0
Route metric is 5135360, traffic share count is 1
Total delay is 600 microseconds, minimum bandwidth is 500 Kbit
Reliability 255/255, minimum MTU 1500 bytes
Loading 1/255, Hops 1
Các Route private vẫn giữ seed metric như cũ (được thiết lập từ bộ thông số: 1000 100 255 1 1500):
R2#sh ip ro 192.168.3.3
Routing entry for 192.168.3.3/32
Known via "eigrp 1", distance 170, metric 2588160, type external
Redistributing via eigrp 1
Last update from 192.168.12.1 on FastEthernet0/0, 00:29:03 ago
Routing Descriptor Blocks:
* 192.168.12.1, from 192.168.12.1, 00:29:03 ago, via FastEthernet0/0
Route metric is 2588160, traffic share count is 1
Total delay is 1100 microseconds, minimum bandwidth is 1000 Kbit
Reliability 255/255, minimum MTU 1500 bytes
Loading 1/255, Hops 1
R1
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface Loopback1
ip address 172.16.2.2 255.255.255.0
!
interface Loopback2
ip address 10.2.2.2 255.255.255.0
!
interface Loopback3
ip address 192.168.2.2 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.12.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.13.1 255.255.255.0
duplex auto
speed auto
!
router eigrp 1
redistribute connected route-map cau5
redistribute ospf 1 metric 1000 100 255 1 1500
network 192.168.12.0
distribute-list 3 out connected
distribute-list 1 out ospf 1
no auto-summary
--More--
router ospf 1
log-adjacency-changes
redistribute connected subnets route-map cau4
redistribute eigrp 1 subnets route-map cau4
network 192.168.13.0 0.0.0.255 area 0
distribute-list 3 out connected
distribute-list 1 out eigrp 1
!
ip classless
!
access-list 1 permit 192.168.0.0 0.0.255.255
access-list 1 permit 172.16.0.0 0.0.255.255
access-list 1 permit 10.0.0.0 0.255.255.255
access-list 3 deny 10.0.0.0 0.255.255.255
access-list 3 deny 172.16.0.0 0.0.255.255
access-list 3 deny 192.168.0.0 0.0.255.255
access-list 3 permit any
access-list 10 permit 10.1.1.0 0.0.0.255
access-list 20 permit 172.16.1.0 0.0.0.255
access-list 30 permit any
!
route-map cau5 permit 10
match ip address 1
set metric 1000 100 255 1 1500
!
route-map cau5 permit 20
set metric 500 50 255 1 1500
!
route-map cau4 permit 10
match ip address 10
set metric 49
set metric-type type-1
!
route-map cau4 permit 20
match ip address 20
set metric 69
set metric-type type-1
!
route-map cau4 permit 30
match ip address 30
set metric 90
set metric-type type-2
R2
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface Loopback1
ip address 10.1.1.1 255.255.255.0
!
interface Loopback2
ip address 172.16.1.1 255.255.255.0
!
interface Loopback3
ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.12.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
no ip address
shutdown
duplex auto
speed auto
!
router eigrp 1
network 1.1.1.0 0.0.0.255
network 10.1.1.0 0.0.0.255
network 172.16.1.0 0.0.0.255
network 192.168.1.0
network 192.168.12.0
no auto-summary
R3
interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface Loopback1
ip address 10.3.3.3 255.255.255.0
!
interface Loopback2
ip address 172.16.3.3 255.255.255.0
!
interface Loopback3
ip address 192.168.3.3 255.255.255.0
!
interface FastEthernet0/0
no ip address
shutdown
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.13.3 255.255.255.0
duplex auto
speed auto
!
router ospf 1
log-adjacency-changes
network 3.3.3.0 0.0.0.255 area 0
network 10.3.3.0 0.0.0.255 area 0
network 172.16.3.0 0.0.0.255 area 0
network 192.168.3.0 0.0.0.255 area 0
network 192.168.13.0 0.0.0.255 area 0