如图所示:
案例要求:
vlan10的主机流量走左通道
vlan20的主机流量走右通道
若路由出现故障做最佳路径
一.实现全网互通。
1.给对用接口配置ip地址。(特殊的设备)
R3:
[R3]interface g 0/0
[R3-GigabitEthernet0/0]port link-mode bridge
[R3-GigabitEthernet0/0]port link-type trunk
[R3-GigabitEthernet0/0]port trunk permit vlan all
[R3]interface g 0/1
[R3-GigabitEthernet0/1]ip address 192.168.40.1 24
[R3-GigabitEthernet0/1]undo shutdown
[R3]interface g 0/2
[R3-GigabitEthernet0/1]ip address 192.168.50.1 24
[R3-GigabitEthernet0/1]undo shutdown
[R3]interface Vlan-interface 1
[R3-Vlan-interface1]ip address 192.168.30.254 24
SW1:
[sw1]interface g 1/0/1
[sw1-GigabitEthernet1/0/1]port link-mode bridge
[sw1-GigabitEthernet1/0/1]port link-type trunk
[sw1-GigabitEthernet1/0/1]port trunk permit vlan all
[sw1]interface Vlan-interface 1
[sw1-Vlan-interface1]ip address 192.168.30.1 24
[sw1]interface Vlan-interface 10
[sw1-Vlan-interface1]ip address 192.168.10.1 24
[sw1]interface Vlan-interface 20
[sw1-Vlan-interface1]ip address 192.168.20.1 24
将vlan加入到对应的接口中。
[sw1]interface g 1/0/3
[sw1-GigabitEthernet1/0/3]port link-type access
[sw1-GigabitEthernet1/0/3]port access vlan 20
[sw1]interface g 1/0/2
[sw1-GigabitEthernet1/0/3]port link-type access
[sw1-GigabitEthernet1/0/3]port access vlan 10
2.配置OSPF区域。
R1:
[R1]ospf 10
[R1-ospf-10]area 0
[R1-ospf-10-area-0.0.0.0]network 192.168.40.0 0.0.0.255
[R1-ospf-10-area-0.0.0.0] network 192.168.60.0 0.0.0.255
R2:
[R2]ospf 10
[R2-ospf-10]area 0
[R2-ospf-10-area-0.0.0.0]network 192.168.50.0 0.0.0.255
[R2-ospf-10-area-0.0.0.0]network 192.168.60.0 0.0.0.255
[R2-ospf-10-area-0.0.0.0]network 192.168.70.0 0.0.0.255
R3:
[R2]ospf 10
[R2-ospf-10]area 0
[R2-ospf-10-area-0.0.0.0]network 192.168.40.0 0.0.0.255
[R2-ospf-10-area-0.0.0.0]network 192.168.50.0 0.0.0.255
[R2-ospf-10]import-route direct
[R2-ospf-10]default-route-advertise
3.配置默认路由。
[vlan10-pc1]ip route-static 0.0.0.0 0 0.0.0.0 GigabitEthernet0/0 192.168.10.254
[vlan20-pc1]ip route-static 0.0.0.0 0 0.0.0.0 GigabitEthernet0/0 192.168.20.254
[vlan1-pc1]ip route-static 0.0.0.0 0 0.0.0.0 GigabitEthernet0/0 192.168.70.254
[sw1]ip route-static 0.0.0.0 0 0.0.0.0 GigabitEthernet0/1 192.168.30.254
4.验证全网互通。
二.配置路由策略。
vlan10的流量:
[R3]acl advanced 3000
[R3-acl-ipv4-adv-3000]rule 0 permit ip source 192.168.10.1 0 #抓取要走左边的流量
[R3]policy-based-route 1 permit node 10
[R3-pbr-1-10]if-match acl 3000 #如果满足acl
[R3-pbr-1-10]apply next-hop 192.168.50.2 #流量走左边
[R3]policy-based-route 1 permit node 20 #不满足走最佳路径
[R3]interface g0/1
[R3-GigabitEthernet0/1]ip policy-based-route 1
vlan20的流量:
[R3]acl advanced 3001
[R3-acl-ipv4-adv-3000]rule 0 permit ip source 192.168.20.1 0
[R3]policy-based-route 2 permit node 10
[R3-pbr-1-10]if-match acl 3000 #如果满足acl
[R3-pbr-1-10]apply next-hop 192.168.40.2 #流量走右边
[R3]policy-based-route 2 permit node 20 #不满足走最佳路径
[R3]interface g0/2
[R3-GigabitEthernet0/1]ip policy-based-route 2
1. 验证vlan10的流量走的左边,验证vlan20的流量走的右边。
2.模拟故障,路由能自动切换。
1)左边故障,vlan10走右边通道。
2)右边故障,vlan20走左边通道。