OSPF的配置
1.按照上图配好IP地址
2.R1的基本配置
Router>enable
Router#configure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host R1
R1(config)#int f0/0
R1(config-if)#ip add 192.168.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#int s0/0/0
R1(config-if)#ip add 172.168.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#clock rate 64000
R1(config-if)#no shutdown
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to down
R1(config-if)#exit
R1(config)#
3.R2的基本配置
Router>enable
Router#configure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host R2
R2(config)#int f0/0
R2(config-if)#ip add 192.168.2.1 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config-if)#int s0/0/0
R2(config-if)#ip add 172.168.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to up
R2(config-if)#
4.R1,R2,OSPF的配置命令
- 启动ospf协议:router ospf 1
- 定义一个区间的地址范围:network
- 查看当前运行的路由协议:show ip protocols
R1(config)#router ospf 1
R1(config-router)#network 172.168.1.0 0.0.0.255 area 0
R1(config-router)#network 192.168.1.0 0.0.0.255 area 1
R1(config-router)#
R2(config)#router ospf 1
R2(config-router)#network 172.168.1.0 0.0.0.255 area 0
R2(config-router)#network 192.168.2.0 0.0.0.255 area 2
R2(config-router)#
R2#show ip protocols
Routing Protocol is "ospf 1"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.2.1
Number of areas in this router is 2. 2 normal 0 stub 0 nssa
Maximum path: 4
Routing for Networks:
172.168.1.0 0.0.0.255 area 0
192.168.2.0 0.0.0.255 area 2
Routing Information Sources:
Gateway Distance Last Update
192.168.1.1 110 00:04:56
192.168.2.1 110 00:04:31
Distance: (default is 110)
R2#
5.验证PC0和PC1能相互PING通