Top

NTD TCNE DAY04

  1. 案例1:OSPF路由选路
  2. 案例2:配置 OSPF 特殊区域
  3. 案例3:配置NSSA区域
  4. 案例4:配置OSPF汇总
  5. 案例5:OSPF虚链路配置

1 案例1:OSPF路由选路

1.1 问题

  1. 如图配置 VLAN、IP和OSPF
  2. R1/R2配置静态路由,访问PC-2
  3. 确保 PC-1与PC-2可以互相访问
  4. PC-1的网关配置在 SW1 上
  5. R1是主出口设备,R2是备份出口设备
  6. 要求数据转发是最优路径

    1.2 方案

    搭建实验环境,如图-1所示。
    TCNE DAY04 - 图1
    图-1

    1.3 步骤

    实现此案例需要按照如下步骤进行。
    1)配置终端设备
    PC1:
    192.168.6.1
    255.255.255.0
    192.168.6.254
    PC2:
    192.168.2.1
    255.255.255.0
    192.168.2.254

2)配置交换机
undo terminal monitor
system-view
[Huawei]sysname SW1
[SW1]vlan batch 6 10 20 //批量创建 VLAN 信息

[SW1]interface GigabitEthernet 0/0/1 //连接 R1 的接口
[SW1-GigabitEthernet0/0/1]port link-type access
[SW1-GigabitEthernet0/0/1]port default vlan 10
[SW1-GigabitEthernet0/0/1]quit

[SW1]interface GigabitEthernet 0/0/2 //连接 R2 的接口
[SW1-GigabitEthernet0/0/3]port link-type access
[SW1-GigabitEthernet0/0/3]port default vlan 20
[SW1-GigabitEthernet0/0/3]quit

[SW1]interface GigabitEthernet 0/0/3 //连接 PC1 的接口
[SW1-GigabitEthernet0/0/3]port link-type access
[SW1-GigabitEthernet0/0/3]port default vlan 6
[SW1-GigabitEthernet0/0/3]quit

[SW1]interface Vlanif 6 //PC1的网关接口
[SW1-Vlanif6]ip address 192.168.6.254 24
[SW1-Vlanif6]quit

[SW1]interface Vlanif 10 //连接R1所用的IP接口
[SW1-Vlanif10]ip address 192.168.10.1 24
[SW1-Vlanif10]quit

[SW1]interface Vlanif 20 //连接R2所用的IP接口
[SW1-Vlanif20]ip address 192.168.20.1 24
[SW1-Vlanif20]quit

3)配置路由器
undo terminal monitor
system-view
[Huawei]sysname R1

[R1]interface gi0/0/0 //连接SW1所用的接口
[R1-GigabitEthernet0/0/0]ip address 192.168.10.2 24
[R1-GigabitEthernet0/0/0]quit

[R1]interface gi0/0/1 //连接R3所用的接口
[R1-GigabitEthernet0/0/1]ip address 192.168.13.1 24
[R1-GigabitEthernet0/0/1]quit

[R1]ip route-static 0.0.0.0 0 192.168.13.3 //去往PC2的默认路由

undo terminal monitor
system-view
[Huawei]sysname R2
[R2]interface gi0/0/0 //连接SW1所用的接口
[R2-GigabitEthernet0/0/0]ip address 192.168.20.2 24
[R2-GigabitEthernet0/0/0]quit

[R2]interface gi0/0/2 //连接 R3 所用的接口
[R2-GigabitEthernet0/0/2]ip address 192.168.23.2 24
[R2-GigabitEthernet0/0/2]quit

[R2]ip route-static 0.0.0.0 0 192.168.23.3 //去往PC2的默认路由

undo terminal monitor
system-view
[Huawei]sysname R3
[R3]interface GigabitEthernet 0/0/1 //连接 R1所用的接口
[R3-GigabitEthernet0/0/1]ip address 192.168.13.3 24
[R3-GigabitEthernet0/0/1]quit

[R3]interface GigabitEthernet 0/0/2 //连接 R2所用的接口
[R3-GigabitEthernet0/0/2]ip address 192.168.23.3 24
[R3-GigabitEthernet0/0/2]quit

[R3]interface gi0/0/0 //连接 PC2所用的接口
[R3-GigabitEthernet0/0/0]ip address 192.168.2.254 24
[R3-GigabitEthernet0/0/0]quit

