OSPF单区域配置Router ID 的作用是什么?在一个网络里唯一的表示一个ospf路由器Router ID 的特点是什么?特别稳定,不重启路由器,不重启ospf是无法修改的Router ID 的选
.
OSPF单区域配置
Router ID 的作用是什么?
在一个网络里唯一的表示一个ospf路由器
Router ID 的特点是什么?
特别稳定,不重启路由器,不重启ospf是无法修改的
Router ID 的选举原则是什么?
首先是选择手动配置的是优先级最高,自动选择是最大ip地址,没有ip选择物理接口最大的接口
OSPF中network命令的含义是什么?
1.让一个网段进入到OSPF协议里面去
2.设置network连接接口才能发ospf,和接osp,路由器之间的这些网段是必须要network的,
有两个作用
1)会把这个网段放入到ospf包里面
2)可以让设备上属于这个网段的接口可以发包可以收包
案例1:配置OSPF单域
如图,配置设备 IP 地址
配置 OSPF 协议,所有网段属于区域 0
验证 各路由器的邻接表
验证 各路由器的 OSPF 路由
确保 PC-1 和 PC-2 可以互通
[R2]ospf 1 /启动ospf协议
[R2-ospf-1]area 0 /在区域0中宣告网段
[R2-ospf-1-area-0.0.0.0]network 192.168.12.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 192.168.23.0 0.0.0.255
[R2]display ospf peer brief /查看OSPF邻接表
[R2]display ip routing-table protocol ospf /查看OSPF路由表
[R1]ospf 1 router-id 1.1.1.1 /修改ospf的路由id为1.1.1.1
<R1>reset ospf proces /重启ospf程序
1 案例1:配置OSPF单域
1.1 问题
如图,配置设备 IP 地址
配置 OSPF 协议,所有网段属于区域 0
验证 各路由器的邻接表
验证 各路由器的 OSPF 路由
确保 PC-1 和 PC-2 可以互通
1.2 方案
搭建实验环境,如图-1所示。
图-1
1.3 步骤
实现此案例需要按照如下步骤进行。
1)配置终端设备 - PC1
地址:192.168.1.1 掩码:255.255.255.0 网关:192.168.1.254
2)配置终端设备 - PC2
地址:192.168.2.1 掩码:255.255.255.0 网关:192.168.2.254
3)配置网络设备 - R1
<Huawei>system-view
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/2
[R1-GigabitEthernet 0/0/2] ip address 192.168.1.254 255.255.255.0
[R1-GigabitEthernet 0/0/2] quit
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet 0/0/0] ip address 192.168.12.1 255.255.255.0
[R1-GigabitEthernet 0/0/0] quit
4)配置网络设备 - R2
<Huawei>system-view
[Huawei]sysname R2
[R2]interface gi0/0/0
[R2-GigabitEthernet 0/0/0] ip address 192.168.23.2 255.255.255.0
[R2-GigabitEthernet 0/0/0] quit
[R2]interface gi0/0/1
[R2-GigabitEthernet 0/0/1] ip address 192.168.12.2 255.255.255.0
[R2-GigabitEthernet 0/0/1] quit
5)配置网络设备 - R3
<Huawei>system-view
[Huawei]sysname R3
[R3]interface GigabitEthernet 0/0/2
[R3-GigabitEthernet 0/0/2] ip address 192.168.2.254 255.255.255.0
[R3-GigabitEthernet 0/0/2] quit
[R3]interface GigabitEthernet 0/0/1
[R3-GigabitEthernet 0/0/1] ip address 192.168.23.3 255.255.255.0
[R3-GigabitEthernet 0/0/1] quit
6)配置 OSPF 区域 0
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 192.168.12.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]quit
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 192.168.12.0 0.0.0.255
[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
[R3]ospf 1 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.2.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]quit
7)验证 OSPF 邻接表
[R1]display ospf peer brief
OSPF Process 1 with Router ID 1.1.1.1
Peer Statistic Information
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 2.2.2.2 Full
[R2]display ospf peer brief
OSPF Process 1 with Router ID 2.2.2.2
Peer Statistic Information
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/1 1.1.1.1 Full
0.0.0.0 GigabitEthernet0/0/0 3.3.3.3 Full
[R3]display ospf peer brief
OSPF Process 1 with Router ID 3.3.3.3
Peer Statistic Information
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/1 2.2.2.2 Full
8)验证 OSPF 路由表
[R1]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.2.0/24 OSPF 10 3 D 192.168.12.2 GigabitEthernet0/0/0
192.168.23.0/24 OSPF 10 2 D 192.168.12.2 GigabitEthernet0/0/0
[R2]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.1.0/24 OSPF 10 2 D 192.168.12.1 GigabitEthernet0/0/1
192.168.2.0/24 OSPF 10 2 D 192.168.23.3 GigabitEthernet0/0/0
[R3]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.1.0/24 OSPF 10 3 D 192.168.23.2 GigabitEthernet0/0/1
192.168.12.0/24 OSPF 10 2 D 192.168.23.2 GigabitEthernet0/0/1
9)测试 PC-1 与 PC-2 之间的连通性
PC-1>ping 192.168.2.1
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=31 ms
From 192.168.2.1: bytes=32 seq=2 ttl=125 time=31 ms
From 192.168.2.1: bytes=32 seq=3 ttl=125 time=16 ms
From 192.168.2.1: bytes=32 seq=4 ttl=125 time=16 ms
From 192.168.2.1: bytes=32 seq=5 ttl=125 time=31 ms
--- 192.168.2.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 16/25/31 ms
PC-2>ping 192.168.1.1
Ping 192.168.1.1: 32 data bytes, Press Ctrl_C to break
From 192.168.1.1: bytes=32 seq=1 ttl=125 time=16 ms
From 192.168.1.1: bytes=32 seq=2 ttl=125 time=31 ms
From 192.168.1.1: bytes=32 seq=3 ttl=125 time=31 ms
From 192.168.1.1: bytes=32 seq=4 ttl=125 time=32 ms
From 192.168.1.1: bytes=32 seq=5 ttl=125 time=31 ms
--- 192.168.1.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 16/28/32 ms