实验介绍

了解 OSPF 通告缺省路由的方式与原理。

实验目的

R1与R2作为企业边界出口设备,构成双出口冗余以实现负载分担。企业内部部署并运行OSPF路由协议,使Client A与Client B能正常访问 Internet路由器的100.1.1.0网络。为减少路由表容量,在 R1与 R2上配置缺省路由,从而在提供连通性的同时保证网络的高可用性。

拓扑结构

接口信息

路由器

接口

IP Address/Mask

SW1

GE 0/0/1

10.1.1.11/24

GE 0/0/2

10.1.1.12/24

GE 0/0/3

10.1.1.22/24

SW2

GE 0/0/1

10.1.1.21/24

GE 0/0/2

20.1.1.2/24

GE 0/0/3

30.1.1.2/24

SW3

GE 0/0/1

20.1.1.3/24

GE 0/0/2

40.1.1.3/24

GE 0/0/10

192.168.1.3/24

SW4

GE 0/0/1

40.1.1.4/24

GE 0/0/2

30.1.1.4/24

GE 0/0/20

172.16.1.4/24

R1

GE 0/0/0

10.1.1.1/24

GE 0/0/1

202.16.0.1/30

R2

GE 0/0/0

10.1.1.2/24

GE 0/0/1

69.151.202.2/30

Internet

GE 0/0/1

202.16.0.2/30

GE 0/0/2

69.151.202.2/30

LoopBack 0

100.1.1.2/24

实验步骤

步骤一:配置接口IP

SW1为二层交换机,无需额外配置,正常开机即可。

以SW2为例,模拟器的三层交换机无法直接配置接口IP,需要使用VLAN子接口曲线救国。

[SW2-Vlanif1]dis th
#
interface Vlanif1
 ip address 10.1.1.2 255.255.255.0
#
return
[SW2-Vlanif2]dis th
#
interface Vlanif2
 ip address 20.1.1.2 255.255.255.0
#
return
[SW2-Vlanif3]dis th
#
interface Vlanif3
 ip address 30.1.1.2 255.255.255.0
#
return

将端口加进对应VLAN。

VLAN 1默认放行。

[SW2-GigabitEthernet0/0/1]dis th
#
interface GigabitEthernet0/0/1
 port link-type access
#
return
[SW2-GigabitEthernet0/0/2]dis th
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 2
#
return
[SW2-GigabitEthernet0/0/3]di th
#
interface GigabitEthernet0/0/3
 port link-type access
 port default vlan 3
#
return

其余类似,路由器直接在接口配置IP即可。

步骤二:配置NAT

以R1为例。

匹配内部源网段。

[R1-acl-basic-2001]dis th
[V200R003C00]
#
acl number 2001
 rule 5 permit source 192.168.1.0 0.0.0.255
 rule 10 permit source 172.16.1.0 0.0.0.255
#
return
[R1-GigabitEthernet0/0/1]dis th
[V200R003C00]
#
interface GigabitEthernet0/0/1
 ip address 202.106.0.1 255.255.255.252
 nat outbound 2001
#
return

配置缺省路由,指定去往任意网段的下一跳接口IP地址。

[R1]ip route-static 0.0.0.0 0 202.106.0.2

步骤三:配置OSPF

R1、R2、SW2、SW3和SW4均需要配置OSPF。

仅R1和R2需要配置OSPF通告缺省路由。

以R1和SW2为例。

[R1-ospf-1]di th
[V200R003C00]
#
ospf 1
 default-route-advertise always cost 10 type 1
 area 0.0.0.0
  network 10.1.1.0 0.0.0.255
#
return
[SW2-ospf-1]dis th
#
ospf 1
 area 0.0.0.0
  network 10.1.1.0 0.0.0.255
  network 20.1.1.0 0.0.0.255
  network 30.1.1.0 0.0.0.255
#
return

通过查看SW2的OSPF路由表项可知,其学习到2条完全等价的缺省路由【O_ASE】

[SW2]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 4        Routes : 6

OSPF routing table status : <Active>
         Destinations : 4        Routes : 6

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_ASE   150  11          D   10.1.1.1        Vlanif1
                    O_ASE   150  11          D   10.1.1.2        Vlanif1
       40.1.1.0/24  OSPF    10   2           D   20.1.1.3        Vlanif2
                    OSPF    10   2           D   30.1.1.4        Vlanif3
     172.16.1.0/24  OSPF    10   2           D   30.1.1.4        Vlanif3
    192.168.1.0/24  OSPF    10   2           D   20.1.1.3        Vlanif2

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0