OSPF配置知识总结2(单区域)

OSPF配置知识总结2

静态路由有静态路由的好处,但也有弊端,牵一发动全身,在一个路由路径上,只要变一个,其他所有的路由器上的静态路由都要跟着改变。

用动态路由OSPF很简单就能解决这个问题。如下:

思路:

1.搭建eNSP模型

2.RouterID规划

3.基本配置

4.OSPF配置

5.连通测试

 

1.搭建eNSP模型

 

2.RouterID规划

route-id是路由器的唯一标识。格式和ip地址相似,也是点分十进制。如255.255.255.255 或 0.0.0.0 (感谢作者的总结,不知名字,谢谢!)
route-id的来源有三种:

a、使用命令直接配置
b、如果没有命令配置,使用所有lookback口中最小的(有的厂商是最大的)ip作为route-id。
c、如果lookback口没有配置ip,使用所有物理接口中最小的(有的厂商是最大的)ip作为route-id

关于route-id的规划需要注意的是:

a、如果使用接口IP作为route-id,当IP改变以后,该路由器的route-id并不会自动改变。route-id只有在ospf进程重启是才会更改。
b、建议在启动OSPF进程前先使用命令配置route-id

规划建议:

RouterID规划(我个人想的方法)
X . X . X . X
区域码 . 工厂码 . 第几台 . 备用码

R1-ID:  0.1.1.0
R2-ID:    0.1.2.0
R3-ID:    0.1.3.0
R4-ID:    0.1.4.0

3.基本配置

3.1.应用客户端配置

3.2.路由器接口IP地址配置

     配置各接口的IP地址

R1

#
interface GigabitEthernet0/0/0
ip address 192.168.1.254 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 192.168.12.1 255.255.255.0

R2

#
interface GigabitEthernet0/0/1
ip address 192.168.12.2 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 192.168.23.2 255.255.255.0

R3

#
interface GigabitEthernet0/0/1
ip address 192.168.34.3 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 192.168.23.3 255.255.255.0

R4

#
interface GigabitEthernet0/0/0
ip address 192.168.2.254 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 192.168.34.4 255.255.255.0

 

 

4.OSPF配置

R1

#
ospf 1 router-id 0.1.1.0
area 0.0.0.0
network 192.168.1.0 0.0.0.255
network 192.168.12.0 0.0.0.255

reset ospf process     //重启OSPF服务,使router-id发挥作用

R2

#
ospf 1 router-id 0.1.2.0
area 0.0.0.0
network 192.168.12.0 0.0.0.255
network 192.168.23.0 0.0.0.255

reset ospf process 

R3

#
ospf 1 router-id 0.1.3.0
area 0.0.0.0
network 192.168.23.0 0.0.0.255
network 192.168.34.0 0.0.0.255

reset ospf process 

R4

#
ospf 1 router-id 0.1.4.0
area 0.0.0.0
network 192.168.2.0 0.0.0.255
network 192.168.34.0 0.0.0.255

reset ospf process 

 

5.连通测试

5.1.查询OSPF的邻接表

R1

[R1]dis ospf peer brief

OSPF Process 1 with Router ID 0.1.1.0  //因为是提前规划的,所以非常清楚是0区,1厂,第一台路由器
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/1 0.1.2.0 Full     //本路由器的邻居为0区,1厂,第二台路由器
----------------------------------------------------------------------------

R2

[R2]dis ospf peer brief

OSPF Process 1 with Router ID 0.1.2.0
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/1     0.1.1.0 Full
0.0.0.0 GigabitEthernet0/0/2     0.1.3.0 Full
----------------------------------------------------------------------------

R3

[R3]dis ospf peer brief

OSPF Process 1 with Router ID 0.1.3.0
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/1  0.1.4.0 Full
0.0.0.0 GigabitEthernet0/0/2 0.1.2.0 Full
----------------------------------------------------------------------------

R4

[R4]dis ospf peer brief

OSPF Process 1 with Router ID 0.1.4.0
Peer Statistic Information
----------------------------------------------------------------------------
Area Id   Interface        Neighbor id   State
0.0.0.0   GigabitEthernet0/0/1     0.1.3.0     Full
----------------------------------------------------------------------------

 

5.2.查询OSPF的路由表

       从OSPF协议生成的路由表可以看出,与静态路由建立的条目一致,换言之目的一样,只是一个是自动,一个手动。简单的结构看不出差别,结构复杂了,中途网络结构调整,OSPF的优势便显而易见。因为每个路由器只需配置网络接口地址,在OSPF进程中配置邻接关联网段即可,其他就交给OSPF服务与协议去处理。试想网络结构节点很多,其中有一台路由器坏了,将其更换,如果用静态路由,逐条配置的场景。当然,OSPF的运行肯定要消耗带宽和路由器运算资源,跟人和网络的稳定性比只能牺牲路由器的资源了。

[R1]dis ip routing-table protocol ospf   //这个路由表是由OSPF服务根据协议自动生成
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 3 Routes : 3

OSPF routing table status : <Active>
Destinations : 3 Routes : 3

Destination/Mask    Proto    Pre   Cost   Flags       NextHop        Interface

192.168.2.0/24       OSPF    10    4      D     192.168.12.2    GigabitEthernet0/0/1
192.168.23.0/24     OSPF    10    2      D     192.168.12.2    GigabitEthernet0/0/1
192.168.34.0/24     OSPF    10    3      D     192.168.12.2    GigabitEthernet0/0/1

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

 

[R2]dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 3 Routes : 3

OSPF routing table status : <Active>
Destinations : 3 Routes : 3

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    3      D    192.168.23.3    GigabitEthernet0/0/2
192.168.34.0/24    OSPF    10    2      D    192.168.23.3    GigabitEthernet0/0/2

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

 

[R3]dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 3 Routes : 3

OSPF routing table status : <Active>
Destinations : 3 Routes : 3

Destination/Mask    Proto      Pre   Cost   Flags   NextHop      Interface

192.168.1.0/24        OSPF    10      3     D       192.168.23.2    GigabitEthernet0/0/2
192.168.2.0/24        OSPF    10      2     D       192.168.34.4    GigabitEthernet0/0/1
192.168.12.0/24      OSPF    10      2      D      192.168.23.2    GigabitEthernet0/0/2

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

 

[R4]dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 3 Routes : 3

OSPF routing table status : <Active>
Destinations : 3 Routes : 3

Destination/Mask    Proto    Pre   Cost   Flags   NextHop       Interface

192.168.1.0/24       OSPF    10    4      D      192.168.34.3    GigabitEthernet0/0/1
192.168.12.0/24     OSPF    10    3      D      192.168.34.3    GigabitEthernet0/0/1
192.168.23.0/24     OSPF    10    2      D      192.168.34.3    GigabitEthernet0/0/1

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

 

5.3.两客户端连通测试

PC>ipconfig

Link local IPv6 address...........: fe80::5689:98ff:fe1a:38d
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.1.2
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.1.254
Physical address..................: 54-89-98-1A-03-8D
DNS server........................:

PC>ping 192.168.2.2

Ping 192.168.2.2: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.2.2: bytes=32 seq=2 ttl=124 time=32 ms
From 192.168.2.2: bytes=32 seq=3 ttl=124 time=31 ms
From 192.168.2.2: bytes=32 seq=4 ttl=124 time=31 ms
From 192.168.2.2: bytes=32 seq=5 ttl=124 time=31 ms

--- 192.168.2.2 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 0/31/32 ms

 

posted on 2022-08-02 00:11  人生不开窍  阅读(638)  评论(0编辑  收藏  举报

导航