要求:PC1的流量通过R1访问R4的100.100.100.100,PC2的流量通过R2访问R4的100.100.100.100,用ospf、单臂路由和策略路由来实现。
R1配置如下:
interface GigabitEthernet0/0/0
ip address 10.10.10.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 30.30.30.1 255.255.255.0
#
ospf 1
import-route static
area 0.0.0.0
network 30.30.30.1 0.0.0.0
#
ip route-static 172.16.0.0 255.255.0.0 10.10.10.1
R2配置如下:
#
interface GigabitEthernet0/0/0
ip address 20.20.20.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 40.40.40.1 255.255.255.0
#
ospf 1
import-route static
area 0.0.0.0
network 40.40.40.1 0.0.0.0
#
ip route-static 172.16.0.0 255.255.0.0 20.20.20.1
#
R3配置如下:
acl number 3000
rule 5 permit ip source 172.16.1.0 0.0.0.255
acl number 3001
rule 5 permit ip source 172.16.2.0 0.0.0.255
acl number 3002
rule 5 permit ip source 172.16.1.0 0.0.0.255 destination 172.16.1.1 0
rule 10 permit ip source 172.16.2.0 0.0.0.255 destination 172.16.2.1 0 //创建允许策略
#
traffic classifier c2 //创建流分类
if-match acl 3002 //调用策略
traffic classifier c0
if-match acl 3000
traffic classifier c1
if-match acl 3001
#
traffic behavior b2 //配置响应动作
permit
traffic behavior b0
redirect ip-nexthop 10.10.10.2
traffic behavior b1
redirect ip-nexthop 20.20.20.2
#
traffic policy p1 //把分类对应行为关联起来
classifier c0 behavior b0
classifier c1 behavior b1
classifier c2 behavior b2
#
interface GigabitEthernet0/0/0
ip address 10.10.10.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 20.20.20.1 255.255.255.0
#
interface GigabitEthernet0/0/2.1
dot1q termination vid 10 //配置单臂路由允许vlan10通过
ip address 172.16.1.1 255.255.255.0
traffic-policy p1 inbound //接口入方向调入流策略
arp broadcast enable
#
interface GigabitEthernet0/0/2.2
dot1q termination vid 20 //配置单臂路由允许vlan20通过
ip address 172.16.2.1 255.255.255.0
traffic-policy p1 inbound //接口入方向调入流策略
arp broadcast enable
#
ip route-static 0.0.0.0 0.0.0.0 10.10.10.2
ip route-static 0.0.0.0 0.0.0.0 20.20.20.2 //配置通往R4的静态路由
#
S1配置:
#
vlan batch 10 20
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan all
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 10
#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 20
#
PC1配置如下:
PC2配置如下
验证结果: