Lệnh distance chỉ thay đổi giá trị AD Administrative Distance của đường đi route khi route được cài đặt vào bảng định tuyến.. Đối với load balancing có nhiều đường đi đến cùng một networ
Trang 1Lab 6-5: DISTANCE VÀ REDISTRIBUTION.
Mô tả:
Bài thực hành này mô tả cách sử dụng các lệnh distance và route redistribution Lệnh distance chỉ thay đổi giá trị AD (Administrative Distance) của đường đi (route) khi route được cài đặt vào bảng định tuyến Do đó, lệnh distance chỉ có tác dụng bên trong router,
và không ảnh hưởng đến các router khác trong routing domain Kỹ thuật distance sử dụng lệnh distance để tăng AD của route Đối với load balancing có nhiều đường đi đến cùng một network, ta có thể ưu tiên sử dụng một đường đi và loại bỏ các đường đi khác, và tạo được các đường đi dự phòng
Khi một route được redistribution nhiều lần, và có thể sẽ được đưa lại network đã có route đó với AD thấp hơn (do độ ưu tiên của nguồn giao thức) nên có độ ưu tiên cao hơn
Do đó, ta sẽ có hiện tượng suboptimal đường đi hay routing loop Vì vậy, cần cẩn thận khi thay đổi distance của các route Lệnh distance tổng quát (distance <AD> được áp dụng đối với tất cả các giao thức) Ngoài ra, các giao thức BGP, OSPF, EIGRP có lệnh distance riêng
Công ty ABC đang ở trong giai đoạn giao thức migration, sử dụng OSPF và RIPv2 như trong hình vẽ Do đó, cần có mutual redistribution giữa hai giao thức để các network đều thấy nhau Đường đi B-C-D có băng thông thấp hơn, nên được sử dụng làm đường
backup.Chỉ có router A làm redistribution cho RIP vào OSPF Router A và D làm
redistribution cho OSPF vào RIP tạo nên load balancing Dùng AD để chuyển BCD thành đường backup cho BAD
Thực hiện
1 Xây dựng và cấu hình mạng theo sơ đồ nhưng chưa cấu hình OSPF Dùng các lệnh CDP và ping để kiểm tra các kết nốI trực tiếp vớI nhau
2 Cấu hình RIP trên A, C, D
Trang 2RouterA(config)#router rip
RouterA(config-router)#version 2
RouterA(config-router)#network 192.168.1.0
RouterA(config-router)#no auto-summary
RouterC(config)#router rip
RouterC(config-router)#version 2
RouterC(config-router)#no auto-summary
RouterC(config-router)#network 192.168.4.0
RouterD(config)#router rip
RouterD(config-router)#version 2
RouterD(config-router)#network 192.168.10.0
RouterD(config-router)#network 192.168.1.0
RouterD(config-router)#network 192.168.4.0
Kiểm tra trên các bảng định tuyến trên router A và C, ta sẽ thấy có 2 RIP route mới
RouterA#show ip route
R 192.168.10.0/24 [120/1] via 192.168.1.2, 00:00:13, FastEthernet0/0
192.168.11.0/32 is subnetted, 1 subnets
R 192.168.4.0 [120/1] via 192.168.1.2, 00:00:13, FastEthernet0/0
Trang 3C 192.168.1.0/24 is directly connected, FastEthernet0/0
192.168.2.0/25 is subnetted, 1 subnets
C 192.168.2.0 is directly connected, FastEthernet0/1
192.168.3.0/30 is subnetted, 1 subnets
RouterC#show ip route
R 192.168.10.0/24 [120/1] via 192.168.4.2, 00:00:09, Serial0/0 192.168.4.0/30 is subnetted, 1 subnets
C 192.168.4.0 is directly connected, Serial0/0
R 192.168.1.0/24 [120/1] via 192.168.4.2, 00:00:09, Serial0/0 192.168.3.0/30 is subnetted, 1 subnets
C 192.168.3.0 is directly connected, Serial0/1
3 Cấu hình OSPF trên A, B, C
Ta cấu hình OSPF cho router A, B, C như sau:
RouterA(config)#router ospf 1
RouterA(config-router)#network 192.168.2.0 0.0.0.127 area 0
RouterB(config)#router ospf 1
RouterB(config-router)#network 192.168.2.0 0.0.0.127 area 0 RouterB(config-router)#network 192.168.3.0 0.0.0.3 area 0
Trang 4RouterB(config-router)#network 192.168.11.0 0.0.0.255 area 0
RouterC(config)#router ospf 1
RouterC(config-router)#network 192.168.3.0 0.0.0.3 area 0
Kiểm tra trên các bảng định tuyến trên router A và C, ta sẽ thấy có các route học từ OSPF
RouterA#show ip route
R 192.168.10.0/24 [120/1] via 192.168.1.2, 00:00:22, FastEthernet0/0
192.168.11.0/32 is subnetted, 1 subnets
O 192.168.11.1 [110/11] via 192.168.2.2, 00:11:25, FastEthernet0/1
192.168.4.0/30 is subnetted, 1 subnets
R 192.168.4.0 [120/1] via 192.168.1.2, 00:00:22, FastEthernet0/0
C 192.168.1.0/24 is directly connected, FastEthernet0/0
192.168.2.0/25 is subnetted, 1 subnets
C 192.168.2.0 is directly connected, FastEthernet0/1
192.168.3.0/30 is subnetted, 1 subnets
O 192.168.3.0 [110/74] via 192.168.2.2, 00:11:26, FastEthernet0/1
RouterC#show ip route
R 192.168.10.0/24 [120/1] via 192.168.4.2, 00:00:21, Serial0/0
Trang 5192.168.11.0/32 is subnetted, 1 subnets
O 192.168.11.1 [110/65] via 192.168.3.2, 00:10:55, Serial0/1
192.168.4.0/30 is subnetted, 1 subnets
C 192.168.4.0 is directly connected, Serial0/0
R 192.168.1.0/24 [120/1] via 192.168.4.2, 00:00:21, Serial0/0
192.168.2.0/25 is subnetted, 1 subnets
O 192.168.2.0 [110/74] via 192.168.3.2, 00:10:55, Serial0/1
192.168.3.0/30 is subnetted, 1 subnets
C 192.168.3.0 is directly connected, Serial0/1
4 Đưa RIP vào OSPF vào trong OSPF ở router A
RouterA(config)#router osfpf 1
RouterA(config-router)#redistribute rip subnets
Các route mới sẽ xuất hiện trong bảng định tuyến của router B
Kiểm tra các route trên router B
RouterB#show ip route
O E2 192.168.10.0/24 [110/20] via 192.168.2.1, 00:00:31, Ethernet0/0
C 192.168.11.0/24 is directly connected, Loopback0
192.168.4.0/30 is subnetted, 1 subnets
Trang 6O E2 192.168.4.0 [110/20] via 192.168.2.1, 00:00:31, Ethernet0/0
O E2 192.168.1.0/24 [110/20] via 192.168.2.1, 00:00:31, Ethernet0/0
192.168.2.0/25 is subnetted, 1 subnets
C 192.168.2.0 is directly connected, Ethernet0/0
192.168.3.0/30 is subnetted, 1 subnets
C 192.168.3.0 is directly connected, Serial0/1
RouterC#sh ip route
O E2 192.168.10.0/24 [110/20] via 192.168.3.2, 00:02:33, Serial0/1
192.168.11.0/32 is subnetted, 1 subnets
O 192.168.11.1 [110/65] via 192.168.3.2, 00:02:55, Serial0/1
192.168.4.0/30 is subnetted, 1 subnets
C 192.168.4.0 is directly connected, Serial0/0
O E2 192.168.1.0/24 [110/20] via 192.168.3.2, 00:02:55, Serial0/1
192.168.2.0/25 is subnetted, 1 subnets
O 192.168.2.0 [110/74] via 192.168.3.2, 00:02:55, Serial0/1
192.168.3.0/30 is subnetted, 1 subnets
C 192.168.3.0 is directly connected, Serial0/1
Ta nhận thấy Router C học được các route 192.168.10.0/24 và 192.168.1.0/24 qua miền OSPF chứ không học qua RIP do AD của OSPF (110) nhỏ hơn AD của RIP (120) Ở router C, để đi đến network 192.168.10.0/24, 192.168.1.0/24, packet phải đi qua network 192.168.3.0/30 là không tối ưu (băng thông s0/1 = 64K) trong khi nếu đi qua network
Trang 7192.168.4.0/30 sẽ nhanh do có băng thông là 2M Ta sẽ chỉnh lại đường đi của packet sao cho tốt hơn
5 Để lấy lại con đường tối ưu đã học được từ RIP trên router C, ta dùng lệnh distance ospf nâng AD của các route này lên ( nghĩa là giảm độ ưu tiên xuống)
RouterC(config)#router ospf 1
RouterC(config-router)#distance ospf external 200
RouterC#clear ip route *
RouterC#show ip route
R 192.168.10.0/24 [120/1] via 192.168.4.2, 00:00:00, Serial0/0
192.168.11.0/32 is subnetted, 1 subnets
O 192.168.11.1 [110/65] via 192.168.3.2, 00:00:48, Serial0/1
192.168.4.0/30 is subnetted, 1 subnets
C 192.168.4.0 is directly connected, Serial0/0
R 192.168.1.0/24 [120/1] via 192.168.4.2, 00:00:01, Serial0/0
192.168.2.0/25 is subnetted, 1 subnets
O 192.168.2.0 [110/74] via 192.168.3.2, 00:00:48, Serial0/1
192.168.3.0/30 is subnetted, 1 subnets
C 192.168.3.0 is directly connected, Serial0/1
Ta thấy các route 192.168.1.0/24 và 192.168.10.0/24 đã được học từ RIP do có AD (120) nhỏ hơn AD của OSPF mà ta vừa cấu hình (200) Để kiểm chứng việc thay đổi AD của OSPF, ta thử shutdown cổng serial 0/0 (192.168.4.1)
Trang 8¤ Để thay đổi giá trị AD của một giao thức định tuyến, dùng lệnh:
Router(config-router)#distance weight [network wildcard-mask]
Đối với một tuyến đường tĩnh , dùng lệnh:
Router(config)#ip route network [ mask] { address | interface} [ distance]
RouterC#show ip route
O E2 192.168.10.0/24 [200/20] via 192.168.3.2, 00:00:08, Serial0/1 192.168.11.0/32 is subnetted, 1 subnets
O 192.168.11.1 [110/65] via 192.168.3.2, 00:05:09, Serial0/1
O E2 192.168.1.0/24 [200/20] via 192.168.3.2, 00:00:09, Serial0/1 192.168.2.0/25 is subnetted, 1 subnets
O 192.168.2.0 [110/74] via 192.168.3.2, 00:05:09, Serial0/1
192.168.3.0/30 is subnetted, 1 subnets
C 192.168.3.0 is directly connected, Serial0/1
6 Đưa OSPF vào RIP
RouterA(config)#router rip
RouterA(config-router)#redistribute ospf 1 metric 3
RouterC(config)#route rip
RouterC(config-router)#redistribute ospf 1 metric 3
Trang 9Kiểm tra bảng định tuyến trên router A, C và D Ở 2 router A và D không có thay đổi Nhưng ở router D, ta có multipath
RouterD#show ip route
C 192.168.10.0/24 is directly connected, Loopback0
192.168.11.0/32 is subnetted, 1 subnets
R 192.168.11.1 [120/3] via 192.168.1.1, 00:00:23, Ethernet0/0
[120/3] via 192.168.4.1, 00:00:18, Serial0/1
192.168.4.0/30 is subnetted, 1 subnets
C 192.168.4.0 is directly connected, Serial0/1
C 192.168.1.0/24 is directly connected, Ethernet0/0
192.168.2.0/25 is subnetted, 1 subnets
R 192.168.2.0 [120/3] via 192.168.1.1, 00:00:23, Ethernet0/0
[120/3] via 192.168.4.1, 00:00:18, Serial0/1
192.168.3.0/30 is subnetted, 1 subnets
R 192.168.3.0 [120/3] via 192.168.1.1, 00:00:23, Ethernet0/0
[120/3] via 192.168.4.1, 00:00:18, Serial0/1
Để tối ưu hoá các multipath route trong RIP, ta dùng lệnh distance Lệnh distance có thể dùng chung cho tất cả các giao thức định tuyến
7 Cấu hình lệnh distance
Trang 10Yêu cầu đặt ra, ta cần loại bỏ các route từ D đi đến 192.168.11.0/24 và 192.168.3.0/30 Network 192.168.4.0/24 chỉ dùng làm dự phòng cho 192.168.1.0/24 để đi ra khỏi RIP domain Do đường đi BAD ưu tiên hơn BCD, ta chỉnh AD của các route từ router C có
AD cao hơn, để loại các route này ra khỏi bảng bảng định tuyến
RouterD(config)#router rip
RouterD(config-router)#distance 200 192.168.4.1 0.0.0.0
Kiểm tra bảng định tuyến của router D Các RIP route có next-hop là 192.168.4.1 đã bị loại ra khỏi bảng định tuyến
RouterD#clear ip route *
RouterD#show ip route
C 192.168.10.0/24 is directly connected, Loopback0
192.168.11.0/32 is subnetted, 1 subnets
R 192.168.11.1 [120/3] via 192.168.1.1, 00:00:08, Ethernet0/0
192.168.4.0/30 is subnetted, 1 subnets
C 192.168.4.0 is directly connected, Serial0/1
C 192.168.1.0/24 is directly connected, Ethernet0/0
192.168.2.0/25 is subnetted, 1 subnets
R 192.168.2.0 [120/3] via 192.168.1.1, 00:00:08, Ethernet0/0
192.168.3.0/30 is subnetted, 1 subnets
R 192.168.3.0 [120/3] via 192.168.1.1, 00:00:08, Ethernet0/0
8 Kiểm tra tính dự phòng của AD
Trang 11Shutdown int fa0/0 của router A Kiểm tra bảng định tuyến của router C Các network 192.168.3.024 và 192.168.11.0/24 sẽ dùng 192.168.4.1 là next hop
RouterD#clear ip route *
RouterD#sh ip route
C 192.168.10.0/24 is directly connected, Loopback0
192.168.11.0/32 is subnetted, 1 subnets
R 192.168.11.1 [200/3] via 192.168.4.1, 00:00:02, Serial0/1
192.168.4.0/30 is subnetted, 1 subnets
C 192.168.4.0 is directly connected, Serial0/1
C 192.168.1.0/24 is directly connected, Ethernet0/0
192.168.2.0/25 is subnetted, 1 subnets
R 192.168.2.0 [200/3] via 192.168.4.1, 00:00:02, Serial0/1
192.168.3.0/30 is subnetted, 1 subnets
R 192.168.3.0 [200/3] via 192.168.4.1, 00:00:02, Serial0/1
Dùng command distance <AD> với access-líst
Giả sử phát sinh nhu cầu từ router D chỉ cho 1 một đường đi đến 192.168.3.0/30 qua 192.168.4.1 VớI các đường đi còn lạI sử dụng multi-path đến 192.168.11.0/24 Như vậy
ta cần phải loại bỏ route 192.168.3.0 với next-hop là 192.168.1.1 Cách loại bỏ sẽ là gán các route cần loại bỏ giá trị AD là 200 Thực hiện trên router D:
RouterD(config)#ip access-list standard Filter
Trang 12RouterD(config-std-nacl)# permit 192.168.3.0 0.0.0.3
RouterD(config-std-nacl)#exit
RouterD(config)#router rip
RouterD(config-router)#distance 200 192.168.4.1 0.0.0.0 Filter Kiểm tra:
RouterD#clear ip route *
RouterD#show ip route
C 192.168.10.0/24 is directly connected, Loopback0
192.168.11.0/32 is subnetted, 1 subnets
R 192.168.11.1 [120/3] via 192.168.1.1, 00:00:23, Ethernet0/0 [120/3] via 192.168.4.1, 00:00:01, Serial0/1
192.168.4.0/30 is subnetted, 1 subnets
C 192.168.4.0 is directly connected, Serial0/1
C 192.168.1.0/24 is directly connected, Ethernet0/0
192.168.2.0/25 is subnetted, 1 subnets
R 192.168.2.0 [120/3] via 192.168.1.1, 00:00:23, Ethernet0/0 [120/3] via 192.168.4.1, 00:00:01, Serial0/1
192.168.3.0/30 is subnetted, 1 subnets
R 192.168.3.0 [120/3] via 192.168.1.1, 00:00:23, Ethernet0/0
Cấu hình
RouterD#show run
Current configuration : 1182 bytes
Trang 13version 12.1
!
hostname RouterD
!
no logging buffered
!
ip subnet-zero
!
no ip finger
no ip domain-lookup
!
!
interface Loopback0
ip address 192.168.10.1 255.255.255.0
!
interface Ethernet0/0
ip address 192.168.1.2 255.255.255.0 half-duplex
!
interface Serial0/1
ip address 192.168.4.2 255.255.255.252
!
Trang 14router rip
version 2
network 192.168.1.0
network 192.168.4.0
network 192.168.10.0
distance 200 192.168.4.1 0.0.0.0 Filter
no auto-summary
!
ip kerberos source-interface any
ip classless
no ip http server
!
ip access-list standard Filter
permit 192.168.3.0 0.0.0.3
!
line con 0
logging synchronous
transport input none
line aux 0
line vty 0 4
privilege level 15
no login
terminal-type monitor
Trang 15End
RouterC#show run
Building configuration
Current configuration:
!
version 12.0
service timestamps debug uptime service timestamps log uptime
no service password-encryption
!
hostname RouterC
!
ip subnet-zero
!
interface Serial0/0
ip address 192.168.4.1 255.255.255.252
no ip directed-broadcast
clockrate 64000
!
interface Serial0/1
Trang 16ip address 192.168.3.1 255.255.255.252
no ip directed-broadcast
!
router ospf 1
network 192.168.3.0 0.0.0.3 area 0 distance ospf external 200
!
router rip
version 2
redistribute ospf 1 metric 3
network 192.168.4.0
no auto-summary
!
ip classless
!
line con 0
logging synchronous
transport input none
line aux 0
line vty 0 4
privilege level 15
no login
!
Trang 17RouterB#show run
Building configuration
Current configuration:
!
hostname RouterB
!
enable password cisco
!
interface Loopback0
ip address 192.168.11.1 255.255.255.0
!
interface Ethernet0/0
ip address 192.168.2.2 255.255.255.128
!
interface Serial0/1
ip address 192.168.3.2 255.255.255.252 clockrate 64000
!
router ospf 1
network 192.168.2.0 0.0.0.127 area 0
Trang 18network 192.168.3.0 0.0.0.3 area 0 network 192.168.11.0 0.0.0.255 area 0
!
ip classless
!
line con 0
logging synchronous
transport input none
line aux 0
line vty 0 4
privilege level 15
no login
RouterA#show run
!
hostname RouterA
!
enable password cisco
!
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.0 duplex auto
speed auto
Trang 19interface FastEthernet0/1
ip address 192.168.2.1 255.255.255.128 duplex auto
speed auto
!
router ospf 1
redistribute rip subnets
network 192.168.2.0 0.0.0.127 area 0
!
router rip
version 2
redistribute ospf 1 metric 3
network 192.168.1.0
no auto-summary
!
ip kerberos source-interface any
ip classless
no ip http server
!
line con 0
logging synchronous
transport input none
Trang 20line aux 0
line vty 0 4 privilege level 15
no login
!
end