4)配置基本的OSPF
[SW1]ospf 1 router-id 6.6.6.6 //启用OSPF协议,配置router-id为6.6.6.6
[SW1-ospf-1]area 0
[SW1-ospf-1-area-0.0.0.0]network 192.168.6.0 0.0.0.255
[SW1-ospf-1-area-0.0.0.0]network 192.168.10.0 0.0.0.255
[SW1-ospf-1-area-0.0.0.0]network 192.168.20.0 0.0.0.255
[SW1-ospf-1-area-0.0.0.0]quit

[R1]ospf 1 router-id 1.1.1.1 //启用OSPF协议,配置router-id为1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 192.168.10.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]quit

[R2]ospf 1 router-id 2.2.2.2 //启用OSPF协议,配置router-id为2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 192.168.20.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]quit

5)配置OSPF默认路由
[R1]ospf 1
[R1-ospf-1]default-route-advertise //OSPF协议产生默认路由

[R2]ospf 1
[R2-ospf-1]default-route-advertise cost 2 //OSPF协议产生默认路由,修改为cost为2

6)配置浮动静态路由
[R3]ip route-static 192.168.6.0 24 192.168.13.1 //配置去往PC1的主路径
[R3]ip route-static 192.168.6.0 24 192.168.23.2 preference 100 //配置去往PC1的备份路径

7)测试 PC1和 PC2 之间的连通性
PC1>ping 192.168.2.1 //在PC1 ping PC2 ,可以互通
Ping 192.168.2.1: 32 data bytes, Press Ctrl_C to break
From 192.168.2.1: bytes=32 seq=1 ttl=125 time=47 ms
From 192.168.2.1: bytes=32 seq=2 ttl=125 time=47 ms
From 192.168.2.1: bytes=32 seq=3 ttl=125 time=32 ms
From 192.168.2.1: bytes=32 seq=4 ttl=125 time=31 ms
From 192.168.2.1: bytes=32 seq=5 ttl=125 time=47 ms
—- 192.168.2.1 ping statistics —-
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/40/47 ms

PC-2>ping 192.168.6.1 //在PC2 ping PC1 ,可以互通
Ping 192.168.6.1: 32 data bytes, Press Ctrl_C to break
From 192.168.6.1: bytes=32 seq=1 ttl=125 time=47 ms
From 192.168.6.1: bytes=32 seq=2 ttl=125 time=31 ms
From 192.168.6.1: bytes=32 seq=3 ttl=125 time=62 ms
From 192.168.6.1: bytes=32 seq=4 ttl=125 time=63 ms
From 192.168.6.1: bytes=32 seq=5 ttl=125 time=62 ms
—- 192.168.6.1 ping statistics —-
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/53/63 ms

2 案例2:配置 OSPF 特殊区域

2.1 问题

  1. 如图,配置设备 IP 地址和 OSPF 区域
  2. R6 与 R7 之间不运行 OSPF,通过静态路由互通
  3. 区域 12 没有外部路由
  4. 确保 PC-1 与 PC-3 可以互通

    2.2 方案

    搭建实验环境,如图-2所示。
    TCNE DAY04 - 图2
    图-2

    2.3 步骤

    实现此案例需要按照如下步骤进行。
    1)配置IP地址,设置OSPF区域
    undo terminal monitor
    system-view
    [Huawei]sysname R1
    [R1]interface GigabitEthernet 0/0/0
    [R1-GigabitEthernet0/0/0]ip add 192.168.12.1 24
    [R1-GigabitEthernet0/0/0]quit

[R1]interface GigabitEthernet 0/0/2
[R1-GigabitEthernet0/0/2]ip add 192.168.1.254 24
[R1-GigabitEthernet0/0/2]quit

[R1]ospf 1 router-id 1.1.1.1 //启用OSPF协议,配置router-id为1.1.1.1
[R1-ospf-1]area 12
[R1-ospf-1-area-0.0.0.12]network 192.168.12.0 0.0.0.255
[R1-ospf-1-area-0.0.0.12]network 192.168.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.12]quit

undo terminal monitor
system-view
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.12.2 24
[R2-GigabitEthernet0/0/1]quit

