OSPF基本功能配置

配置思路

采用如下的思路配置OSPF基本功能:

  1. 在各交换机的VLANIF接口上配置IP地址并配置各接口所属VLAN,实现网段内的互通。

  2. 在各交换机上配置OSPF基本功能,并且以SwitchA为ABR将OSPF网络划分为Area0和Area1两个区域,实现后续以SwitchA和SwitchB所在区域为骨干区域来扩展整个OSPF网络。

操作步骤
  1. 配置各接口所属的VLAN

    # 配置SwitchA。SwitchB和SwitchC的配置与SwitchA类似。

    <HUAWEI> system-view
    [HUAWEI] sysname SwitchA
    [SwitchA] vlan batch 10 20
    [SwitchA] interface gigabitethernet 1/0/1
    [SwitchA-GigabitEthernet1/0/1] port link-type trunk
    [SwitchA-GigabitEthernet1/0/1] port trunk allow-pass vlan 10
    [SwitchA-GigabitEthernet1/0/1] quit
    [SwitchA] interface gigabitethernet 1/0/2
    [SwitchA-GigabitEthernet1/0/2] port link-type trunk
    [SwitchA-GigabitEthernet1/0/2] port trunk allow-pass vlan 20
    [SwitchA-GigabitEthernet1/0/2] quit

  2. 配置各VLANIF接口的IP地址

    # 配置SwitchA。SwitchB和SwitchC的配置与SwitchA类似。

    [SwitchA] interface vlanif 10
    [SwitchA-Vlanif10] ip address 192.168.0.1 24
    [SwitchA-Vlanif10] quit
    [SwitchA] interface vlanif 20
    [SwitchA-Vlanif20] ip address 192.168.1.1 24
    [SwitchA-Vlanif20] quit

  3. 配置OSPF基本功能

    # 配置SwitchA。

    [SwitchA] ospf 1 router-id 10.1.1.1   //创建进程号为1,Router ID为10.1.1.1的OSPF进程
    [SwitchA-ospf-1] area 0   //创建area 0区域并进入area 0视图
    [SwitchA-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255   //配置area 0所包含的网段
    [SwitchA-ospf-1-area-0.0.0.0] quit
    [SwitchA-ospf-1] area 1   //创建area 1区域并进入area 1视图
    [SwitchA-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255   //配置area 1所包含的网段
    [SwitchA-ospf-1-area-0.0.0.1] return

    # 配置SwitchB。

    [SwitchB] ospf 1 router-id 10.2.2.2
    [SwitchB-ospf-1] area 0
    [SwitchB-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255
    [SwitchB-ospf-1-area-0.0.0.0] return

    # 配置SwitchC。

    [SwitchC] ospf 1 router-id 10.3.3.3
    [SwitchC-ospf-1] area 1
    [SwitchC-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255
    [SwitchC-ospf-1-area-0.0.0.1] return

  4. 验证配置结果

    # 查看SwitchA的OSPF邻居。

    <SwitchA> display ospf peer
    
              OSPF Process 1 with Router ID 10.1.1.1
                      Neighbors
    
     Area 0.0.0.0 interface 192.168.0.1(Vlanif10)'s neighbors
    Router ID: 10.2.2.2      Address: 192.168.0.2
       State: Full  Mode:Nbr is  Master  Priority: 1
       DR: 192.168.0.2  BDR: 192.168.0.1   MTU: 0
       Dead timer due in 36  sec
       Retrans timer interval: 5
       Neighbor is up for 00:15:04
       Authentication Sequence: [ 0 ]
    
                      Neighbors
    
     Area 0.0.0.1 interface 192.168.1.1(Vlanif20)'s neighbors
    Router ID: 10.3.3.3       Address: 192.168.1.2
       State: Full  Mode:Nbr is  Master  Priority: 1
       DR: 192.168.1.2  BDR: 192.168.1.1   MTU: 0
       Dead timer due in 39  sec
       Retrans timer interval: 5
       Neighbor is up for 00:07:32
       Authentication Sequence: [ 0 ]

    # 查看SwitchC的OSPF路由信息。

    <SwitchC> display ospf routing
    
              OSPF Process 1 with Router ID 10.3.3.3
                       Routing Tables
    
     Routing for Network
     Destination      Cost  Type         NextHop         AdvRouter       Area
     192.168.1.0/24    1    Transit      192.168.1.2     10.3.3.3        0.0.0.1
     192.168.0.0/24    2    Inter-area   192.168.1.1     10.1.1.1        0.0.0.1
    
     Total Nets: 2
     Intra Area: 1  Inter Area: 1  ASE: 0  NSSA: 0

    由以上回显可以看出,SwitchC有到192.168.0.0/24网段的路由,且此路由被标识为区域间路由。

    # 查看SwitchB的路由表,并使用Ping测试SwitchB和SwitchC的连通性。

    <SwitchB> display ospf routing
    
              OSPF Process 1 with Router ID 10.2.2.2
                       Routing Tables
    
     Routing for Network
     Destination        Cost  Type       NextHop      AdvRouter       Area
     192.168.0.0/24     1     Transit    192.168.0.2  10.2.2.2        0.0.0.0
     192.168.1.0/24     2     Inter-area 192.168.0.1  10.1.1.1        0.0.0.0
    
     Total Nets: 2
     Intra Area: 1  Inter Area: 1  ASE: 0  NSSA: 0

    由以上回显可以看出,SwitchB有到192.168.1.0/24网段的路由,且此路由被标识为区域间路由。

    # 在SwitchB上使用Ping测试SwitchB和SwitchC之间的连通性。

    <SwitchB> ping 192.168.1.2
      PING 192.168.1.2: 56  data bytes, press CTRL_C to break
        Reply from 192.168.1.2: bytes=56 Sequence=1 ttl=254 time=62 ms
        Reply from 192.168.1.2: bytes=56 Sequence=2 ttl=254 time=16 ms
        Reply from 192.168.1.2: bytes=56 Sequence=3 ttl=254 time=62 ms
        Reply from 192.168.1.2: bytes=56 Sequence=4 ttl=254 time=94 ms
        Reply from 192.168.1.2: bytes=56 Sequence=5 ttl=254 time=63 ms
    
      --- 192.168.1.2 ping statistics ---
        5 packet(s) transmitted
        5 packet(s) received
        0.00% packet loss
        round-trip min/avg/max = 16/59/94 ms

配置文件

  • SwitchA的配置文件

    #
    sysname SwitchA
    #
    vlan batch 10 20
    #
    interface Vlanif10
     ip address 192.168.0.1 255.255.255.0
    #
    interface Vlanif20
     ip address 192.168.1.1 255.255.255.0
    #
    interface GigabitEthernet1/0/1
     port link-type trunk
     port trunk allow-pass vlan 10
    #
    interface GigabitEthernet1/0/2
     port link-type trunk
     port trunk allow-pass vlan 20
    #
    ospf 1 router-id 10.1.1.1
     area 0.0.0.0
      network 192.168.0.0 0.0.0.255
     area 0.0.0.1
      network 192.168.1.0 0.0.0.255
    #
    return
  • SwitchB的配置文件

    #
    sysname SwitchB
    #
    vlan batch 10
    #
    interface Vlanif10
     ip address 192.168.0.2 255.255.255.0
    #
    interface GigabitEthernet1/0/1
     port link-type trunk
     port trunk allow-pass vlan 10
    #
    ospf 1 router-id 10.2.2.2
     area 0.0.0.0
      network 192.168.0.0 0.0.0.255
    #
    return
  • SwitchC的配置文件

    #
    sysname SwitchC
    #
    vlan batch 20
    #
    interface Vlanif20
     ip address 192.168.1.2 255.255.255.0
    #
    interface GigabitEthernet1/0/1
     port link-type trunk
     port trunk allow-pass vlan 20
    #
    ospf 1 router-id 10.3.3.3
     area 0.0.0.1
      network 192.168.1.0 0.0.0.255
    #
    return

配置OSPF的Stub区域示例

Stub区域简介

Stub区域的ABR不传播它们接收到的自治系统外部路由,在Stub区域中路由器的路由表规模以及路由信息传递的数量都会大大减少。为保证到自治系统外的路由依旧可达,该区域的ABR将生成一条缺省路由,并发布给Stub区域中的其他非ABR路由器。

例如H公司有一台设备通过单链路与骨干区域连接,这台设备的性能较低,路由表规格也比较小。对于这台设备来说,这个区域需要访问其他区域,或者是OSPF域外的网段的时候,它的路由的下一跳都是这个单链路所对应的下一跳核心设备的IP。所以这个区域没有必要学习到大量的OSPF外部路由,此时就可以考虑将该区域配置成Stub区域。这样就能减小这个区域的路由表规模,降低对设备性能资源的消耗。

配置注意事项

  • 骨干区域不能配置成Stub区域。
  • Stub区域内不能存在ASBR,即自治系统外部的路由不能在本区域内传播。
  • 虚连接不能穿过Stub区域。
  • 如果要将一个区域配置成Stub区域,则该区域中的所有路由器都要配置Stub区域属性。
  • 如果要将一个区域配置成Totally Stub区域,该区域中的所有路由器必须配置stub命令,而其中该区域的ABR路由器需要配置stub no-summary命令。
  • stub no-summary命令仅能用于ABR上,用于禁止ABR向Stub区域内发布3类LSA。在ABR上配置该命令以后该区域成为Totally Stub区域,这时区域内的路由表项进一步减少,只有区域内路由和ABR通告的一条缺省路由。
  • 本举例适用于S12700, S12700E交换机的所有版本所有产品。
  • 15
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数字化信息化智能化解决方案

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值