Site icon KerKer 的模組世界

[Juniper] Junos動態路由OSPF驗證機制(authentication)

&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">關於OSPF的基本設定可以參考:<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;e5&percnt;9f&percnt;ba&percnt;e6&percnt;9c&percnt;ac&percnt;e8&percnt;a8&percnt;ad&percnt;e5&percnt;ae&percnt;9a&sol;" class&equals;"aioseop-link">Junos動態路由OSPF基本設定<&sol;a><&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">OSPF協定可以透過認證來保證只有受信任的設備能夠加入路由交換,此功能預設是關閉的。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">相對於Cisco能夠在area、interface設定認證,Juniper設備僅能夠於interface設定認證選項。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">架構圖將沿用基本設定裡的架構如下,所有的介面都已經事先加入ospf area 0&period;0&period;0&period;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">Junos上可以設定simple-password及MD5兩種認證機制。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">其中simple-password是直接將password以明文的方式嵌入封包作為認證使用,若封包遭竊聽則有可能遭到冒用。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">若使用MD5認證,則是將Hash值及checksum加入封包進行認證,相對較為安全。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">這裡將以sw1至sw2的ospf 為例。。 <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">在開始設定之前,我們可以先使用下列指令確認目前的OSPF認證狀態:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> KerKer&commat;sw1&gt&semi; show ospf interface detail &NewLine; Interface State Area DR ID BDR ID Nbrs&NewLine; ge-0&sol;0&sol;23&period;0 BDR 0&period;0&period;0&period;0 10&period;0&period;0&period;2 10&period;0&period;0&period;1 1&NewLine; Type&colon; LAN&comma; Address&colon; 172&period;16&period;0&period;1&comma; Mask&colon; 255&period;255&period;255&period;252&comma; MTU&colon; 1500&comma; Cost&colon; 1&NewLine; DR addr&colon; 172&period;16&period;0&period;2&comma; BDR addr&colon; 172&period;16&period;0&period;1&comma; Priority&colon; 128&NewLine; Adj count&colon; 1&NewLine; Hello&colon; 10&comma; Dead&colon; 40&comma; ReXmit&colon; 5&comma; Not Stub&NewLine; Auth type&colon; None&NewLine; Protection type&colon; None&NewLine; Topology default &lpar;ID 0&rpar; -&gt&semi; Cost&colon; 1<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">Auth type 顯示為 none,即代表未啟用認證選項。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">另外也先檢查目前所連接的ospf neighbor:<&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">記錄下狀態後我們就可以開始設定認證了,這裡我們直接設定較安全的MD5認證,我們將key-id設定為1,密碼為KerKer:<&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 authentication md5 1 key KerKer<&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 configuration protocols ospf &NewLine; area 0&period;0&period;0&period;0 &lbrace;&NewLine; interface ge-0&sol;0&sol;23&period;0 &lbrace;&NewLine; authentication &lbrace;&NewLine; md5 1 key "&dollar;9&dollar;bd2oZHkPTF&sol;RheWXxsY"&semi; &num;&num; SECRET-DATA&NewLine; &rcub;&NewLine; &rcub;&NewLine; &rcub;<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">再次確認OSPF認證狀態,Auth type已變成MD5:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> KerKer&commat;sw1&gt&semi; show ospf interface detail &NewLine; Interface State Area DR ID BDR ID Nbrs&NewLine; ge-0&sol;0&sol;23&period;0 BDR 0&period;0&period;0&period;0 10&period;0&period;0&period;2 10&period;0&period;0&period;1 1&NewLine; Type&colon; LAN&comma; Address&colon; 172&period;16&period;0&period;1&comma; Mask&colon; 255&period;255&period;255&period;252&comma; MTU&colon; 1500&comma; Cost&colon; 1&NewLine; DR addr&colon; 172&period;16&period;0&period;2&comma; BDR addr&colon; 172&period;16&period;0&period;1&comma; Priority&colon; 128&NewLine; Adj count&colon; 1&NewLine; Hello&colon; 10&comma; Dead&colon; 40&comma; ReXmit&colon; 5&comma; Not Stub&NewLine; Auth type&colon; MD5&comma; Active key ID&colon; 1&comma; Start time&colon; 2000 Jan 5 00&colon;04&colon;27 UTC&NewLine; Protection type&colon; None&NewLine; Topology default &lpar;ID 0&rpar; -&gt&semi; Cost&colon; 1<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">再次查看ospf neighbor會發現此時原本的鄰居已經中斷連線:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> KerKer&commat;sw1&gt&semi; show ospf neighbor <&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">這是因為ospf認證設定需要兩端都做相同設定才能生效,我們進到sw2做設定:<&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 authentication md5 1 key KerKer<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">commit生效後再次回到sw1再次確認ospf neighbor:<&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 33<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">到這裡我們已經完成ospf authentication的設定了,這麼設定後只有知道認證密碼的設備才能加入ospf路由交換了!<&sol;p>&NewLine;

Exit mobile version