[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip add 192.168.23.2 24
[R2-GigabitEthernet0/0/0]quit

[R2]ospf 1 router-id 2.2.2.2 //启用OSPF协议,配置router-id为2.2.2.2
[R2-ospf-1]area 12
[R2-ospf-1-area-0.0.0.12]network 192.168.12.0 0.0.0.255
[R2-ospf-1-area-0.0.0.12]quit
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 192.168.23.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]quit

undo terminal monitor
system-view
[Huawei]sysname R3
[R3]interface GigabitEthernet 0/0/1
[R3-GigabitEthernet0/0/1]ip add 192.168.23.3 24
[R3-GigabitEthernet0/0/1]quit

[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip add 192.168.34.3 24
[R3-GigabitEthernet0/0/0]quit

[R3]ospf 1 router-id 3.3.3.3 //启用OSPF协议,配置router-id为3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 192.168.23.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 192.168.34.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]quit

undo terminal monitor
system-view
[Huawei]sysname R4
[R4]interface GigabitEthernet 0/0/1
[R4-GigabitEthernet0/0/1]ip add 192.168.34.4 24
[R4-GigabitEthernet0/0/1]quit

[R4]interface GigabitEthernet 0/0/0
[R4-GigabitEthernet0/0/0]ip add 192.168.45.4 24
[R4-GigabitEthernet0/0/0]quit

[R4]ospf 1 router-id 4.4.4.4 //启用OSPF协议,配置router-id为4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 192.168.45.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]network 192.168.34.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]quit

undo terminal monitor
system-view
[Huawei]sysname R5
[R5]interface GigabitEthernet 0/0/1
[R5-GigabitEthernet0/0/1]ip add 192.168.45.5 24
[R5-GigabitEthernet0/0/1]quit

[R5]interface GigabitEthernet 0/0/0
[R5-GigabitEthernet0/0/0]ip add 192.168.56.5 24
[R5-GigabitEthernet0/0/0]quit

[R5]ospf 1 router-id 5.5.5.5 //启用OSPF协议,配置router-id为5.5.5.5
[R5-ospf-1]area 56
[R5-ospf-1-area-0.0.0.56]network 192.168.56.0 0.0.0.255
[R5-ospf-1-area-0.0.0.56]quit
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]network 192.168.45.0 0.0.0.255
[R5-ospf-1-area-0.0.0.0]quit

undo terminal monitor
system-view
[Huawei]sysname R6
[R6]interface GigabitEthernet 0/0/0
[R6-GigabitEthernet0/0/0]ip add 192.168.67.6 24
[R6-GigabitEthernet0/0/0]quit

[R6]interface GigabitEthernet 0/0/1
[R6-GigabitEthernet0/0/1]ip add 192.168.56.6 24
[R6-GigabitEthernet0/0/1]quit

[R6]interface GigabitEthernet 0/0/2
[R6-GigabitEthernet0/0/2]ip add 192.168.2.254 24
[R6-GigabitEthernet0/0/2]quit

[R6]ospf 1 router-id 6.6.6.6 //启用OSPF协议,配置router-id为6.6.6.6
[R6-ospf-1]area 56
[R6-ospf-1-area-0.0.0.56]network 192.168.56.0 0.0.0.255
[R6-ospf-1-area-0.0.0.56]network 192.168.2.0 0.0.0.255
[R6-ospf-1-area-0.0.0.56]quit

undo terminal monitor
system-view
[Huawei]sysname R7
[R7]interface GigabitEthernet 0/0/1
[R7-GigabitEthernet0/0/0]ip add 192.168.67.7 24
[R7-GigabitEthernet0/0/0]quit

[R7]interface GigabitEthernet 0/0/2
[R7-GigabitEthernet0/0/2]ip add 192.168.3.254 24
[R7-GigabitEthernet0/0/2]quit

[R7]ip route-static 192.168.0.0 24 192.168.67.6 //配置去往其他网段的路由

2)配置 R6 与 R7 之间的互通路由,并引入 OSPF
[R6]ip route-static 192.168.3.0 24 192.168.67.7 //配置去往PC3的路由条目

[R6]ospf 1 router-id 6.6.6.6
[R6-ospf-1]import-route static //将配置的静态路由导入进OSPF协议
[R6-ospf-1]area 56
[R6-ospf-1-area-0.0.0.56]network 192.168.56.0 0.0.0.255
[R6-ospf-1-area-0.0.0.56]network 192.168.2.0 0.0.0.255
[R6-ospf-1-area-0.0.0.56]quit

