实验一
会配置OSPF下发默认路由,一般在出口设备配置下发默认路由,出口连接运营商,通过下发默认路由将数据引导至出口设备,再转交给运营商
拓扑
AR2模拟运营商
配置
PC1配置
LSW1配置
<Huawei>sys
[Huawei]sys LSW1
[LSW1]vlan batch 10 20
[LSW1]inte gi 0/0/2
[LSW1-GigabitEthernet0/0/2]port link-type access
[LSW1-GigabitEthernet0/0/2]port default vlan 10
[LSW1-GigabitEthernet0/0/2]inte gi 0/0/1
[LSW1-GigabitEthernet0/0/1]port link-type access
[LSW1-GigabitEthernet0/0/1]port default vlan 20
[LSW1-GigabitEthernet0/0/1]inte vlan 10
[LSW1-Vlanif10]ip addr 192.168.1.254 255.255.255.0
[LSW1-Vlanif10]inte vlan 20
[LSW1-Vlanif20]ip address 11.1.1.1 255.255.255.0
[LSW1-Vlanif20]q
[LSW1]ospf 1 router-id 2.2.2.2
[LSW1-ospf-1]area 0
[LSW1-ospf-1-area-0.0.0.0]network 11.1.1.1 0.0.0.0
[LSW1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
AR1配置
<Huawei>sys
[Huawei]sys AR1
[AR1]inte gi 0/0/1
[AR1-GigabitEthernet0/0/1]ip addr 11.1.1.2 255.255.255.0
[AR1-GigabitEthernet0/0/1]inte gi 0/0/0
[AR1-GigabitEthernet0/0/0]ip addr 12.1.1.1 255.255.255.0
[AR1-GigabitEthernet0/0/0]inte lo 1
[AR1-LoopBack1]ip address 1.1.1.1 255.255.255.255
[AR1-LoopBack1]q
[AR1]ospf 1 router-id 1.1.1.1
[AR1-ospf-1]default-route-advertise //下发默认路由,可选添加参数always,不添加always的时候只有当本设备有默认路由下会下发,没有则不发,加上always参数意思为不管本设备有无缺省路由都下发
[AR1-ospf-1]area 0
[AR1-ospf-1-area-0.0.0.0]network 11.1.1.2 0.0.0.0
[AR1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[AR1-ospf-1]q
[AR1]ip route-static 0.0.0.0 0 12.1.1.2
AR2配置
<Huawei>sys
[Huawei]sys AR2
[AR2]inte lo 1
[AR2-LoopBack1]ip addr 8.8.8.8 255.255.255.255
[AR2-LoopBack1]inte gi 0/0/0
[AR2-GigabitEthernet0/0/0]ip addr 12.1.1.2 255.255.255.0
[AR2]ip route-static 192.168.1.0 255.255.255.0 12.1.1.1 //现网中没有此步,运营商个内网回复使用的是nat技术,为了实验的完整性配置静态回程路由
通信验证
查看LSW1的路由表,可以看到OSPF下发的默认路由
[LSW1]dis ip routing-table
Route Flags: R - relay, D - download to fib
\------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 8 Routes : 8
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 O_ASE 150 1 D 11.1.1.2 Vlanif20 //由AR1下发的默认路由
1.1.1.1/32 OSPF 10 1 D 11.1.1.2 Vlanif20
11.1.1.0/24 Direct 0 0 D 11.1.1.1 Vlanif20
11.1.1.1/32 Direct 0 0 D 127.0.0.1 Vlanif20
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Direct 0 0 D 192.168.1.254 Vlanif10
192.168.1.254/32 Direct 0 0 D 127.0.0.1 Vlanif10
PC1 ping 模拟运营商(AR2)
通信过程讲解
标签:AR1,LSW1,14,0.0,GigabitEthernet0,OSPF,路由,1.1 From: https://www.cnblogs.com/Metkey/p/17717079.html在现网环境中,出口路由器不可能宣告公网接口,因此,LSW1无法学习到去往公网的路由,因此需要出口路由器下发默认路由,如需访问公网就把流量引导至出口路由器,再由出口转发至公网,实现通信