A, OSPF basic concepts of
OSPF (Open Shortest Path First) is an interior gateway protocol (Interior Gateway Protocol, referred IGP). Relative to RIP, OSPF protocol is a link state the road, and the RIP is a distance vector routing protocol. Link is another way of saying router interface, also known as interface state so OSPF routing protocol. OSPF is established by the state of the network interface between the router advertisement link state database, to generate the shortest path tree, OSPF each router uses the shortest path routing table.
Second, on the OSPF experimental operation
1. Network requirements
• • All switches run OSPF, and the entire AS is divided into three areas.
• • Switch A and Switch B as ABR to forward routing information between areas.
• • After configuration, all switches can learn routes to all network segments in the AS
2 Step Configuration
(1) Configuration of IP addresses for the interfaces
Example SwitchB:
<H3C> SYS
[H3C] hostname SwitchB
[SwitchB] VLAN 100
[SwitchB-VLANs 100] Port G 1/0/10
[SwitchB-VLANs 100] quit
[SwitchB] VLAN 200 is
[SwitchB-VLAN200] Port G 1/0/20
[SwitchB-VLAN200] quit
[SwitchB] Inter VLAN 100
[SwitchB interface100--VLAN] IP 10.1.1.2 the Add 24
[SwitchB-of Vlan-interface100] quit
[SwitchB] Inter VLAN 200 is
[SwitchB-of Vlan-interface200] IP 10.3.1.1 the Add 24
[SwitchB-of Vlan-interface200] quit
[SwitchB]
(2) 配置 OSPF 基本配置
配置 Switch A。
<SwitchA> system-view
[SwitchA] router id 10.2.1.1
[SwitchA] ospf
[SwitchA-ospf-1] area 0
[SwitchA-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[SwitchA-ospf-1-area-0.0.0.0] quit
[SwitchA-ospf-1] area 1
[SwitchA-ospf-1-area-0.0.0.1] network 10.2.1.0 0.0.0.255
[SwitchA-ospf-1-area-0.0.0.1] quit
[SwitchA-ospf-1] quit
配置 Switch B。
<SwitchB> system-view
[SwitchB] router id 10.3.1.1
[SwitchB] ospf
[SwitchB-ospf-1] area 0
[SwitchB-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[SwitchB-ospf-1-area-0.0.0.0] quit
[SwitchB-ospf-1] area 2
[SwitchB-ospf-1-area-0.0.0.2] network 10.3.1.0 0.0.0.255
[SwitchB-ospf-1-area-0.0.0.2] quit
[SwitchB-ospf-1] quit
配置 Switch C。
<SwitchC> system-view
[SwitchC] router id 10.4.1.1
[SwitchC] ospf
[SwitchC-ospf-1] area 1
[SwitchC-ospf-1-area-0.0.0.1] network 10.2.1.0 0.0.0.255
[SwitchC-ospf-1-area-0.0.0.1] network 10.4.1.0 0.0.0.255
[SwitchC-ospf-1-area-0.0.0.1] quit
[SwitchC-ospf-1] quit
配置 Switch D。
<SwitchD> system-view
[SwitchD] router id 10.5.1.1
[SwitchD] ospf
[SwitchD-ospf-1] area 2
[SwitchD-ospf-1-area-0.0.0.2] network 10.3.1.0 0.0.0.255
[SwitchD-ospf-1-area-0.0.0.2] network 10.5.1.0 0.0.0.255
[SwitchD-ospf-1-area-0.0.0.2] quit
[SwitchD-ospf-1] quit
(3)验证配置
查看 Switch A 的 OSPF 邻居。
[SwitchA] display ospf peer verbose
查看 Switch A 的 OSPF 路由信息。
[SwitchA] display ospf routing
查看 Switch D 的 OSPF 路由信息。
[SwitchD] display ospf routing
在 Switch D 上使用 Ping 进行测试连通性。
[SwitchD] ping 10.4.1.1
3、实验操作2
配置OSPF引入自治系统外部路由
- 组网需求
• • 所有的交换机都运行 OSPF,整个自治系统划分为 3 个区域。
• • 其中 Switch A 和 Switch B 作为 ABR 来转发区域之间的路由。
• • 在 Switch C 上配置为 ASBR 引入外部路由(静态路由),且路由信息可正确的在 AS 内传播。
2.配置步骤
(1) 配置各接口的 IP 地址(略)
(2) 配置OSPF(同前例 )
(3) 配置引入自治系统外部路由
在 Switch C 上配置一条到目的网段 3.1.2.0/24 的静态路由。
<SwitchC> system-view
[SwitchC] ip route-static 3.1.2.1 24 10.4.1.2
在 Switch C 上配置 OSPF 引入静态路由。
[SwitchC] ospf 1
[SwitchC-ospf-1] import-route static
验证配置
查看 Switch D 的 ABR/ASBR 信息。
<SwitchD> display ospf abr-asbr
查看 Switch D 的 OSPF 路由表。
<SwitchD> display ospf routing
3、实验操作3
配置OSPF发布聚合路由
- 组网需求
• • Switch A 和 Switch B 位于 AS 200 内,AS 200 内使用 OSPF 作为 IGP 协议。
• • Switch C、Switch D 和 Switch E 位于 AS 100 内,AS 100 内使用 OSPF 作为 IGP 协议。
• • Switch B 和 Switch C 之间建立 EBGP 连接,配置 BGP 引入 OSPF 和直连路由,配置 OSPF
进程引入 BGP 路由。
• • 为了减小 Switch A 的路由表规模,在 Switch B 上配置路由聚合,只发布聚合后的路由
10.0.0.0/8。
- 配置步骤
(1) 配置接口的 IP 地址
(2) 配置 OSPF
配置 Switch A。
<SwitchA> system-view
[SwitchA] router id 11.2.1.2
[SwitchA] ospf
[SwitchA-ospf-1] area 0
[SwitchA-ospf-1-area-0.0.0.0] network 11.2.1.0 0.0.0.255
[SwitchA-ospf-1-area-0.0.0.0] quit
[SwitchA-ospf-1] quit
配置 Switch B。
<SwitchB> system-view
[SwitchB] router id 11.2.1.1
[SwitchB] ospf
[SwitchB-ospf-1] area 0
[SwitchB-ospf-1-area-0.0.0.0] network 11.2.1.0 0.0.0.255
[SwitchB-ospf-1-area-0.0.0.0] quit
[SwitchB-ospf-1] quit
配置 Switch C。
<SwitchC> system-view
[SwitchC] router id 11.1.1.2
[SwitchC] ospf
[SwitchC-ospf-1] area 0
[SwitchC-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[SwitchC-ospf-1-area-0.0.0.0] network 10.2.1.0 0.0.0.255
[SwitchC-ospf-1-area-0.0.0.0] quit
[SwitchC-ospf-1] quit
配置 Switch D。
<SwitchD> system-view
[SwitchD] router id 10.3.1.1
[SwitchD] ospf
[SwitchD-ospf-1] area 0
[SwitchD-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[SwitchD-ospf-1-area-0.0.0.0] network 10.3.1.0 0.0.0.255
[SwitchD-ospf-1-area-0.0.0.0] quit
配置 Switch E。
<SwitchE> system-view
[SwitchE] router id 10.4.1.1
[SwitchE] ospf
[SwitchE-ospf-1] area 0
[SwitchE-ospf-1-area-0.0.0.0] network 10.2.1.0 0.0.0.255
[SwitchE-ospf-1-area-0.0.0.0] network 10.4.1.0 0.0.0.255
[SwitchE-ospf-1-area-0.0.0.0] quit
[SwitchE-ospf-1] quit
(3) 配置 BGP,引入 OSPF 和直连路由
配置 Switch B。
[SwitchB] bgp 200
[SwitchB-bgp] peer 11.1.1.2 as 100
[SwitchB-bgp] address-family ipv4 unicast
[SwitchB-bgp-ipv4] import-route ospf
[SwitchB-bgp-ipv4] import-route direct
[SwitchB-bgp-ipv4] peer 11.1.1.2 enable 注意不要少了这句
[SwitchB-bgp-ipv4] quit
[SwitchB-bgp] quit
配置 Switch C。
[SwitchC] bgp 100
[SwitchC-bgp] peer 11.1.1.1 as 200
[SwitchC-bgp] address-family ipv4 unicast
[SwitchC-bgp-ipv4] import-route ospf
[SwitchC-bgp-ipv4] import-route direct
[SwitchC-bgp-ipv4] peer 11.1.1.1 enable #注意不要少了这句
[SwitchC-bgp-ipv4] quit
[SwitchC-bgp] quit
(4) arranged OSPF into BGP routes on Switch B and Switch C
configuration OSPF into BGP routes on Switch B.
[SwitchB] OSPF
[OSPF--SwitchB. 1] Import-BGP route
configured OSPF into BGP routes on Switch C.
[SwitchC] OSPF
[OSPF--SwitchC. 1] Import-route BGP
routing table of SwitchA.
[SwitchA] display ip routing-table
(5) arranged on the route aggregation Switch B, only the summary route 10.0.0.0/8.
[SwitchB-ospf-1] asbr -summary 10.0.0.0 8
See Switch A's routing table.
[SwitchA] display ip routing-table