3)配置区域12 为特殊区域
[R1]ospf 1
[R1-ospf-1]area 12
[R1-ospf-1-area-0.0.0.12]stub //将区域12配置为特殊区域-Stub
[R1-ospf-1-area-0.0.0.12]quit

[R2]ospf 1
[R2-ospf-1]area 12
[R2-ospf-1-area-0.0.0.12]stub //将区域12配置为特殊区域-Stub
[R2-ospf-1-area-0.0.0.12]quit

4)确保PC1/2 与 PC3之间的互通
PC1>ping 192.168.3.1 //在PC1 ping PC3,可以互通
Ping 192.168.3.1: 32 data bytes, Press Ctrl_C to break
From 192.168.3.1: bytes=32 seq=1 ttl=125 time=31 ms
From 192.168.3.1: bytes=32 seq=2 ttl=125 time=31 ms
From 192.168.3.1: bytes=32 seq=3 ttl=125 time=16 ms
From 192.168.3.1: bytes=32 seq=4 ttl=125 time=16 ms
From 192.168.3.1: bytes=32 seq=5 ttl=125 time=31 ms
—- 192.168.3.1 ping statistics —-
5 packet(s) transmitted

PC2>ping 192.168.3.1 //在PC2 ping PC3,可以互通
Ping 192.168.3.1: 32 data bytes, Press Ctrl_C to break
From 192.168.3.1: bytes=32 seq=1 ttl=125 time=31 ms
From 192.168.3.1: bytes=32 seq=2 ttl=125 time=31 ms
From 192.168.3.1: bytes=32 seq=3 ttl=125 time=16 ms
From 192.168.3.1: bytes=32 seq=4 ttl=125 time=16 ms
From 192.168.3.1: bytes=32 seq=5 ttl=125 time=31 ms
—- 192.168.3.1 ping statistics —-
5 packet(s) transmitted

3 案例3:配置NSSA区域

3.1 问题

  1. 如图配置设备IP地址和OSPF区域
  2. R4去往ISP,使用的是静态的默认路由
  3. R1去往合作公司,使用的也是静态路由,仅需要访问 PC-1 即可
  4. 区域 123 不允许出现 5类 LSA
  5. 确保 PC-1 和 Server-1 互通

    3.2 方案

    搭建实验环境,如图-3所示。
    TCNE DAY04 - 图3
    图-3

    3.3 步骤

    实现此案例需要按照如下步骤进行。
    1)配置终端设备
    PC1:
    192.168.10.1
    255.255.255.0
    192.168.10.254
    Server1:
    192.168.20.1
    255.255.255.0
    192.168.20.254

2)配置IP地址和基本OSPF
undo terminal monitor
system-view
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.12.1 24
[R1-GigabitEthernet0/0/0]quit

