Ëæ×ÅÆóÒµÄÚ²¿Á÷Á¿µÄÖð²½Ôö´ó£¬Ê¹Ó÷ÓÉÆ÷µÄ¶À±Û·Óɹ¦ÄÜÀ´ÊµÏÖ²»Í¬vlan¼ä»¥·ÃÒѲ»ÄÜÂú×ãÆóÒµÓû§µÄÐèÇó¡£ÕâʱÎÒÃÇ¿ÉÒÔʹÓÃת·¢ËٶȽϿìµÄÈý²ã½»»»»úÀ´ÊµÏÖÕâЩ¹¦ÄÜ¡£Í¨¹ýÔÚÈý²ã½»»»ÉÏÅäÖÃÏàÓ¦µÄvlanµØÖ·£¨¼´Íø¹ØµØÖ·£©£¬Èò»Í¬vlanµÄÓû§Í¨¹ýÈý²ã½»»»µÄÖмÌÁ´Â·ÊµÏÖ¿ìËٵĻ¥·Ã¡£
¡¡¡¡ÊµÏÖ²½Öè
¡¡¡¡ÔÚ2²ã½»»»»úÉÏÅäÖÃVLAN
SW-2L(config)#vlan 2
SW-2L(config-vlan)#vlan 3
SW-2L(config-vlan)#exit
¡¡¡¡ÅäÖÃËùÐèÒªµÄ½Ó¿Ú¼ÓÈëµ½vlanÖÐ
SW-2L(config)#interface range f0/2
SW-2L(config-if-range)#switchport mode access
SW-2L(config-if-range)#switchport access vlan 2
SW-2L(config)#interface range f0/3
SW-2L(config-if-range)#switchport mode access
SW-2L(config-if-range)#switchport access vlan 3
¡¡¡¡ÔÚ2²ã½»»»»úÉÏÅäÖÆTrunk½Ó¿Ú
SW-2L(config)#interface f0/1
SW-2L(config-if)#switchport mode trunk
¡¡¡¡ÔÚ3²ã½»»»»úÉÏÅäÖÃÓë2²ã½»»»»úÏàͬµÄVLAN£¨ÅäÖò½ÖèÓë·½·¨Ïàͬ£¬Ò²¿ÉÒÔÅäÖÃһ̨½»»»»úΪVTPÓò·þÎñÆ÷£¬ÆäËü½»»»»úΪVTPÓò¿Í»§¶ËÀ´×Ô¶¯Ñ§Ï°vlanÐÅÏ¢£©
SW-3L(config)#vlan database
SW-3L(config-vlan)#vlan 2
SW-3L(config-vlan)#vlan 3
SW-3L(config-vlan)#exit
¡¡¡¡ÔÚ3²ã½»»»»úÉÏÅäÖÃÖм̽ӿÚ
SW-3L(config)#interface f0/1
SW-3L(config-if)#switchport trunk encapsulation dot1q
SW-3L(config-if)#switchport mode trunk
¡¡¡¡ÔÚ3²ã½»»»»úÉÏÆô¶¯Â·ÓÉ
¡¡¡¡SW-3L£¨config£©#ip routing
¡¡¡¡vÔÚ3²ã½»»»»úÉÏÅäÖø÷VLANµÄIPµØÖ·
SW-3L(config)#interface vlan 1
SW-3L(config-if)#ip address 192.168.1.1 255.255.255.0
SW-3L(config-if)#no shut
SW-3L(config)#interface vlan 2
SW-3L(config-if)#ip address 192.168.2.1 255.255.255.0
SW-3L(config-if)#no shut
SW-3L(config)#interface vlan 3
SW-3L(config-if)#ip address 192.168.3.1 255.255.255.0
SW-3L(config-if)#no shut
¡¡¡¡ÔÚ3²ã½»»»»úÉϲ鿴·Óɱí
SW-3L#show ip route
SW-3L #sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.1.0/24 is directly connected, Vlan1
C 192.168.2.0/24 is directly connected, Vlan2
C 192.168.3.0/24 is directly connected, Vlan3
¡¡¡¡ÔÚÖ÷»ú192.168.2.2ÉÏping 192.168.3.2
¡¡¡¡ÔÚÕâÀÖ÷»úÒ²ÊÇÓ÷ÓÉÆ÷Ä£ÄâµÄ£¬ÕâÀï¾Ùһ̨µÄÅäÖÃΪÀý£º
Router#conf t
Router(config)#host PC2
PC2(config)#int f0/2
PC2(config-if)#no sw
PC2(config-if)#ip add 192.168.2.2 255.255.255.0
PC2(config-if)#no shut
PC2(config-if)#exit
PC2(config)#ip default-ga 192.168.2.1
PC2(config)#no ip routing
PC2#ping 192.168.3.2
|