Site icon KerKer 的模組世界

[Juniper] Junos動態路由OSPF基本設定

&NewLine;<p class&equals;"wp-block-paragraph"> 邊做邊學,順便留個筆記,若有錯誤請不吝指教。 <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph"> Junos基本操作及root密碼設定可參考我之前的文章:<a href&equals;"https&colon;&sol;&sol;kerker&period;website&sol;juniper-junos&percnt;E5&percnt;9F&percnt;BA&percnt;E6&percnt;9C&percnt;AC&percnt;E6&percnt;93&percnt;8D&percnt;E4&percnt;BD&percnt;9C&percnt;E3&percnt;80&percnt;81root&percnt;E5&percnt;AF&percnt;86&percnt;E7&percnt;A2&percnt;BC&percnt;E8&percnt;A8&percnt;AD&percnt;E5&percnt;AE&percnt;9A&sol;">Juniper Junos基本操作、root密碼設定<&sol;a> <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph"> 所有Juniper相關文章列表:<a href&equals;"https&colon;&sol;&sol;kerker&period;website&sol;juniper-junos-&percnt;E7&percnt;B3&percnt;BB&percnt;E5&percnt;88&percnt;97-&percnt;E6&percnt;96&percnt;87&percnt;E7&percnt;AB&percnt;A0&percnt;E5&percnt;88&percnt;97&percnt;E8&percnt;A1&percnt;A8&sol;">Juniper JunOS 系列文章列表<&sol;a> <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<&excl;--more-->&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">在較大型的網路環境中,如果仍然使用固定路由&lpar;Static route&rpar;就會使整個網路難以維護,每次的路由異動都會是大工程,這時候使用動態路由協定會是一個比較好的選擇。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">本篇中僅進行實作說明,不包含OSPF技術細節的說明。這邊我們使用OSPF動態路由協定,為一個串接三台交換器的小型網路建立一個 OSPF 的 area 0 做為簡單範例。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<figure class&equals;"wp-block-image size-large"><img src&equals;"https&colon;&sol;&sol;lh3&period;googleusercontent&period;com&sol;pw&sol;AP1GczPxMkb7af5Y4Afaqmg8E5nvH9KD9ypYsG8nxYNax46IbaWp1jXvsPMHGN2TreOVVPasTnTMElCNLeyePviPkdUYr1f5iB1ccj8dI0fHaeAidIbJQy&fjlig;cjtkuMJTzRXHA76qsqKi-BSFnPfXBgWphwb&lowbar;&equals;w439-h471-s-no-gm&quest;authuser&equals;0" alt&equals;""&sol;><&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">在尚未進行設定前我們可以先檢查sw1的路由表<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> KerKer&commat;sw1&gt&semi; show route &NewLine; 172&period;16&period;0&period;0&sol;30 &ast;&&num;91&semi;Direct&sol;0&rsqb; 00&colon;00&colon;19&NewLine; &gt&semi; via ge-0&sol;0&sol;23&period;0&NewLine; 172&period;16&period;0&period;1&sol;32 &ast;&&num;91&semi;Local&sol;0&rsqb; 00&colon;00&colon;19&NewLine; Local via ge-0&sol;0&sol;23&period;0<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">我們觀察到在沒有做任何路由設定前,sw1的路由表僅包含與sw2連接的直連網段&lpar;Direct Link&rpar;及本地 IP&lpar;Local IP&rpar;。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">再來我們開始在sw1上建立一個OSPF的area 0&period;0&period;0&period;0,並將與sw2連接的介面加入此area。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> KerKer&commat;sw1&num; set protocols ospf area 0&period;0&period;0&period;0 interface ge-0&sol;0&sol;23&period;0<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">接著我們在sw2上重複相同的動作,將與sw1及sw3相連的介面加入 ospf area 0&period;0&period;0&period;0。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> KerKer&commat;sw2&num; set protocols ospf area 0&period;0&period;0&period;0 interface ge-0&sol;0&sol;23&period;0&NewLine; KerKer&commat;sw2&num; set protocols ospf area 0&period;0&period;0&period;0 interface ge-0&sol;0&sol;0&period;0<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">最後我們再到sw3重複上述設定。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> KerKer&commat;sw3&num; set protocols ospf area 0&period;0&period;0&period;0 interface ge-0&sol;0&sol;0&period;0&NewLine; KerKer&commat;sw3&num; set protocols ospf area 0&period;0&period;0&period;0 interface irb&period;100&NewLine; KerKer&commat;sw3&num; set protocols ospf area 0&period;0&period;0&period;0 interface irb&period;200 <&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">這裡我們將irb介面也加入area 0&period;0&period;0&period;0是為了讓這兩個介面的網段也能透過OSPF動態交換,而不是要與其他設備建立ospf neighbor。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">如果要增加安全性,避免被有心人從該vlan上與sw3建立ospf neighbor可以開啟ospf authentication選項。或是不將介面加入OSPF area,直接使用redistribute將Direct link的路由放出來即可。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">authentication做法可以參考:<a href&equals;"https&colon;&sol;&sol;kerker&period;website&sol;juniper-junos&percnt;e5&percnt;8b&percnt;95&percnt;e6&percnt;85&percnt;8b&percnt;e8&percnt;b7&percnt;af&percnt;e7&percnt;94&percnt;b1ospf&percnt;e9&percnt;a9&percnt;97&percnt;e8&percnt;ad&percnt;89&percnt;e6&percnt;a9&percnt;9f&percnt;e5&percnt;88&percnt;b6authentication&sol;" class&equals;"aioseop-link">&lbrack;Juniper&rsqb; Junos動態路由OSPF驗證機制&lpar;authentication&rpar;<&sol;a><br>redistribute做法可以參考:<a href&equals;"https&colon;&sol;&sol;kerker&period;website&sol;juniper-junos&percnt;e5&percnt;8b&percnt;95&percnt;e6&percnt;85&percnt;8b&percnt;e8&percnt;b7&percnt;af&percnt;e7&percnt;94&percnt;b1ospf&percnt;e8&percnt;b7&percnt;af&percnt;e7&percnt;94&percnt;b1&percnt;e9&percnt;87&percnt;8d&percnt;e5&percnt;88&percnt;86&percnt;e7&percnt;99&percnt;bcredistribute-route&sol;" class&equals;"aioseop-link">&lbrack;Juniper&rsqb; Junos動態路由OSPF路由重分發&lpar;redistribute route&rpar;<&sol;a><&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">我們可以回到sw1,在命令模式下使用下列指令查看同area內與sw1相鄰的路由器。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> KerKer&commat;sw1&gt&semi; show ospf neighbor &NewLine; Address Interface State ID Pri Dead&NewLine; 172&period;16&period;0&period;2 ge-0&sol;0&sol;23&period;0 Full 10&period;0&period;0&period;2 128 36<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">再次檢視路由表以確認是否友學習到動態路由。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> KerKer&commat;sw1&gt&semi; show route &NewLine; 172&period;16&period;0&period;0&sol;30 &ast;&&num;91&semi;Direct&sol;0&rsqb; 00&colon;59&colon;47&NewLine; &gt&semi; via ge-0&sol;0&sol;23&period;0&NewLine; 172&period;16&period;0&period;1&sol;32 &ast;&&num;91&semi;Local&sol;0&rsqb; 00&colon;59&colon;47&NewLine; Local via ge-0&sol;0&sol;23&period;0&NewLine; 172&period;16&period;0&period;4&sol;30 &ast;&&num;91&semi;OSPF&sol;10&rsqb; 00&colon;55&colon;27&comma; metric 2&NewLine; &gt&semi; to 172&period;16&period;0&period;2 via ge-0&sol;0&sol;23&period;0&NewLine; 192&period;168&period;100&period;0&sol;24 &ast;&&num;91&semi;OSPF&sol;10&rsqb; 00&colon;05&colon;37&comma; metric 3&NewLine; &gt&semi; to 172&period;16&period;0&period;2 via ge-0&sol;0&sol;23&period;0&NewLine; 192&period;168&period;200&period;0&sol;24 &ast;&&num;91&semi;OSPF&sol;10&rsqb; 00&colon;05&colon;45&comma; metric 3&NewLine; &gt&semi; to 172&period;16&period;0&period;2 via ge-0&sol;0&sol;23&period;0&NewLine; 224&period;0&period;0&period;5&sol;32 &ast;&&num;91&semi;OSPF&sol;10&rsqb; 01&colon;01&colon;56&comma; metric 1&NewLine; MultiRecv<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">這裡我們可以觀察到sw1已經透過ospf協定動態學習到sw2及sw3加入ospf的介面上的路由了。<&sol;p>&NewLine;

Exit mobile version