[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 192.168.16.1 24
[R1-GigabitEthernet0/0/1]quit

[R1]ospf 1 router-id 1.1.1.1 //启用OSPF,配置 router-id 为 1.1.1.1
[R1-ospf-1]area 123
[R1-ospf-1-area-0.0.0.123]network 192.168.12.0 0.0.0.255
[R1-ospf-1-area-0.0.0.123]quit
[R1-ospf-1]quit

undo terminal monitor
system-view
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip address 192.168.12.2 24
[R2-GigabitEthernet0/0/1]quit

[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 192.168.23.2 24
[R2-GigabitEthernet0/0/0]quit

[R2]ospf 1 router-id 2.2.2.2 //启用OSPF,配置 router-id 为 2.2.2.2
[R2-ospf-1]area 123
[R2-ospf-1-area-0.0.0.123]network 192.168.12.0 0.0.0.255
[R2-ospf-1-area-0.0.0.123]network 192.168.23.0 0.0.0.255
[R2-ospf-1-area-0.0.0.123]quit
[R2-ospf-1]quit

undo terminal monitor
system-view
[Huawei]sysname R3
[R3]interface GigabitEthernet 0/0/1
[R3-GigabitEthernet0/0/1]ip address 192.168.23.3 24
[R3-GigabitEthernet0/0/1]quit

[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip address 192.168.34.3 24
[R3-GigabitEthernet0/0/0]quit

[R3]ospf 1 router-id 3.3.3.3 //启用OSPF,配置 router-id 为 3.3.3.3
[R3-ospf-1]area 123
[R3-ospf-1-area-0.0.0.123]network 192.168.23.0 0.0.0.255
[R3-ospf-1-area-0.0.0.123]quit
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 192.168.34.0 0.0.0.255
[R3-ospf-1]quit

undo terminal monitor
system-view
[Huawei]sysname R4
[R4]interface GigabitEthernet 0/0/1
[R4-GigabitEthernet0/0/1]ip address 192.168.34.4 24
[R4-GigabitEthernet0/0/1]quit

[R4]interface GigabitEthernet 0/0/0
[R4-GigabitEthernet0/0/0]ip address 192.168.45.4 24
[R4-GigabitEthernet0/0/0]quit

[R4]ospf 1 router-id 4.4.4.4 //启用OSPF,配置 router-id 为 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 192.168.34.0 0.0.0.255
[R4-ospf-1]quit

undo terminal monitor
system-view
[Huawei]sysname R5
[R5]interface GigabitEthernet 0/0/1
[R5-GigabitEthernet0/0/1]ip address 192.168.45.5 24
[R5-GigabitEthernet0/0/1]quit

[R5]interface GigabitEthernet 0/0/2
[R5-GigabitEthernet0/0/2]ip address 192.168.20.254 24
[R5-GigabitEthernet0/0/2]quit

[R5] ip route-static 192.168.0.0 16 192.168.45.4 //配置去往其他网段的路由条目

undo terminal monitor
system-view
[Huawei]sysname R6
[R6]interface GigabitEthernet 0/0/0
[R6-GigabitEthernet0/0/1]ip address 192.168.16.6 24
[R6-GigabitEthernet0/0/1]quit

[R6]interface GigabitEthernet 0/0/2
[R6-GigabitEthernet0/0/2]ip address 192.168.10.254 24
[R6-GigabitEthernet0/0/2]quit

[R6] ip route-static 192.168.0.0 255.255.0.0 192.168.16.1 //配置去往其他网段的路由条目

3)配置区域123为 NSSA 区域
[R1]ospf 1
[R1-ospf-1]area 123
[R1-ospf-1-area-0.0.0.123]nssa //配置该区域为 NSSA 区域
[R1-ospf-1-area-0.0.0.123]quit

[R2]ospf 1
[R2-ospf-1]area 123
[R2-ospf-1-area-0.0.0.123]nssa //配置该区域为 NSSA 区域
[R2-ospf-1-area-0.0.0.123]quit

[R3]ospf 1
[R3-ospf-1]area 123
[R3-ospf-1-area-0.0.0.123]nssa //配置该区域为 NSSA 区域
[R3-ospf-1-area-0.0.0.123]quit

4)配置 R1 引入 合作公司的外部路由
[R1]ip route-static 192.168.10.0 24 192.168.16.6 //去往合作公司的路由条目

[R1]ospf 1
[R1-ospf-1]import-route static //将静态路由引入到 OSPF 协议

5)配置 R4 引入 去往外部网络的路由
[R4]ip route-static 0.0.0.0 0 192.168.45.5 //配置去往服务器的路由条目

[R4]ospf 1
[R4-ospf-1]default-route-advertise //配置OSPF产生默认路由

6)测试 PC1 和 Server-1的连通性
PC1>ping 192.168.20.1 //在 PC1 ping Server1,可以互通
Ping 192.168.20.1: 32 data bytes, Press Ctrl_C to break
From 192.168.20.1: bytes=32 seq=1 ttl=125 time=31 ms
From 192.168.20.1: bytes=32 seq=2 ttl=125 time=31 ms
From 192.168.20.1: bytes=32 seq=3 ttl=125 time=16 ms
From 192.168.20.1: bytes=32 seq=4 ttl=125 time=16 ms
From 192.168.20.1: bytes=32 seq=5 ttl=125 time=31 ms
—- 192.168.20.1 ping statistics —-
5 packet(s) transmitted

4 案例4:配置OSPF汇总

