OSPF unicast

本文展示了一个关于OSPF配置的实际案例,包括路由器r2和r5之间的配置细节,如接口设置、地址分配、OSPF进程配置等。此外,还展示了两台路由器之间的邻居状态及路由表信息,以及IP包调试输出,有助于理解OSPF在网络中的实际运作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

hostname r2

interface Loopback0
ip address 167.8.2.2 255.255.255.0

interface Serial0/0.2 point-to-point
ip address 167.8.25.2 255.255.255.0
ip nat outside
frame-relay interface-dlci 205

router ospf 1
router-id 255.255.255.255
network 167.8.2.2 0.0.0.0 area 0
network 167.8.25.0 0.0.0.255 area 0

ip nat outside source static 167.8.25.5 224.0.0.5


--------------------------------------------------------------------
hostname r5

interface Loopback0
ip address 167.8.5.5 255.255.255.0

interface Serial0/0
ip address 167.8.25.5 255.255.255.0
ip nat outside
encapsulation frame-relay
ip ospf network point-to-multipoint
ip ospf hello-interval 10
frame-relay map ip 167.8.25.2 502 broadcast
no frame-relay inverse-arp

router ospf 1
network 167.8.5.5 0.0.0.0 area 0
network 167.8.25.0 0.0.0.255 area 0

ip nat outside source static 167.8.25.2 224.0.0.5
-----------------------------------------------------------------------
r2#sh ip os nei

Neighbor ID Pri State Dead Time Address Interface
167.8.5.5 0 FULL/ - 00:00:36 167.8.25.5 Serial0/0.2
-----------------------------------------------------------------------
r5#sh ip os nei

Neighbor ID Pri State Dead Time Address Interface
255.255.255.255 0 FULL/ - 00:00:28 167.8.25.2 Serial0/0
------------------------------------------------------------------------
--------------------------------------------------------------
r2#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

167.8.0.0/16 is variably subnetted, 4 subnets, 2 masks
C 167.8.2.0/24 is directly connected, Loopback0
O 167.8.5.5/32 [110/65] via 167.8.25.5, 00:00:01, Serial0/0.2
O 167.8.25.5/32 [110/64] via 167.8.25.5, 00:00:01, Serial0/0.2
C 167.8.25.0/24 is directly connected, Serial0/0.2
---------------------------------------------------------------------------
r5#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

167.8.0.0/16 is variably subnetted, 3 subnets, 2 masks
C 167.8.5.0/24 is directly connected, Loopback0
O 167.8.2.2/32 [110/65] via 167.8.25.2, 00:01:20, Serial0/0
C 167.8.25.0/24 is directly connected, Serial0/0
------------------------------------------------------------------------------
r2#deb ip pac
IP packet debugging is on
r2#
*Aug 27 20:19:04.167: IP: s=167.8.25.5 (Serial0/0.2), d=167.8.25.2, len 80, rcvd 0
*Aug 27 20:19:08.943: IP: s=167.8.25.2 (local), d=224.0.0.5 (Serial0/0.2), len 80, sending broad/multicast
*Aug 27 20:19:14.167: IP: s=167.8.25.5 (Serial0/0.2), d=167.8.25.2, len 80, rcvd 0
*Aug 27 20:19:18.943: IP: s=167.8.25.2 (local), d=224.0.0.5 (Serial0/0.2), len 80, sending broad/multicast
*Aug 27 20:19:24.167: IP: s=167.8.25.5 (Serial0/0.2), d=167.8.25.2, len 80, rcvd 0
---------------------------------------------------------------------------------
r5#deb ip pac
IP packet debugging is on
r5#
*Apr 2 23:14:04.899: IP: s=167.8.25.2 (Serial0/0), d=167.8.25.5, len 80, rcvd 0
*Apr 2 23:14:10.120: IP: s=167.8.25.5 (local), d=224.0.0.5 (Serial0/0), len 80, sending broad/multicast
*Apr 2 23:14:14.900: IP: s=167.8.25.2 (Serial0/0), d=167.8.25.5, len 80, rcvd 0
*Apr 2 23:14:20.120: IP: s=167.8.25.5 (local), d=224.0.0.5 (Serial0/0), len 80, sending broad/multicast 
### OSPF 接口宣布的相关配置与概念 OSPF(Open Shortest Path First)是一种链路状态路由协议,用于在网络中传播路由信息。在 OSPF 中,接口的宣告是指路由器通过其接口向邻居通告网络拓扑信息的过程。以下是关于 OSPF 接口宣布的关键配置和概念: #### 1. 基本概念 OSPF 的接口宣布涉及将特定子网或 IP 地址范围加入到 OSPF 路由域中。这通常通过 `network` 命令完成,该命令指定哪些接口参与 OSPF 进程并属于哪个区域[^1]。 #### 2. 配置语法 在 Cisco 或类似的设备上,可以通过以下方式配置 OSPF 接口宣布: ```shell router ospf <process-id> network <ip-address> <wildcard-mask> area <area-id> ``` - `<process-id>` 是一个本地意义的标识符,用于区分不同的 OSPF 实例。 - `<ip-address>` 和 `<wildcard-mask>` 定义了一个反掩码形式的地址范围,表示要被宣告的网络。 - `<area-id>` 表示此网络所属的 OSPF 区域。 例如: ```shell router ospf 1 network 192.168.1.0 0.0.0.255 area 0 ``` 这段配置表明,所有匹配 `192.168.1.0/24` 子网的接口都将被宣告进入 OSPF 区域 0[^1]。 #### 3. 默认行为 如果未显式声明某个接口,则默认情况下它不会参与到 OSPF 协议中。管理员需要手动配置每个希望参与 OSPF 的接口及其对应的区域归属。 #### 4. IPv6 支持 (OSPFv3) 对于 OSPFv3,在 IPv6 环境下,接口的宣布更加依赖于单播地址绑定而非传统的 `network` 命令。具体来说,可以使用如下命令来启用 OSPFv3 并关联至某区域: ```shell interface GigabitEthernet0/0 ipv6 enable ipv6 router ospfv3 <process-id> area <area-id> ``` 例如: ```shell interface GigabitEthernet0/0 ipv6 enable ipv6 router ospfv3 1 area 0 ``` 这里需要注意的是,IPv6 下 OSPFv3 不再基于子网划分而是直接作用于每条链路上的所有前缀[^1]。 #### 5. 示例代码展示 下面是一个完整的 OSPF v2/v3 配置实例对比: ##### OSPFv2 Configuration Example: ```shell router ospf 1 log-adjacency-changes passive-interface default no passive-interface GigabitEthernet0/0 network 192.168.1.0 0.0.0.255 area 0 ``` ##### OSPFv3 Configuration Example: ```shell ipv6 unicast-routing router ospfv3 1 router-id 1.1.1.1 ! interface GigabitEthernet0/0 ipv6 enable ipv6 address FE80::ABCD link-local ipv6 address 2001:DB8::1/64 eui-64 ipv6 router ospfv3 1 area 0 ``` 以上展示了如何分别针对 IPv4 和 IPv6 设置 OSPF 接口公告过程中的差异之处[^1]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值