Site icon KerKer 的模組世界

[Juniper] Junos提交設定(commit)

&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">&NewLine;&NewLine;所有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"> 使用Juniper設備的設定模式時,Junos會將目前運行的config檔複製出來供管理者做修改。<br> 這個時候對config檔所有改動皆不會立即生效,需要透過commit指令將設定檔寫入才會生效。<br> 如果commit成功則會顯示如下:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-preformatted"> &lbrace;master&colon;0&rcub;&lbrack;edit&rsqb;<br> root&num; commit <br> configuration check succeeds<br> commit complete<&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph"><br> 這邊要注意的是完成commit之後仍然是在設定模式,如果希望在完成commit後回到命令列模式可以在commit後加上and-quit。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-preformatted"> &lbrace;master&colon;0&rcub;&lbrack;edit&rsqb;<br> root&num; commit and-quit <br> configuration check succeeds<br> commit complete<br> Exiting configuration mode<&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph"> commit指令提供管理者在commit時加上註解&lpar;comment&rpar;的功能,用來紀錄修改內容<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-preformatted"> root&num; commit comment test<br> root&num; commit comment "test 123"<&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph"> 這裡需要特別注意的是,如果註解內容包含空格則需要在註解內容前後加上引號&lpar;&&num;8220&semi;&rpar;。<br> 如果遠端設定時擔心設定檔內容有誤造成斷線,commit指令提供一個10分鐘自動復原&lpar;rollback&rpar;的功能。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-preformatted"> root&num; commit confirmed <br> configuration check succeeds<br> commit confirmed will be automatically rolled back in 10 minutes unless confirmed<br> commit complete<&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph"> 如同上面的系統提示所述,如果管理者在10分鐘內沒有再次下達commit指令,則系統會自動復原至commit前的設定檔。<br> 另外commit也提供管理者排程功能,在commit指令後加上at &lbrack;時間&rsqb; 即可。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-preformatted"> &lbrace;master&colon;0&rcub;&lbrack;edit&rsqb;<br> root&num; commit at "2019-01-19 16&colon;41&colon;00" <br> configuration check succeeds<br> commit at will be executed at 2019-01-19 16&colon;41&colon;00 UTC<br> Exiting configuration mode<&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph"> 在命令列模式下可以使用&&num;8221&semi;show system commit&&num;8221&semi;來查看commit紀錄,這邊就可以看到我們剛剛所有的commit紀錄。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-preformatted"> root&gt&semi; show system commit <br> 0 2019-01-19 16&colon;41&colon;18 UTC by root via cli commit at<br> 1 2019-01-19 16&colon;36&colon;21 UTC by root via cli<br> 2 2019-01-19 16&colon;36&colon;13 UTC by root via cli commit confirmed&comma; rollback in 10mins<br> 3 2019-01-19 16&colon;35&colon;57 UTC by root via cli<br> test 123<br> 4 2019-01-19 16&colon;35&colon;51 UTC by root via cli<br> test<br> 5 2019-01-19 16&colon;35&colon;39 UTC by root via cli<&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph"> 最後提供一個在commit前用來檢查設定檔的指令<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-preformatted"> &lbrace;master&colon;0&rcub;&lbrack;edit&rsqb;<br> root&num; commit check <br> configuration check succeeds<&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph"> commit check僅僅會檢查語法是否正確,設定上的邏輯是否正確仍然需要人工進行確認,可以在commit前先確認與現行設定檔的差異<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-preformatted"> root&num; show &vert; compare<br> &lbrack;edit interfaces ge-0&sol;0&sol;0 unit 0&rsqb;<br> &plus; family inet &lbrace;<br> &plus; address 10&period;0&period;0&period;1&sol;24&semi;<br> &plus; &rcub;<br> - family ethernet-switching &lbrace;<br> - storm-control default&semi;<br> - &rcub;<&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph"><br> 差異的部分會使用&&num;8221&semi;&plus;&&num;8221&semi;號代表增加的設定,&&num;8221&semi;-&&num;8220&semi;則是減少的設定,如果仍然不確定設定修改是否正確還是用commit confirmed吧!<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph"> 當然,如果真的不小心下錯了指令,還可以使用 rollback 指令來救急, 更多關於 rollback 指令的內容可以參考:<a href&equals;"https&colon;&sol;&sol;kerker&period;website&sol;juniper-junos&percnt;E5&percnt;BF&percnt;AB&percnt;E9&percnt;80&percnt;9F&percnt;E5&percnt;BE&percnt;A9&percnt;E5&percnt;8E&percnt;9Frollback&sol;"> Juniper Junos快速復原&lpar;rollback&rpar;<&sol;a><&sol;p>&NewLine;

Exit mobile version