{"id":986,"date":"2021-10-11T21:10:12","date_gmt":"2021-10-12T04:10:12","guid":{"rendered":"https:\/\/www.xh86.me\/?p=986"},"modified":"2021-10-11T21:10:12","modified_gmt":"2021-10-12T04:10:12","slug":"cisco-switching-%e4%b8%89%e5%b1%82%e4%ba%a4%e6%8d%a2%e9%85%8d%e7%bd%ae%e8%b7%af%e7%94%b1","status":"publish","type":"post","link":"https:\/\/www.xh86.me\/?p=986","title":{"rendered":"Cisco Switching-\u4e09\u5c42\u4ea4\u6362\u914d\u7f6e\u8def\u7531"},"content":{"rendered":"<div>\n<h1>\u95ee\u9898<\/h1>\n<p>\u4e09\u5c42\u4ea4\u6362\u673a\u5b9e\u73b0\u4e86VLAN\u95f4\u4e92\u901a\u540e\uff0c\u8fd8\u8981\u4e0e\u5176\u4ed6\u7f51\u7edc\u8fdb\u884c\u901a\u4fe1\uff0c\u8fd9\u6837\u5c31\u9700\u8981\u6709\u76f8\u5173\u7684\u8def\u7531\u673a\u5236\u3002<\/p>\n<p>\u4ea4\u6362\u63a5\u53e3\u914d\u7f6e\u4e3a\u4e09\u5c42\u63a5\u53e3\u5b9e\u73b0\u8def\u7531\u95f4\u901a\u4fe1<\/p>\n<h1>\u65b9\u6848<\/h1>\n<p>\u4e09\u5c42\u4ea4\u6362\u673a\u65e2\u7136\u5177\u6709\u4e09\u5c42\u529f\u80fd\uff0c\u4e5f\u5c31\u53ef\u4ee5\u5b9e\u73b0\u4e0e\u8def\u7531\u5668\u76f8\u4f3c\u7684\u914d\u7f6e\u3002\u65e2\u53ef\u4ee5\u628a\u4ea4\u6362\u63a5\u53e3\u914d\u7f6e\u4e3a\u4e09\u5c42\u63a5\u53e3\uff0c\u4e5f\u53ef\u4ee5\u5728\u5176\u4e0a\u914d\u7f6e\u9759\u6001\u3001\u52a8\u6001\u8def\u7531\u3002\u901a\u8fc7\u5bf9\u4e09\u5c42\u4ea4\u6362\u673a\u7684\u8def\u7531\u914d\u7f6e\uff0c\u5b9e\u73b0VLAN\u4e0e\u5176\u4ed6\u7f51\u7edc\u7684\u4e92\u901a\u3002<\/p>\n<div class=\"image-package\">\n<div class=\"image-container\">\n<div class=\"image-container-fill\"><a href=\"https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/4211900-6b8859d9418da1bf.webp\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/4211900-6b8859d9418da1bf-300x152.webp'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-987\" data-original=\"https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/4211900-6b8859d9418da1bf-300x152.webp\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" width=\"379\" height=\"192\"  sizes=\"auto, (max-width: 379px) 100vw, 379px\" \/><\/div><\/a><\/div>\n<div class=\"image-view\" data-width=\"483\" data-height=\"245\"><\/div>\n<\/div>\n<div class=\"image-caption\">\u62d3\u6251\u56fe<\/div>\n<\/div>\n<h1>\u6b65\u9aa4<\/h1>\n<h2>1.\u914d\u7f6e\u4e09\u5c42\u4ea4\u6362\u673a<\/h2>\n<h3>\u4e09\u5c42\u4ea4\u6362\u673a\u521b\u5efavlan\u5e76\u914d\u7f6evlan\u7684\u865a\u7aef\u53e3IP\u5e76\u5f00\u542f\u8def\u7531\u529f\u80fd<\/h3>\n<p>Switch&gt;enable<\/p>\n<p>Switch#configure terminal<\/p>\n<p>Switch(config)#vlan 2<\/p>\n<p>Switch(config-vlan)#vlan 3<\/p>\n<p>Switch(config-vlan)#vlan 4<\/p>\n<p>Switch(config-vlan)#vlan 5<\/p>\n<p>Switch(config)#interface vlan 1<\/p>\n<p>Switch(config-if)#ip address 192.168.1.254 255.255.255.0<\/p>\n<p>Switch(config-if)#no shutdown<\/p>\n<p>Switch(config)#interface vlan 2<\/p>\n<p>Switch(config-if)#ip address 192.168.2.254 255.255.255.0<\/p>\n<p>Switch(config-if)#no shutdown<\/p>\n<p>Switch(config)#interface vlan 3<\/p>\n<p>Switch(config-if)#ip address 192.168.3.254 255.255.255.0<\/p>\n<p>Switch(config-if)#no shutdown<\/p>\n<p>Switch(config)#interface vlan 4<\/p>\n<p>Switch(config-if)#ip address 192.168.4.254 255.255.255.0<\/p>\n<p>Switch(config-if)#no shutdown<\/p>\n<p>Switch(config)#interface vlan 5<\/p>\n<p>Switch(config-if)#ip address 192.168.5.254 255.255.255.0<\/p>\n<p>Switch(config-if)#no shutdown<\/p>\n<p>Switch(config)#ip routing \/\/\u5f00\u542f\u8def\u7531\u529f\u80fd<\/p>\n<h3>\u4e09\u5c42\u4ea4\u6362\u7684Fa0\/23\u3001Fa0\/24\u8bbe\u7f6e\u4e3a\u4e2d\u7ee7\u94fe\u8def\u6a21\u5f0f<\/h3>\n<p>Switch(config)#interface range f0\/23-24<\/p>\n<p>Switch (config-if-range)#switchport trunk encapsulation dot1q<\/p>\n<p>Switch (config-if-range)#switchport mode trunk<\/p>\n<h2>2.\u914d\u7f6e\u4e8c\u5c42\u4ea4\u6362\u673a<\/h2>\n<h3>Sw1\u521b\u5efavlan2\u3001 vlan3\u5e76\u5c06\u7aef\u53e3\u52a0\u5165vlan<\/h3>\n<p>Sw1(config)#vlan 2<\/p>\n<p>Sw1(config)#vlan 2<\/p>\n<p>Sw1(config-vlan)#vlan 3<\/p>\n<p>Sw1(config)#interface fastEthernet 0\/2<\/p>\n<p>Sw1(config-if)#switchport access vlan 2<\/p>\n<p>Sw1(config)#interface fastEthernet 0\/3<\/p>\n<p>Sw1(config-if)#switchport access vlan 3<\/p>\n<p>Sw1(config)#interface fastEthernet 0\/5<\/p>\n<p>Sw1(config-if)#switchport mode trunk \/\/\u8fde\u63a5\u4e09\u5c42\u4ea4\u6362\u673a\u7684\u63a5\u53e3\u914d\u7f6e\u4e3atrunk\u6a21\u5f0f<\/p>\n<h3>Sw2\u521b\u5efavlan4\u3001 vlan5\u5e76\u5c06\u7aef\u53e3\u52a0\u5165vlan<\/h3>\n<p>Sw2(config)#vlan 4<\/p>\n<p>Sw2(config-vlan)#vlan 5<\/p>\n<p>Sw2(config)#interface fastEthernet 0\/1<\/p>\n<p>Sw2(config-if)#switchport access vlan 4<\/p>\n<p>Sw2(config)#interface f0\/2<\/p>\n<p>Sw2(config-if)#switchport access vlan 5<\/p>\n<h2>3.\u5c06\u4e09\u5c42\u4ea4\u6362\u7684Fa0\/6\u53e3\u914d\u7f6e\u4e3a\u4e09\u5c42\u8def\u7531\u7aef\u53e3\uff0c\u5e76\u914d\u7f6eIP\u5730\u5740<\/h2>\n<p>\u4e09\u5c42\u4ea4\u6362\u673a\u7684\u7269\u7406\u7aef\u53e3\u9ed8\u8ba4\u662f\u4e8c\u5c42\u7aef\u53e3\uff0c\u53ea\u5177\u6709\u4e8c\u5c42\u7279\u6027\uff0c\u4e0d\u80fd\u914d\u7f6eIP\u5730\u5740\u3002\u628a\u4e8c\u5c42\u7aef\u53e3\u914d\u7f6e\u4e3a\u4e09\u5c42\u7aef\u53e3\u540e\uff0c\u8be5\u7aef\u53e3\u5c31\u5177\u5907\u8def\u7531\u529f\u80fd\u4e86\uff0c\u53ef\u4ee5\u914d\u7f6eIP\u5730\u5740\uff0c\u4f46\u540c\u65f6\u4e5f\u5c31\u5173\u95ed\u4e86\u5176\u4e8c\u5c42\u7279\u6027\uff0c\u6bd4\u5982\u4e0d\u80fd\u628a\u4e09\u5c42\u7aef\u53e3\u52a0\u5165VLAN\u3002<\/p>\n<p>\u4e8c\u5c42\u7aef\u53e3\uff08\u4ea4\u6362\u673a\u4e0a\u7684\u7aef\u53e3\u9ed8\u8ba4\u90fd\u662f\u4e8c\u5c42\u7aef\u53e3\uff09\u9ed8\u8ba4\u662f\u6fc0\u6d3b\u72b6\u6001\uff0c\u90a3\u4e9b\u6ca1\u6709\u4f7f\u7528\u5230\u7684\u7aef\u53e3\u4e3a\u4e86\u5b89\u5168\u5e94\u8be5\u624b\u5de5\u5c06\u5176\u7981\u7528\uff08shutdown\uff09\uff1b\u800c\u4e09\u5c42\u7aef\u53e3\uff08\u8def\u7531\u5668\u4e0a\u7684\u7aef\u53e3\u6216\u662f\u4e09\u5c42\u4ea4\u6362\u673a\u4e0a\u88ab\u914d\u7f6e\u6210\u8def\u7531\u7aef\u53e3\u7684\u7aef\u53e3\uff09\u9ed8\u8ba4\u662f\u7981\u7528\u72b6\u6001\uff0c\u5728\u4f7f\u7528\u4e4b\u524d\u52a1\u5fc5\u8981\u5c06\u5176\u6fc0\u6d3b\uff08no shutdown\uff09\u3002<\/p>\n<p>Switch(config)#interface f0\/6<\/p>\n<p>Switch(config-if)#no switchport<\/p>\n<p>Switch(config-if)#ip address 192.168.6.1 255.255.255.0<\/p>\n<p>Switch(config-if)#no shutdown<\/p>\n<h2>4.\u914d\u7f6e\u8def\u7531\u5668\u7684\u7aef\u53e3IP\u5730\u5740<\/h2>\n<p>Switch(config)#interface f0\/0<\/p>\n<p>Switch(config-if)#ip address 192.168.6.2 255.255.255.0<\/p>\n<p>Switch(config-if)#no shutdown<\/p>\n<p>Switch(config-if)#interface f0\/1<\/p>\n<p>Switch(config-if)#ip address 192.168.7.254 255.255.255.0<\/p>\n<p>Switch(config-if)#no shutdown<\/p>\n<h2>5.\u5728\u4e09\u5c42\u4ea4\u6362\u673a\u4e0a\u914d\u7f6e\u9759\u6001\u8def\u7531\uff0c\u4ee5\u4fbfVLAN\u5185\u4e3b\u673a\u53ef\u4ee5\u4e0e\u5916\u754c\u7f51\u7edc\u4e92\u8054<\/h2>\n<p>Switch(config)#iproute 192.168.7.0 255.255.255.0 192.168.6.2 \/\/\u683c\u5f0f ip route \u4e0b\u4e00\u8df3<\/p>\n<p>Switch(config)#exit<\/p>\n<p>Switch#show ip route<\/p>\n<p>Codes: C &#8211; connected, S &#8211; static, I &#8211; IGRP, R &#8211; RIP, M &#8211; mobile, B &#8211; BGP<\/p>\n<p>D &#8211; EIGRP, EX &#8211; EIGRP external, O &#8211; OSPF, IA &#8211; OSPF inter area<\/p>\n<p>N1 &#8211; OSPF NSSA external type 1, N2 &#8211; OSPF NSSA external type 2<\/p>\n<p>E1 &#8211; OSPF external type 1, E2 &#8211; OSPF external type 2, E &#8211; EGP<\/p>\n<p>i &#8211; IS-IS, L1 &#8211; IS-IS level-1, L2 &#8211; IS-IS level-2, ia &#8211; IS-IS inter area<\/p>\n<p>* &#8211; candidate default, U &#8211; per-user static route, o &#8211; ODR<\/p>\n<p>P &#8211; periodic downloaded static route<\/p>\n<p>Gateway of last resort is not set<\/p>\n<p>C 192.168.1.0\/24 is directly connected, Vlan1<\/p>\n<p>C 192.168.2.0\/24 is directly connected, Vlan2<\/p>\n<p>C 192.168.3.0\/24 is directly connected, Vlan3<\/p>\n<p>C 192.168.4.0\/24 is directly connected, Vlan4<\/p>\n<p>C 192.168.5.0\/24 is directly connected, Vlan5<\/p>\n<p>C 192.168.6.0\/24 is directly connected, FastEthernet0\/6<\/p>\n<p>S 192.168.7.0\/24 [1\/0] via 192.168.6.2<\/p>\n<h2>6.\u5728\u8def\u7531\u5668\u4e0a\u914d\u7f6e\u5230\u8fbe\u4e09\u4e2aVLAN\u7f51\u7edc\u7684\u9759\u8def\u7531<\/h2>\n<p>tarena-rouer(config)#ip route 192.168.1.0 255.255.255.0 192.168.6.1<\/p>\n<p>tarena-rouer(config)#ip route 192.168.2.0 255.255.255.0 192.168.6.1<\/p>\n<p>tarena-rouer(config)#ip route 192.168.3.0 255.255.255.0 192.168.6.1<\/p>\n<p>tarena-rouer(config)#ip route 192.168.4.0 255.255.255.0 192.168.6.1<\/p>\n<p>tarena-rouer(config)#ip route 192.168.5.0 255.255.255.0 192.168.6.1<\/p>\n<p>tarena-rouer(config)#exit<\/p>\n<p>tarena-rouer#show ip rout<\/p>\n<p>Codes: C &#8211; connected, S &#8211; static, I &#8211; IGRP, R &#8211; RIP, M &#8211; mobile, B &#8211; BGP<\/p>\n<p>D &#8211; EIGRP, EX &#8211; EIGRP external, O &#8211; OSPF, IA &#8211; OSPF inter area<\/p>\n<p>N1 &#8211; OSPF NSSA external type 1, N2 &#8211; OSPF NSSA external type 2<\/p>\n<p>E1 &#8211; OSPF external type 1, E2 &#8211; OSPF external type 2, E &#8211; EGP<\/p>\n<p>i &#8211; IS-IS, L1 &#8211; IS-IS level-1, L2 &#8211; IS-IS level-2, ia &#8211; IS-IS inter area<\/p>\n<p>* &#8211; candidate default, U &#8211; per-user static route, o &#8211; ODR<\/p>\n<p>P &#8211; periodic downloaded static route<\/p>\n<p>Gateway of last resort is not set<\/p>\n<p>S\u00a0 \u00a0 192.168.1.0\/24 [1\/0] via 192.168.6.1<\/p>\n<p>S\u00a0 \u00a0 192.168.2.0\/24 [1\/0] via 192.168.6.1<\/p>\n<p>S\u00a0 \u00a0 192.168.3.0\/24 [1\/0] via 192.168.6.1<\/p>\n<p>S\u00a0 \u00a0 192.168.4.0\/24 [1\/0] via 192.168.6.1<\/p>\n<p>S\u00a0 \u00a0 192.168.5.0\/24 [1\/0] via 192.168.6.1<\/p>\n<p>C\u00a0 \u00a0 192.168.6.0\/24 is directly connected, FastEthernet0\/0<\/p>\n<p>C\u00a0 \u00a0 192.168.7.0\/24 is directly connected, FastEthernet0\/1<\/p>\n<h2>7.\u5728PC\u4e0a\u6d4b\u8bd5\u4e0eVLAN\u7684\u8fde\u901a\u6027<\/h2>\n<p>PC&gt;ipconfig<\/p>\n<p>FastEthernet0 Connection:(default port)<\/p>\n<p>Link-local IPv6 Address&#8230;&#8230;&#8230;: FE80::2E0:8FFF:FE14:BB43<\/p>\n<p>IP Address&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.: 192.168.7.1<\/p>\n<p>Subnet Mask&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;: 255.255.255.0<\/p>\n<p>Default Gateway&#8230;&#8230;&#8230;&#8230;&#8230;..: 192.168.7.254<\/p>\n<p>SERVER&gt;ping 192.168.1.1<\/p>\n<p>Pinging 192.168.1.1 with 32 bytes of data:<\/p>\n<p>Request timed out.<\/p>\n<p>Reply from 192.168.1.1: bytes=32 time=0ms TTL=126<\/p>\n<p>Reply from 192.168.1.1: bytes=32 time=0ms TTL=126<\/p>\n<p>Reply from 192.168.1.1: bytes=32 time=1ms TTL=126<\/p>\n<p>Ping statistics for 192.168.1.1:<\/p>\n<p>Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),<\/p>\n<p>Approximate round trip times in milli-seconds:<\/p>\n<p>Minimum = 0ms, Maximum = 1ms, Average = 0ms<\/p>\n<p>SERVER&gt;ping 192.168.2.1<\/p>\n<p>Pinging 192.168.2.1 with 32 bytes of data:<\/p>\n<p>Reply from 192.168.2.1: bytes=32 time=0ms TTL=126<\/p>\n<p>Reply from 192.168.2.1: bytes=32 time=0ms TTL=126<\/p>\n<p>Reply from 192.168.2.1: bytes=32 time=0ms TTL=126<\/p>\n<p>Reply from 192.168.2.1: bytes=32 time=0ms TTL=126<\/p>\n<p>Ping statistics for 192.168.2.1:<\/p>\n<p>Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),<\/p>\n<p>Approximate round trip times in milli-seconds:<\/p>\n<p>Minimum = 0ms, Maximum = 0ms, Average = 0ms<\/p>\n<p>\u200b<\/p>\n<p>SERVER&gt;ping 192.168.3.1<\/p>\n<p>Pinging 192.168.3.1 with 32 bytes of data:<\/p>\n<p>Reply from 192.168.3.1: bytes=32 time=1ms TTL=126<\/p>\n<p>Reply from 192.168.3.1: bytes=32 time=0ms TTL=126<\/p>\n<p>Reply from 192.168.3.1: bytes=32 time=0ms TTL=126<\/p>\n<p>Reply from 192.168.3.1: bytes=32 time=0ms TTL=126<\/p>\n<p>Ping statistics for 192.168.3.1:<\/p>\n<p>Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),<\/p>\n<p>Approximate round trip times in milli-seconds:<\/p>\n<p>Minimum = 0ms, Maximum = 1ms, Average = 0ms<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898 \u4e09\u5c42\u4ea4\u6362\u673a\u5b9e\u73b0\u4e86VLAN\u95f4\u4e92\u901a\u540e\uff0c\u8fd8\u8981\u4e0e\u5176\u4ed6\u7f51\u7edc\u8fdb\u884c\u901a\u4fe1\uff0c\u8fd9\u6837\u5c31\u9700\u8981\u6709\u76f8\u5173\u7684\u8def\u7531\u673a\u5236\u3002 \u4ea4\u6362\u63a5\u53e3\u914d\u7f6e\u4e3a\u4e09 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-986","post","type-post","status-publish","format-standard","hentry","category-cisco"],"_links":{"self":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=986"}],"version-history":[{"count":1,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/986\/revisions"}],"predecessor-version":[{"id":988,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/986\/revisions\/988"}],"wp:attachment":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}