之前都已經測試過PBR, 今次再增加點測試題目, 由PC1到R4的lo1 192.168.5.1
PC1
no ip domain-lookup no ip routing ip default-gateway 10.0.0.1 int e0/0 no shut ip add 10.0.0.10 255.255.255.0
R1
int e0/0 no shut ip add 12.0.0.1 255.255.255.0 int e0/1 no shut ip add 13.0.0.1 255.255.255.0 int e0/2 no shut ip add 10.0.0.1 255.255.255.0 router eigrp 1 no auto network 12.0.0.0 0.0.0.255 network 13.0.0.0 0.0.0.255 network 10.0.0.1 0.0.0.255
R2
int e0/0 no shut ip add 12.0.0.2 255.255.255.0 ip add 12.0.0.22 255.255.255.0 sec int e0/1 no shut ip add 24.0.0.2 255.255.255.0 router eigrp 1 no auto network 12.0.0.0 0.0.0.255 network 24.0.0.0 0.0.0.255
R3
int e0/0 no shut ip add 13.0.0.3 255.255.255.0 int e0/1 no shut ip add 34.0.0.3 255.255.255.0 router eigrp 1 no auto network 13.0.0.0 0.0.0.255 network 34.0.0.0 0.0.0.255
R4
int e0/0 no shut ip add 24.0.0.4 255.255.255.0 int e0/1 no shut ip add 34.0.0.4 255.255.255.0 int lo1 ip add 192.168.5.1 255.255.255.0 router eigrp 1 no auto network 24.0.0.0 0.0.0.255 network 34.0.0.0 0.0.0.255 network 192.168.5.0 0.0.0.255
所有都設定好後, 在PC1先測試一下traceroute 192.168.5.1
在圖中可以看到是經過R3到達目的地
測試1, 更改為經由R2
ip access-list extended PC1toServer1 permit ip host 10.0.0.10 host 192.168.5.1 route-map PC1toServer1 permit 10 match ip address PC1toServer1 set ip next-hop 12.0.0.2 int e0/2 ip policy route-map PC1toServer1
測試2, 增加多一個policy
ip access-list extended newPC1toServer1 permit ip host 10.0.0.10 host 192.168.5.1 route-map PC1toServer1 permit 20 match ip address newPC1toServer1 set ip next-hop 12.0.0.22
因為route-map PC1toServer1 permit 10已經中了, 所以沒有執行20
測試3, 刪除10的指令, 看看會怎樣
route-map PC1toServer1 permit 10 no set ip next-hop 12.0.0.2