VLAN配置

来源:互联网 发布:网站数据统计工具 编辑:程序博客网 时间:2024/05/12 13:19

首先配置switch0Switch>ENA                                               //进入特权模式Switch#conf t                                              //进入全局交换模式Enter configuration commands, one per line.  End with CNTL/Z.Switch(config)#vlan 10                                    //建立vlan10Switch(config-vlan)#exitSwitch(config)#vlan 20                                   //建立vlan20Switch(config-vlan)#exitSwitch(config)#int f0/1                               //把f0/1划分到vlan10Switch(config-if)#switchport mode accessSwitch(config-if)#switchport access vlan 10Switch(config-if)#int f0/2                             //把f0/2划分到vlan20Switch(config-if)#switchport mode accessSwitch(config-if)#switchport access vlan 20Switch(config-if)#int f0/24                           //设置中继端口Switch(config-if)#switchport mode trunkSwitch(config-if)#%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to down%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to upSwitch(config-if)#switchport trunk allowed vlan allSwitch(config-if)#no shutdownSwitch(config-if)#exitSwitch(config)#endSwitch#%SYS-5-CONFIG_I: Configured from console by consoleSwitch#show vlanVLAN Name                             Status    Ports---- -------------------------------- --------- -------------------------------1    default                          active    Fa0/3, Fa0/4, Fa0/5, Fa0/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, Gig1/1, Gig1/210   VLAN0010                         active    Fa0/120   VLAN0020                         active    Fa0/21002 fddi-default                     act/unsup 1003 token-ring-default               act/unsup 1004 fddinet-default                  act/unsup 1005 trnet-default                    act/unsup VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------1    enet  100001     1500  -      -      -        -    -        0      010   enet  100010     1500  -      -      -        -    -        0      020   enet  100020     1500  -      -      -        -    -        0      01002 fddi  101002     1500  -      -      -        -    -        0      0   1003 tr    101003     1500  -      -      -        -    -        0      0   1004 fdnet 101004     1500  -      -      -        ieee -        0      0   1005 trnet 101005     1500  -      -      -        ibm  -        0      0   配置switch1(与switch0类似)Switch>enaSwitch#conf tEnter configuration commands, one per line.  End with CNTL/Z.Switch(config)#vlan 10Switch(config-vlan)#exitSwitch(config)#vlan 20Switch(config-vlan)#exitSwitch(config)#int f0/1Switch(config-if)#switchport  mode accessSwitch(config-if)#switchport access vlan 10Switch(config-if)#int f0/24Switch(config-if)#switchport mode trunkSwitch(config-if)#switchport trunk allowed vlan allSwitch(config)#int f0/23Switch(config-if)#switchport mode trunkSwitch(config-if)#%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/23, changed state to down%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/23, changed state to upSwitch(config-if)#switchport trunk allowed vlan allSwitch(config-if)#no shutdownSwitch(config-if)#endSwitch#%SYS-5-CONFIG_I: Configured from console by console配置switch2(与switch0类似)Switch>enaSwitch#conf tEnter configuration commands, one per line.  End with CNTL/Z.Switch(config)#vlan 10Switch(config-vlan)#exitSwitch(config)#vlan 20Switch(config-vlan)#exitSwitch(config)#int f0/1Switch(config-if)#switchport mode accessSwitch(config-if)#switchport access vlan 20Switch(config-if)#int f0/24Switch(config-if)#switchport mode trunkSwitch(config-if)#switchport trunk allowed vlan allSwitch(config-if)#no shutdownSwitch(config-if)#endSwitch#%SYS-5-CONFIG_I: Configured from console by console到此交换机配置完成。对各个主机设置IP地址PC0:192.168.10.2PC1:192.168.20.3PC2:192.168.10.4PC3:192.168.20.5开始测试主机的连通性对PC0

对PC1


使用VTP配置vlan


1.先给三个交换机配置vtpSwitch>enaSwitch#conf tEnter configuration commands, one per line.  End with CNTL/Z.Switch(config)#vtp mode serverDevice mode already VTP SERVER.Switch(config)#vtp domain chenhanChanging VTP domain name from NULL to chenhanSwitch(config)#vtp password 111Setting device VLAN database password to 111Switch(config)#%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to down%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up2.进入三台交换机分别设置trunk口对switch0Switch(config)#int f0/23Switch(config-if)#switchport mode trunkSwitch(config-if)#%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/23, changed state to down%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/23, changed state to upSwitch(config-if)#switchport trunk allowed vlan allSwitch(config)#int f0/24Switch(config-if)#switchport mode trunkSwitch(config-if)#switchport trunk allowed vlan all对switch1Switch(config)#int f0/24Switch(config-if)#switchport mode trunkSwitch(config-if)#%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to down%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to upSwitch(config-if)#switchport trunk allowed vlan all对switch2Switch(config)#int f0/24Switch(config-if)#switchport mode trunkSwitch(config-if)#switchport trunk allowed vlan all3.在switch0上建立vlan10、vlan20Switch(config)#vlan 10Switch(config-vlan)#exitSwitch(config)#vlan 20Switch(config-vlan)#exit4.进入switch1、switch2把相应端口划入相应vlan对switch1Switch(config-if)#int f0/1Switch(config-if)#switchport mode accessSwitch(config-if)#switchport access vlan 10Switch(config-if)#int f0/2Switch(config-if)#switchport mode accessSwitch(config-if)#switchport access vlan 20对switch2Switch(config)#int f0/1Switch(config-if)#switchport mode accessSwitch(config-if)#switchport access vlan 10Switch(config-if)#int f0/2Switch(config-if)#switchport mode accessSwitch(config-if)#switchport access vlan 205.给主机设置IPPC0:192.168.10.2PC1:192.168.20.2PC2:192.168.10.3PC3:192.168.20.3到此配置完成对PC0

对PC1