用靜態路由協議實現網絡間的互通
兩年多的時間沒有在博客園寫文了,今日重返博客園,在此從一名看客變回一名時常分享所見所聞技術的小白。還請大家多多指教。
今日在學校學習了靜態路由,發現班上的同學們對於三路由組成的靜態路由不太熟練,為此特地將拓撲和詳細配置打上來,供大家參考。
拓撲:
知識補充:
靜態路由的三要素:目標網絡的網絡號、子網掩碼、下一跳。
發現同學們對下一跳的概念不是很理解,這裏來著重解釋一下“下一跳”是什麽意思
所為下一跳,是指路由的下一個點。如果路由器沒有直接連接到目的地網絡,它會有一個提供下一跳路由的鄰居路由器,用來傳遞數據到目的地。
是不是有點難以理解?那麽我們換一個比較通俗的講法?
你一個人要去出國旅行,例如到日本的東京
但是你的經濟實力比較拮據,只能購買要轉機的機票(例如先轉機到大阪,再從大阪轉機到東京)
那麽,你完整的行程就是:上海→大阪(日本)→東京(日本)
那麽按照上面的飛行軌跡,大阪就是我們從上海飛向東京的“下一跳”。無論你怎麽變化,飛機必定要經過大阪走一遭(除非你打破上述經濟實力的問題,你可以買張直達票= _=)
理解了比較搞的下一跳後,我們就可以較為輕松的配置路由了。下面給出PC和路由的詳細配置。
PC0:
PC1:
路由器R1:
R1#show running-config
Building configuration...
Current configuration : 623 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname R1
!
!
!
!
!
!
!
!
!
!
!
!
no ip domain-lookup
!
!
spanning-tree mode pvst
!
!
!
!
interface FastEthernet0/0
ip address 192.168.1.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 172.16.1.1 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
ip classless
ip route 10.27.72.0 255.255.255.0 172.16.1.2
ip route 192.168.2.0 255.255.255.0 172.16.1.2
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
login
!
!
!
end
路由器R2:
R2#show running-config
Building configuration...
Current configuration : 623 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname R2
!
!
!
!
!
!
!
!
!
!
!
!
no ip domain-lookup
!
!
spanning-tree mode pvst
!
!
!
!
interface FastEthernet0/0
ip address 172.16.1.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 10.27.72.1 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
ip classless
ip route 192.168.1.0 255.255.255.0 172.16.1.1
ip route 192.168.2.0 255.255.255.0 10.27.72.2
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
login
!
!
!
end
路由器R3:
R3#show running-config
Building configuration...
Current configuration : 623 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname R3
!
!
!
!
!
!
!
!
!
!
!
!
no ip domain-lookup
!
!
spanning-tree mode pvst
!
!
!
!
interface FastEthernet0/0
ip address 10.27.72.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.2.1 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
ip classless
ip route 192.168.1.0 255.255.255.0 10.27.72.1
ip route 172.16.1.0 255.255.255.0 10.27.72.1
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
login
!
!
!
end
tips:
如果大家懶得看每臺路由器的詳細配置,那麽大家針對本文直接看詳細配置中紅色加粗字體即可
實際驗證效果:
PC0
PC1
用靜態路由協議實現網絡間的互通