OSPF (Open Shortest Path First) is an open shortest path first routing protocol for dynamic routing selection in IP networks. Ruige will start from Huawei, Cisco, and Junifer. For H3C commands, please refer to Huawei’s commands. For Ruijie, please refer to Cisco’s commands.
Huawei equipment
Environmental preparation
Before starting to configure OSPF, make sure the following conditions are met:
- The Huawei device is properly connected and configured with the correct IP address and subnet mask.
- OSPF has been enabled on the router.
Configure topology
configuration steps
Step 1: Enter the router
First, use SSH or a serial port to log in to the management interface of the Huawei device. Enter a username and password to authenticate.
Step 2: Enter global configuration mode
After successfully logging in, enter the global configuration mode for OSPF configuration.
<设备名称> system-view
Step 3: Create an OSPF process
In global configuration mode, create an OSPF process and specify a process ID.
[设备名称] ospf <进程ID>
Step 4: Configure router ID
Configure the router ID, which is used to uniquely identify the router in the OSPF domain.
[设备名称-ospf-<进程ID>] router-id <路由器ID>
Step 5: Configure the zone
Configure OSPF areas and divide interfaces into corresponding areas. The following example divides interface GigabitEthernet 0/0/1 into area 0.
[设备名称-ospf-<进程ID>] area <区域ID>
[设备名称-ospf-<进程ID>-area-<区域ID>] network <网络地址> <网络掩码>
Step 6: Enable OSPF interface
Enable OSPF and specify the area to which the interface belongs.
[设备名称] interface <接口名称>
[设备名称-<接口名称>] ospf <进程ID> area <区域ID>
Step 7: Configure the default route
If you need to configure a default route, you can use the following command:
[设备名称] ip route-static 0.0.0.0 0.0.0.0 <下一跳地址>
Step 8: Save the configuration
After completing the OSPF configuration, remember to save the configuration.
[设备名称] save
layout script
Router1 configuration script
system-view
ospf 1
router-id 1.1.1.1
area 0
network 192.168.1.0 0.0.0.255
interface GigabitEthernet0/0/1
ospf 1 area 0
quit
interface GigabitEthernet0/0/2
ip address 192.168.2.1 255.255.255.0
quit
save
Router2 configuration script
system-view
ospf 1
router-id 2.2.2.2
area 0
network 192.168.1.0 0.0.0.255
interface GigabitEthernet0/0/1
ip address 192.168.2.2 255.255.255.0
ospf 1 area 0
quit
interface GigabitEthernet0/0/2
ip address 192.168.3.1 255.255.255.0
quit
save
Switch1 configuration script
system-view
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan all
quit
interface GigabitEthernet0/0/2
port link-type access
port default vlan 10
quit
interface Vlanif10
ip address 192.168.1.2 255.255.255.0
ospf 1 area 0
quit
interface Vlanif20
ip address 192.168.3.2 255.255.255.0
ospf 1 area 0
quit
save
cisco equipment
Environmental preparation
Before starting to configure OSPF, make sure the following conditions are met:
- The Cisco device is properly connected and configured with the correct IP address and subnet mask.
- OSPF has been enabled on the router.
Configure topology
configuration steps
Step 1: Enter the router
First, use SSH or a serial port to log in to the management interface of the Cisco device. Enter a username and password to authenticate.
Step 2: Enter global configuration mode
After successfully logging in, enter the global configuration mode for OSPF configuration.
enable
configure terminal
Step 3: Create an OSPF process
In global configuration mode, create an OSPF process and specify a process ID.
router ospf <进程ID>
Step 4: Configure router ID
Configure the router ID, which is used to uniquely identify the router in the OSPF domain.
router-id <路由器ID>
Step 5: Configure the zone
Configure OSPF areas and divide interfaces into corresponding areas. The following example divides interface GigabitEthernet0/0 into area 0.
interface GigabitEthernet0/0
ip ospf <进程ID> area <区域ID>
Step 6: Enable OSPF interface
Enable OSPF and specify the area to which the interface belongs.
interface <接口名称>
ip ospf <进程ID> area <区域ID>
Step 7: Configure the default route
If you need to configure a default route, you can use the following command:
ip route 0.0.0.0 0.0.0.0 <下一跳地址>
Step 8: Save the configuration
After completing the OSPF configuration, remember to save the configuration.
end
copy running-config startup-config
layout script
Router1 configuration script
enable
configure terminal
router ospf 1
router-id 1.1.1.1
network 192.168.1.0 0.0.0.255 area 0
interface GigabitEthernet0/0
ip address 192.168.1.1 255.255.255.0
ip ospf 1 area 0
exit
interface GigabitEthernet0/1
ip address 192.168.2.1 255.255.255.0
exit
exit
copy running-config startup-config
Router2 configuration script
enable
configure terminal
router ospf 1
router-id 2.2.2.2
network 192.168.2.0 0.0.0.255 area 0
interface GigabitEthernet0/0
ip address 192.168.2.2 255.255.255.0
ip ospf 1 area 0
exit
interface GigabitEthernet0/1
ip address 192.168.3.1 255.255.255.0
exit
exit
copy running-config startup-config
Switch1 configuration script
enable
configure terminal
interface GigabitEthernet0/0/1
switchport mode trunk
switchport trunk native vlan 1
exit
interface GigabitEthernet0/0/2
switchport mode access
switchport access vlan 10
exit
interface Vlan10
ip address 192.168.1.2 255.255.255.0
exit
interface Vlan20
ip address 192.168.3.2 255.255.255.0
exit
router ospf 1
network 192.168.1.0 0.0.0.255 area 0
network 192.168.3.0 0.0.0.255 area 0
exit
exit
copy running-config startup-config
Juniper devices
Environmental preparation
Before starting to configure OSPF, make sure the following conditions are met:
- The Juniper device is properly connected and configured with the correct IP address and subnet mask.
- OSPF has been enabled on the router.
Configure topology
configuration steps
Step 1: Enter the router
First, use SSH or a serial port to log in to the management interface of the Juniper device. Enter a username and password to authenticate.
Step 2: Enter global configuration mode
After successfully logging in, enter the global configuration mode for OSPF configuration.
configure
Step 3: Create an OSPF process
In global configuration mode, create an OSPF process and specify a process ID.
set protocols ospf area 0.0.0.0
Step 4: Configure router ID
Configure the router ID, which is used to uniquely identify the router in the OSPF domain.
set routing-options router-id <路由器ID>
Step 5: Configure the zone
Configure OSPF areas and divide interfaces into corresponding areas. The following example divides interface ge-0/0/1 into area 0.
set interfaces ge-0/0/1 unit 0 family inet address <IP地址/子网掩码>
set protocols ospf area 0.0.0.0 interface ge-0/0/1.0
Step 6: Enable OSPF interface
Enable OSPF and specify the area to which the interface belongs.
set protocols ospf area 0.0.0.0 interface ge-0/0/1.0
Step 7: Configure the default route
If you need to configure a default route, you can use the following command:
set routing-options static route 0.0.0.0/0 next-hop <下一跳地址>
Step 8: Save the configuration
After completing the OSPF configuration, remember to save the configuration.
commit
layout script
Router1 configuration script
configure
set interfaces ge-0/0/0 unit 0 family inet address 192.168.1.1/24
set protocols ospf area 0.0.0.0
set routing-options router-id 1.1.1.1
set protocols ospf area 0.0.0.0 interface ge-0/0/0.0
commit
Router2 configuration script
configure
set interfaces ge-0/0/0 unit 0 family inet address 192.168.1.2/24
set protocols ospf area 0.0.0.0
set routing-options router-id 2.2.2.2
set protocols ospf area 0.0.0.0 interface ge-0/0/0.0
commit
Switch1 configuration script
configure
set interfaces ge-0/0/0 unit 0 family inet address 192.168.1.2/24
set protocols ospf area 0.0.0.0
set protocols ospf area 0.0.0.0 interface ge-0/0/0.0
commit
Precautions
The above is a simple sample topology and corresponding configuration scripts, which can be adjusted appropriately according to the actual network environment and devices. Parameters such as the IP address, interface name, and area ID in the configuration script may need to be modified according to actual conditions.
Please make sure to back up your device configuration before using the configuration script, and verify and adjust it according to actual needs.
Summarize
In this article, Ruige introduces the basic configuration of OSPF for Huawei, Cisco, and Junifer. I hope it will be helpful to you!