4.1 问题

  1. 如图配置设备IP地址和OSPF区域
  2. 对区域 12 进行3类LSA汇总,汇总后为 10.10.0.0/16
  3. 对区域 45 的直连链路进行5类汇总,进行精确汇总

    4.2 方案

    搭建实验环境,如图-4所示。
    TCNE DAY04 - 图4
    图-4

    4.3 步骤

    实现此案例需要按照如下步骤进行。
    1)配置IP地址和OSPF
    undo terminal monitor
    system-view
    [Huawei]sysname R1
    [R1]interface GigabitEthernet 0/0/0
    [R1-GigabitEthernet0/0/0]ip add 192.168.12.1 24
    [R1-GigabitEthernet0/0/0]quit

[R1]interface LoopBack 1
[R1-LoopBack1]ip address 10.10.1.1 24
[R1-LoopBack1]quit

[R1]interface LoopBack 2
[R1-LoopBack2]ip address 10.10.2.2 24
[R1-LoopBack2]quit

[R1]interface LoopBack 3
[R1-LoopBack3]ip address 10.10.3.3 24
[R1-LoopBack3]quit

[R1]interface LoopBack 4
[R1-LoopBack4]ip address 10.10.4.4 24
[R1-LoopBack4]quit

[R1]ospf 1 router-id 1.1.1.1 //启用OSPF协议,配置router-id 为 1.1.1.1
[R1-ospf-1]area 12
[R1-ospf-1-area-0.0.0.12]network 192.168.12.0 0.0.0.255
[R1-ospf-1-area-0.0.0.12]network 10.10.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.12]network 10.10.2.0 0.0.0.255
[R1-ospf-1-area-0.0.0.12]network 10.10.3.0 0.0.0.255
[R1-ospf-1-area-0.0.0.12]network 10.10.4.0 0.0.0.255
[R1-ospf-1-area-0.0.0.12]quit

undo terminal monitor
system-view
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.12.2 24
[R2-GigabitEthernet0/0/1]quit

[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip add 192.168.23.2 24
[R2-GigabitEthernet0/0/0]quit

[R2]ospf 1 router-id 2.2.2.2 //启用OSPF协议,配置router-id 为 2.2.2.2
[R2-ospf-1]area 12
[R2-ospf-1-area-0.0.0.12]network 192.168.12.0 0.0.0.255
[R2-ospf-1-area-0.0.0.12]quit
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 192.168.23.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]quit

undo terminal monitor
system-view
[Huawei]sysname R3
[R3]interface GigabitEthernet 0/0/1
[R3-GigabitEthernet0/0/1]ip add 192.168.23.3 24
[R3-GigabitEthernet0/0/1]quit

[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip add 192.168.34.3 24
[R3-GigabitEthernet0/0/0]quit

[R3]ospf 1 router-id 3.3.3.3 //启用OSPF协议,配置router-id 为 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 192.168.23.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 192.168.34.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]quit

undo terminal monitor
system-view
[Huawei]sysname R4
[R4]interface GigabitEthernet 0/0/1
[R4-GigabitEthernet0/0/1]ip add 192.168.34.4 24
[R4-GigabitEthernet0/0/1]quit

[R4]interface GigabitEthernet 0/0/0
[R4-GigabitEthernet0/0/0]ip add 192.168.45.4 24
[R4-GigabitEthernet0/0/0]quit

[R4]ospf 1 router-id 4.4.4.4 //启用OSPF协议,配置router-id 为 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 192.168.34.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]quit
[R4-ospf-1]area 45
[R4-ospf-1-area-0.0.0.0]network 192.168.45.0 0.0.0.255

undo terminal monitor
system-view
[Huawei]sysname R5
[R5]interface GigabitEthernet 0/0/1
[R5-GigabitEthernet0/0/1]ip add 192.168.45.5 24
[R5-GigabitEthernet0/0/1]quit

[R1]interface LoopBack 51
[R1-LoopBack1]ip address 10.50.1.1 24
[R1-LoopBack1]quit

[R1]interface LoopBack 52
[R1-LoopBack2]ip address 10.50.2.2 24
[R1-LoopBack2]quit

[R1]interface LoopBack 53
[R1-LoopBack3]ip address 10.50.3.3 24
[R1-LoopBack3]quit

[R1]interface LoopBack 54
[R1-LoopBack4]ip address 10.50.4.4 24
[R1-LoopBack4]quit

[R5]ospf 1 router-id 5.5.5.5 //启用OSPF协议,配置router-id 为 5.5.5.5
[R5-ospf-1]import-route direct //将直连链路引入到 OSPF 协议
[R5-ospf-1]area 45
[R5-ospf-1-area-0.0.0.56]network 192.168.45.0 0.0.0.255
[R5-ospf-1-area-0.0.0.56]quit

2)对区域12进行3类LSA汇总
[R2]ospf 1
[R2-ospf-1]area 12
[R2-ospf-1-area-0.0.0.12]abr-summary 10.10.0.0 255.255.0.0 //对区域12发出的3类LSA进行汇总

