Site icon KerKer 的模組世界

[Juniper] Junos基本vlan設定

&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">vlan的設定細節比較多,因此可能無法較為全面的做說明,這邊就以一個常見的拓樸作範例。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<figure class&equals;"wp-block-image size-large"><a href&equals;"https&colon;&sol;&sol;lh3&period;googleusercontent&period;com&sol;EKKqtqnq0qKqONp5ytk-owXiK5OFieZBcOlpMUUYP-DnU5K7hq4Tj0wc3Z3HU1GfRxTo61Z5HqjpxjLPDw-YPpLGbxQP9osnQtORJQgci0uMiGuP-DidSaLcpW4bsqTyr9H4ox56VjkbNMW&lowbar;SoTV9ah8RkOrmyv1NFxKMXoXuubEI9Ve2vlGosi8bYzbTg2dSDbEZq-3TCl9GRJShkW79b7TlYClg1eI3R-Py7yUiNV7YfnWvkFGfG2oVzyQaXLJ7zfoYpkuE&lowbar;7e3rLL8JYSz80EwXTR82u6mGVy71rZXp2JdfJGtIKTOelmQu4VbM1VsZJDSM4mjNLzWTEMXNYAn0w3NlgP7sa2&lowbar;4UfwV4YvL3MkEtI-hOg1UyNXOb7JHbQgCwR-tZKi23hgObRlgKFTzxj88EH4sxxGQ8l7&lowbar;oJKZC1ggifyMdCRJTN5IqwEjjPnQMZUGEizOxUDseghTccOW9rXRFr2MBv&lowbar;K9Hc8zOGlw4KHs9NuR-1aGkUaYGXLBmv7oHYV1IUH9X7Yu8W1nmXPvCfpzntwNEe2-rEzgSMhS3onELgdD5uRIe4x58EKSKQkcZ2ivS8syRUq4SUM-lBHN9yo5JWIuU2VTURXsjShnZhyI4sGmrnKFclyyRl8oCCPXK6m5cMYmkc4-YnwAhI8a2J0fTgxB0QNvjPVcxoV4nVWvL0vYf0L6xmkNw0jD4X7tKCtv3KGTiF9HW-Ub81ar5FWC-HpdzXWDmZiwAgAYDp9mT&equals;w471-h364-no"><img src&equals;"https&colon;&sol;&sol;lh3&period;googleusercontent&period;com&sol;pw&sol;AP1GczM&lowbar;MPTluDZlnX6KabLz&lowbar;sm5zFqDuqeJqFqKptynXO2a4zZGROEgsCWd78VlBCbyW89E8q4KNk6ybXOlAvJU&lowbar;ul5HXZMTGsppte8K26bulLUeDQIGa6fJPgbbl4VpZKflcIz5wCUYpg5NTyZ3ty-943M&equals;w471-h364-s-no-gm&quest;authuser&equals;0" alt&equals;""&sol;><&sol;a><&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">在這個拓樸中sw1作為vlan100和vlan200的gateway,vlan1作為管理vlan。sw2使用vlan trunk串接sw1,並讓兩台PC分別連到access vlan100的介面及access vlan200的介面。<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">我們先到sw1查看初始的vlan設定:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> KerKer&commat;sw1&gt&semi; show configuration vlans &NewLine; default &lbrace;&NewLine; vlan-id 1&semi;&NewLine; l3-interface irb&period;0&semi;&NewLine; &rcub;<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">初始的vlan設定僅有vlan1作為default vlan,並將irb&period;0作為vlan1的l3-interface&lpar;在舊的版本中會是vlan&period;0&rpar;<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">首先先將sw1的管理IP設定到irb&period;0上,這裡分配10&period;0&period;0&period;1作為sw1的管理IP:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> &lbrace;master&colon;0&rcub;&&num;91&semi;edit&rsqb;&NewLine; KerKer&commat;sw1&num; set interfaces irb&period;0 family inet address 10&period;0&period;0&period;1&sol;24<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">這裡先分別建立vlan100及vlan200,並以irb&period;100和irb&period;200作為l3 interface:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> &lbrace;master&colon;0&rcub;&&num;91&semi;edit&rsqb;&NewLine; KerKer&commat;sw1&num; set vlans v100 l3-interface irb&period;100&NewLine; &lbrace;master&colon;0&rcub;&&num;91&semi;edit&rsqb;&NewLine; KerKer&commat;sw1&num; set vlans v200 l3-interface irb&period;200<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">在irb&period;100和irb&period;200兩個介面上設定ip作為vlan100及vlan200的gateway:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> &lbrace;master&colon;0&rcub;&&num;91&semi;edit&rsqb;&NewLine; KerKer&commat;sw1&num; set interfaces irb&period;100 family inet address 192&period;168&period;100&period;254&sol;24 &NewLine; &lbrace;master&colon;0&rcub;&&num;91&semi;edit&rsqb;&NewLine; KerKer&commat;sw1&num; set interfaces irb&period;200 family inet address 192&period;168&period;200&period;254&sol;24<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">將與sw2連接的ge-0&sol;0&sol;0介面設定為trunk,並加入default、v100、v200等三個vlan:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> &lbrace;master&colon;0&rcub;&&num;91&semi;edit&rsqb;&NewLine; KerKer&commat;sw1&num; edit interfaces ge-0&sol;0&sol;0 unit 0 family ethernet-switching&NewLine; &lbrace;master&colon;0&rcub;&&num;91&semi;edit interfaces ge-0&sol;0&sol;0 unit 0 family ethernet-switching&rsqb;&Tab;&Tab;&NewLine; KerKer&commat;sw2&num; set interface-mode trunk&NewLine; &lbrace;master&colon;0&rcub;&&num;91&semi;edit interfaces ge-0&sol;0&sol;0 unit 0 family ethernet-switching&rsqb;&NewLine; KerKer&commat;sw1&num; set vlan members &&num;91&semi;default v100 v200&rsqb;<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">sw2的irb&period;0介面做相同的設定,這裡分配10&period;0&period;0&period;2作為sw2的管理IP:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> &lbrace;master&colon;0&rcub;&&num;91&semi;edit&rsqb;&NewLine; KerKer&commat;sw2&num; set interfaces irb&period;0 family inet address 10&period;0&period;0&period;2&sol;24<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">一樣建立vlan100及vlan200,但是不用建立l3 iinterface&lpar;要建立也可以但不是必須&rpar;:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> &lbrace;master&colon;0&rcub;&&num;91&semi;edit&rsqb;&NewLine; KerKer&commat;sw2&num; set vlans v100 vlan-id 100 &NewLine; KerKer&commat;sw2&num; set vlans v200 vlan-id 200<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">將與sw1連接的ge-0&sol;0&sol;0介面設定為trunk,並加入default、v100、v200等三個vlan:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> &lbrace;master&colon;0&rcub;&&num;91&semi;edit&rsqb;&NewLine; KerKer&commat;sw2&num; edit interfaces ge-0&sol;0&sol;0 unit 0 family ethernet-switching&NewLine;&NewLine; &lbrace;master&colon;0&rcub;&&num;91&semi;edit interfaces ge-0&sol;0&sol;0 unit 0 family ethernet-switching&rsqb;&NewLine; KerKer&commat;sw2&num; set vlan members &&num;91&semi;default v100 v200&rsqb;<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">接著分別將連接到兩台PC的介面設定為access vlanl00及access vlan200:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> &lbrace;master&colon;0&rcub;&&num;91&semi;edit&rsqb;&NewLine; KerKer&commat;sw2&num; edit interfaces ge-0&sol;0&sol;1 unit 0 family ethernet-switching&NewLine;&NewLine; &lbrace;master&colon;0&rcub;&&num;91&semi;edit interfaces ge-0&sol;0&sol;1 unit 0 family ethernet-switching&rsqb;&NewLine; KerKer&commat;sw2&num; set interface-mode access vlan members 100 &NewLine;&NewLine; &lbrace;master&colon;0&rcub;&&num;91&semi;edit interfaces ge-0&sol;0&sol;2 unit 0 family ethernet-switching&rsqb;&NewLine; KerKer&commat;sw2&num; set interface-mode access vlan members 200<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">到這邊sw1及sw2的設定基本完成了,查看位於vlan100的PC設定:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> C&colon;&bsol;Users&bsol;Jacky&gt&semi;ipconfig&NewLine;&NewLine; Windows IP 設定&NewLine; &period;&period;&period;&NewLine; IPv4 位址 &period; &period; &period; &period; &period; &period; &period; &period; &period; &period; &period; &period; &colon; 192&period;168&period;100&period;1&NewLine; 子網路遮罩 &period; &period; &period; &period; &period; &period; &period; &period; &period; &period; &period; &period;&colon; 255&period;255&period;255&period;0&NewLine; 預設閘道 &period; &period; &period; &period; &period; &period; &period; &period; &period; &period; &period; &period; &period;&colon; 192&period;168&period;100&period;254&NewLine; &period;&period;&period;<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">嘗試ping vlan100的gateway:<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"wp-block-code"><code> C&colon;&bsol;Users&bsol;Jacky&gt&semi;ping 192&period;168&period;100&period;254&NewLine;&NewLine; Ping 192&period;168&period;100&period;254 &lpar;使用 32 位元組的資料&rpar;&colon;&NewLine; 回覆自 192&period;168&period;100&period;254&colon; 位元組&equals;32 時間&equals;12ms TTL&equals;64&NewLine; 回覆自 192&period;168&period;100&period;254&colon; 位元組&equals;32 時間&equals;3ms TTL&equals;64&NewLine; 回覆自 192&period;168&period;100&period;254&colon; 位元組&equals;32 時間&equals;13ms TTL&equals;64&NewLine; 回覆自 192&period;168&period;100&period;254&colon; 位元組&equals;32 時間&equals;5ms TTL&equals;64&NewLine;&NewLine; 192&period;168&period;100&period;254 的 Ping 統計資料&colon;&NewLine; 封包&colon; 已傳送 &equals; 4,已收到 &equals; 4&comma; 已遺失 &equals; 0 &lpar;0&percnt; 遺失&rpar;,&NewLine; 大約的來回時間 &lpar;毫秒&rpar;&colon;&NewLine; 最小值 &equals; 3ms,最大值 &equals; 13ms,平均 &equals; 8ms<&sol;code><&sol;pre>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">到這邊已經可以確定vlan的設定已經正確完成了!<&sol;p>&NewLine;

Exit mobile version