实验划分VLAN
目的 1.vlan 的创建
2.把交换机接口划分到特定VLAN的方法
拓扑:
(1)将各路由器配置相应地址
Router#conf te
Router(config)#hostnameR1
R1(config)# interface f0/0
R1(config-if)#ip address 192.168.0.1 255.255.255.0
R1(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#
R2的配置
R2>
R2>en
R2#conf te
Enter configuration commands, one per line.End with CNTL/Z.
R2 (config)#inter f0/0
R2 (config-if)#ip ad 192.168.0.2 255.255.255.0
R2 (config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2 (config-if)#
(2)交换机基本配置以及VLAN 划分
SW1(config)#vlan 2
SW1(config-vlan)#vlan 3
(3)将端口划分在VLAN 中
SW1(config)#interfacef0/1//进入端口1
SW1(config-if)#switchport //接口配置为二层接口
SW1(config-if)#switchport mode access //交换机模式改为ACCESS
SW1(config-if)#switchport access vlan 2//将端口加入VLAN2
SW1(config)#interfacef0/2
SW1(config-if)#switchport modeaccess
SW1(config-if)#switchportaccessvlan 3
SW1(config)#interfacerangef0/3 – 5//同时添加多个端口
SW1(config-if-range)#sw
SW1(config-if-range)#switchport
SW1(config-if-range)#sw mo ac
SW1(config-if-range)#sw ac vlan 2//划分到VLAN 2
SW1(config-if-range)#
实验调试
SW1#show vlan brief //该命令查看VLAN的信息摘要
VLAN NameStatusPorts
---- -------------------------------- --------- -------------------------------
1defaultactiveFa0/6, Fa0/7, Fa0/8, Fa0/9
Fa0/10, Fa0/11, Fa0/12, Fa0/13
Fa0/14, Fa0/15, Fa0/16, Fa0/17
Fa0/18, Fa0/19, Fa0/20, Fa0/21
Fa0/22, Fa0/23, Fa0/24, Gig0/1
Gig0/2
2VLAN0002activeFa0/1, Fa0/3, Fa0/4, Fa0/5
3VLAN0003activeFa0/2
1002 fddi-defaultactive
1003 token-ring-defaultactive
1004 fddinet-defaultactive
1005 trnet-defaultactive
SW1#show interfacesf0/1 switchport //查看f0/1接口作为交换端口的有关信息
Name: Fa0/1//接口的名字
Switchport: Enabled//接口是交换端口
Administrative Mode: static access //管理员已经配置成access
Operational Mode: down
Administrative Trunking Encapsulation: dot1q//trunk 封装模式为802.1Q
Operational Trunking Encapsulation: native//接口的trunk封装为native方式,即不对帧进行重新封装
Negotiation of Trunking: Off//已关闭trunk的自动协商
Access Mode VLAN: 2 (VLAN0002)//接口在VLAN2中
Trunking Native Mode VLAN: 1 (default)
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk encapsulation: dot1q
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk private VLANs: none
Operational private-vlan: none
Trunking VLANs Enabled: All
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL
Protected: false
Unknown unicast blocked: disabled
Unknown multicast blocked: disabled
Appliance trust: none
实验测试
R1PINGR2
R1#
R1#PING192.168.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
R1#
//R1 R2所对应端口均不属于同一VLAN所以不同VLAN之间是不能通信的,
在实际应用当中,不同VLAN使用不同IP地址子网,本实验为测试,所以都属于192.168.0.0/24子网,为了实验目的