目录
拓扑图
配置IP
配置静态路由
配置ospf
nat
配置路由策略
流分类
流行为
流策略
应用接口
测试流量路径
拓扑图
配置IP
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 192.168.1.254 24
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.2.254 24
[R1-GigabitEthernet0/0/1]int g0/0/2
[R1-GigabitEthernet0/0/2]ip add 12.1.1.1 30
[R1-GigabitEthernet0/0/2]int g4/0/0
[R1-GigabitEthernet4/0/0]ip add 13.1.1.1 30
[R2]INT G0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.1.1.2 30
[R2-GigabitEthernet0/0/2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 100.1.1.1 30
[R2]interface LoopBack 0
[R2-LoopBack0]ip add 1.1.1.1 32
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 13.1.1.2 30
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 100.1.1.2 30
[R3-GigabitEthernet0/0/1]q
[R3]int LoopBack 0
[R3-LoopBack0]ip add 2.2.2.2 32
配置静态路由
[R1]ip route-static 0.0.0.0 0 12.1.1.2
[R1]ip route-static 0.0.0.0 0 13.1.1.2
配置ospf
[R2]ospf 1
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 12.1.1.0 0.0.0.3
[R2-ospf-1-area-0.0.0.0]network 100.1.1.0 0.0.0.3
[R2-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[R3]ospf 1
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 13.1.1.0 0.0.0.3
[R3-ospf-1-area-0.0.0.0]network 100.1.1.0 0.0.0.3
[R3-ospf-1-area-0.0.0.0]netwonetwork 2.2.2.2 0.0.0.0
nat
[R1]acl 2000
[R1-acl-basic-2000]rule 5 permit source 192.168.1.0 0.0.0.255
[R1-acl-basic-2000]rule 10 permit source 192.168.2.0 0.0.0.255
R1]interface g0/0/2
[R1-GigabitEthernet0/0/2]nat outbound 2000
[R1-GigabitEthernet0/0/2]int g4/0/0
[R1-GigabitEthernet4/0/0]nat outbound 2000
测试网络是否可达
在接口上抓包发现走的是g0/0/2口
配置路由策略
[R1]acl 2010
[R1-acl-basic-2010]rule 5 permit source 192.168.1.0 0.0.0.255
[R1-acl-basic-2010]q
[R1]acl 2020
[R1-acl-basic-2020]rule 5 permit source 192.168.2.0 0.0.0.255
流分类
[R1]traffic classifier jiaoxue
[R1-classifier-jiaoxue]if-match acl 2010
[R1-classifier-jiaoxue]q
[R1]traffic classifier bangong
[R1-classifier-bangong]if-match acl 2020
流行为
[R1]traffic behavior dianxin
[R1-behavior-dianxin]redirect ip-nexthop 12.1.1.2
[R1]traffic behavior liantong
[R1-behavior-liantong]redirect ip-nexthop 13.1.1.2
流策略
[R1]traffic policy p
[R1-trafficpolicy-p]classifier jiaoxue behavior dianxin
[R1-trafficpolicy-p]q
[R1]traffic policy q
[R1-trafficpolicy-q]classifier bangong behavior liantong
应用接口
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]traffic-policy p inbound
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]traffic-policy q inbound
测试流量路径
在pc1上面看看流量路径是怎么走的
关闭g0/0/2口,流量都走下面接口
R1]int g0/0/2
[R1-GigabitEthernet0/0/2]shutdown