配置路由協議rip和ospf
阿新 • • 發佈:2018-12-22
完成拓撲圖,並使各個網段的主機可以通訊。
1.使用RIP配置動態路由 對R0 Continue with configuration dialog? [yes/no]: no Press RETURN to get started! Router>en Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int f0/0 Router(config-if)#ip add 10.1.5.1 255.255.255.0 Router(config-if)#no shut Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up Router(config-if)#int f0/1 Router(config-if)#ip add 10.1.1.1 255.255.255.0 Router(config-if)#no shut Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up Router(config-if)#int s0/0/0 Router(config-if)#ip add 10.1.2.1 255.255.255.0 Router(config-if)#no shut %LINK-5-CHANGED: Interface Serial0/0/0, changed state to down Router(config-if)#int s0/0/1 Router(config-if)#ip add 10.1.3.1 255.255.255.0 Router(config-if)#no shut %LINK-5-CHANGED: Interface Serial0/0/1, changed state to down Router(config-if)#int s0/1/0 Router(config-if)#ip add 10.1.4.1 255.255.255.0 Router(config-if)#no shut %LINK-5-CHANGED: Interface Serial0/1/0, changed state to down Router(config-if)#router rip Router(config-router)#net 10.1.1.0 Router(config-router)#net 10.1.2.0 Router(config-router)#net 10.1.3.0 Router(config-router)#net 10.1.4.0 Router(config-router)#net 10.1.5.0 Router(config-router)# %LINK-5-CHANGED: Interface Serial0/0/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/0, changed state to up %LINK-5-CHANGED: Interface Serial0/0/1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/1, changed state to up %LINK-5-CHANGED: Interface Serial0/1/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up %IP-4-DUPADDR: Duplicate address 10.1.5.1 on FastEthernet0/0, sourced by 0060.4760.5201 %IP-4-DUPADDR: Duplicate address 10.1.5.1 on FastEthernet0/0, sourced by 0060.4760.5201
對R1 Continue with configuration dialog? [yes/no]: no Press RETURN to get started! Router>en Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int f0/0 Router(config-if)#ip add 192.168.10.1 255.255.255.0 Router(config-if)#no shut Router(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 Router(config-if)#int f0/1 Router(config-if)#ip add 192.168.20.1 255.255.255.0 Router(config-if)#no shut Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up Router(config-if)#int s0/0/0 Router(config-if)# ip add 10.1.2.2 255.255.255.0 Router(config-if)#no shut Router(config-if)# %LINK-5-CHANGED: Interface Serial0/0/0, changed state to up Router(config-if)#int s0/0/1 Router(config-if)#ip add 10.1.3.2 255.255.255.0 Router(config-if)#no shut Router(config-if)# %LINK-5-CHANGED: Interface Serial0/0/1, changed state to up Router(config-if)#router rip Router(config-router)#net 10.1.2.0 Router(config-router)#net 10.1.3.0 Router(config-router)#net 192.168.10.0 Router(config-router)#net 192.168.20.0 Router(config-router)#exit
對R2 Continue with configuration dialog? [yes/no]: no Press RETURN to get started! Router>en Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int f0/0 Router(config-if)#ip add 192.168.30.1 255.255.255.0 Router(config-if)#no shut Router(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 Router(config-if)#int f0/1 Router(config-if)#ip add 192.168.40.1 255.255.255.0 Router(config-if)#no shut Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up Router(config-if)#int s0/0/0 Router(config-if)#ip add 10.1.4.2 255.255.255.0 Router(config-if)#no shut Router(config-if)# %LINK-5-CHANGED: Interface Serial0/0/0, changed state to up Router(config-if)#router rip %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/0, changed state to up Router(config-router)#router rip Router(config-router)#net 10.1.4.0 Router(config-router)#net 192.168.30.0 Router(config-router)#net 192.168.40.0 Router(config-router)#exit
對R3
Continue with configuration dialog? [yes/no]: no
Press RETURN to get started!
Router>en
Router#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int f0/0
Router(config-if)#ip add 10.1.5.2 255.255.255.0
Router(config-if)#no shut
Router(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
%IP-4-DUPADDR: Duplicate address 10.1.5.1 on FastEthernet0/0, sourced by 0090.2B99.CE01
%IP-4-DUPADDR: Duplicate address 10.1.5.1 on FastEthernet0/0, sourced by 0090.2B99.CE01
Router(config-if)#int f0/1
Router(config-if)#ip add 172.16.10.1 255.255.255.0
Router(config-if)#no shut
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Router(config-if)#router rip
Router(config-router)#net 10.1.5.0
Router(config-router)#net 172.16.10.0
給各個主機設定ip、掩碼、閘道器
PC0: 192.168.10.2 255.255.255.0 192.168.10.1
PC1: 192.168.20.2 255.255.255.0 192.168.20.1
PC2: 192.168.30.2 255.255.255.0 192.168.30.1
PC3: 192.168.40.2 255.255.255.0 192.168.40.1
PC4: 172.16.10.2 255.255.255.0 172.16.10.1
Server0:10.1.1.2 255.255.255.0 10.1.1.1
對R0
對R1
對R2
對R3
2.使用ospf配置動態路由(直接刪除更改原有配置)
對R0
Router(config)#no router rip
Router(config)#router ospf 1
Router(config-router)#net 10.1.1.0 0.0.0.255 area 0
Router(config-router)#net 10.1.2.0 0.0.0.255 area 0
Router(config-router)#net 10.1.3.0 0.0.0.255 area 0
Router(config-router)#net 10.1.4.0 0.0.0.255 area 0
Router(config-router)#net 10.1.5.0 0.0.0.255 area 0
對R1
Router(config)#no router rip
Router(config)#router ospf 1
Router(config-router)#net 10.1.2.0 0.0.0.255 area 0
Router(config-router)#net 10.1.3.0 0.0.0.255 area 0
Router(config-router)#net 192.168.10.0 0.0.0.255 area 0
Router(config-router)#net 192.168.20.0 0.0.0.255 area 0
對R2
Router(config)#no router rip
Router(config)#router ospf 1
Router(config-router)#net 10.1.4.0 0.0.0.255 area 0
Router(config-router)#net 192.168.30.0 0.0.0.255 area 0
Router(config-router)#net 192.168.40.0 0.0.0.255 area 0
Router(config-router)#
對R3
Router(config)#no router rip
Router(config)#router ospf 1
Router(config-router)#net 10.1.5.0 0.0.0.255 area 0.
Router(config-router)#net 172.16.10.0 0.0.0.255 area 0
Router(config-router)#
OSPF配置完成,檢視四個路由器的路由表
動態路由配置,使用了兩種方法RIP和OSPF。配置過程比較簡單,先是配置埠IP,然後開啟RIP或OSPF宣告網路。與靜態路由相比,路由協議只用宣告與其相鄰的網路,而靜態路由則需配置所有與其不同的固定路由。與OSPF相比,RIP適合小型網路,不支援子網和超網,而且容易產生環路,並消耗網路頻寬。所以相同情況下應該使用OSPF。