3)对区域45的5类LSA进行精确汇总
[R5]ospf 1
[R5-ospf-1]asbr-summary 10.50.0.0 255.255.248.0 //对R5产生的5类LSA进行汇总

5 案例5:OSPF虚链路配置

5.1 问题

  1. 如图配置IP地址和OSPF网络
  2. 公司网络扩容,新区域与骨干区域无法相连,通过配置虚链路解决问题

    5.2 方案

    搭建实验环境,如图-5所示。
    TCNE DAY04 - 图5
    图-5

    5.3 步骤

    实现此案例需要按照如下步骤进行。
    1)配置IP地址和OSPF网络
    undo terminal monitor
    system-view
    [Huawei]sysname R1
    [R1]interface GigabitEthernet 0/0/0
    [R1-GigabitEthernet0/0/0]ip add 192.168.14.1 24
    [R1-GigabitEthernet0/0/0]quit

[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.12.1 24
[R1-GigabitEthernet0/0/1]quit

[R1]ospf 1 router-id 1.1.1.1 //启用OSPF协议,配置router-id 为 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 192.168.14.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]quit
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]network 192.168.12.0 0.0.0.255
[R1-ospf-1-area-0.0.0.1]quit

undo terminal monitor
system-view
[Huawei]sysname R4
[R4]interface GigabitEthernet 0/0/0
[R4-GigabitEthernet0/0/0]ip add 192.168.14.4 24
[R4-GigabitEthernet0/0/0]quit

[R4]ospf 1 router-id 4.4.4.4 //启用OSPF协议,配置router-id 为 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 192.168.14.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]quit

undo terminal monitor
system-view
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.12.2 24
[R2-GigabitEthernet0/0/1]quit

[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip add 192.168.23.2 24
[R2-GigabitEthernet0/0/0]quit

[R2]ospf 1 router-id 2.2.2.2 //启用OSPF协议,配置router-id 为 2.2.2.2
[R2-ospf-1]area 1
[R2-ospf-1-area-0.0.0.1]network 192.168.12.0 0.0.0.255
[R2-ospf-1-area-0.0.0.1]quit
[R2-ospf-1]area 2
[R2-ospf-1-area-0.0.0.2]network 192.168.23.0 0.0.0.255
[R2-ospf-1-area-0.0.0.2]quit

2)在R1和R2之间配置虚链路
[R2]ospf 1
[R2-ospf-1]area 1
[R2-ospf-1-area-0.0.0.1]vlink-peer 1.1.1.1 //经过区域1,配置虚链路

[R1]ospf 1
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]vlink-peer 2.2.2.2 //经过区域1,配置虚链路

3)验证 R3 和 R4 可以互相 Ping 通
[R3]ping 192.168.14.4
PING 192.168.14.4: 56 data bytes, press CTRL_C to break
Reply from 192.168.14.4: bytes=56 Sequence=1 ttl=255 time=30 ms
Reply from 192.168.14.4: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 192.168.14.4: bytes=56 Sequence=3 ttl=255 time=10 ms
Reply from 192.168.14.4: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from 192.168.14.4: bytes=56 Sequence=5 ttl=255 time=10 ms

—- 192.168.14.4 ping statistics —-
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/20/30 ms

[R4]ping 192.168.23.3
PING 192.168.23.3: 56 data bytes, press CTRL_C to break
Reply from 192.168.23.3: bytes=56 Sequence=1 ttl=255 time=30 ms
Reply from 192.168.23.3: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 192.168.23.3: bytes=56 Sequence=3 ttl=255 time=10 ms
Reply from 192.168.23.3: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from 192.168.23.3: bytes=56 Sequence=5 ttl=255 time=10 ms
—- 192.168.23.3 ping statistics —-
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/20/30 ms