OSPF中的forward address主要在广播共享网络中起作用(如以下拓扑图),该字段的作用类似于"第三方下一跳"的概念。

以下例子可以更具体地理解OSPF LSA5中的forward address字段:

OSPF LSA5中的forward address_第1张图片

R1::

interface FastEthernet0/0
 ip address 123.1.1.1 255.255.255.0
!
router ospf 110
 network 123.1.1.1 0.0.0.0 area 0

R2:

interface FastEthernet0/0

 ip address 123.1.1.2 255.255.255.0

!
router ospf 110
 redistribute rip subnets
 network 123.1.1.2 0.0.0.0 area 0
!
router rip
 version 2
 network 123.0.0.0
 no auto-summary

R3:

interface FastEthernet0/0
 ip address 123.1.1.3 255.255.255.0
!
interface FastEthernet1/0
 ip address 34.1.1.3 255.255.255.0
!
router rip
 version 2
 network 34.0.0.0
 network 123.0.0.0
 no auto-summary
 
查看OSPF的LSA5中forward address:
 
R1#sh ip os database external
 
            OSPF Router with ID (123.1.1.1) (Process ID 110)
 
                Type-5 AS External Link States
 
 Routing Bit Set on this LSA
 LS age: 375
 Options: (No TOS-capability, DC)
 LS Type: AS External Link
 Link State ID: 34.1.1.0 (External Network Number )
 Advertising Router: 123.1.1.2
 LS Seq Number: 80000003
 Checksum: 0x304A
 Length: 36
 Network Mask: /24
        Metric Type: 2 (Larger than any link state path)
        TOS: 0
        Metric: 20
        Forward Address: 123.1.1.3
        External Route Tag: 0

R1#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
 
     34.0.0.0/24 is subnetted, 1 subnets
O E2    34.1.1.0 [110/20] via 123.1.1.3, 00:12:45, FastEthernet0/0
     123.0.0.0/24 is subnetted, 1 subnets
C        123.1.1.0 is directly connected, FastEthernet0/0
 
当把R2的F0/0接口passive或更改其OSPF的网络类型后,发现forward address为0.0.0.0,路由表中34网段的下一跳变为123.1.1.2即R2F0/0接口的地址。
 
结论:
1.forward address的作用:
forward address是ASBR通告的type 5 LSA中的字段,它是告诉OSPF域内的路由器如何选择下一跳地址才能够更快捷地到达LSA5所通告的路由。
2.forward address为0.0.0.0
此时路由器想去往外部路由就把包发往ASBR。
3.forward address为非0.0.0.0
此时路由表中的forward address网段若有效,则去往外部路由就发给该forward address地址。
4.满足forward address为非0.0.0.0必须同时满足以下条件:
a.引入的这条外部路由,其对应的出接口(如本例R2的F0/0)宣告OSPF。
b.引入的这条外部路由,其对应的出接口不被passive-interface。
c.引入的这条外部路由,其对应的出接口的OSPF网络类型必须为broadcast。