valn配置命令
Sw1(config)#valn 10 //创建vlan ID号
Sw1(config-vlan)#name xiaohang //命名vlan名
Sw1(config)#no vlan 10 //删除vlan
Sw1(config)#interface fastEthernet1/1 //选择分配端口
Sw1(config)#interface range fastEthernet 1/1 -5 //同时还分配多个端口
Sw1(config-if)#switchport mode access //定义二层端口模式(思科设备默认就是二层端口模式,可省略)
sw1(config-if)#switchport access vlan 10 //把端口加入vlan
sw1(config)#default interface fastEthernet 1/1 //还原接口到默认配置状态
sw2#show vlan-switch brief //查看vlan信息
trunk配置命令
sw1(config)#interface fastEthernet 1/15 //进接口
sw1(config-if)#switchport mode trunk //配置接口为trunk
sw1(config-if)#switchport trunk allowed vlan remove 10 //从trunk中删除某个vlan
sw1(config-if)#switchport trunk allowed vlan add 10 //从trunk中添加某个vlan
sw1#show interfaces fastEthernet 1/15 switchport //查看接口类型
三层交换配置命令
M1(config)#vlan 10 //加vlan
M1(config)#interface vlan 10 //进vlan
M1(config-if)#ip add 192.168.1.1 255.255.255.0 //配置IP、掩码
例题
sw1 配置
!
no ip routing
vlan 10
valn 20
!
interface FastEthernet1/1
switchport access vlan 10
!
interface FastEthernet1/2
switchport access vlan 20
!
interface FastEthernet1/15
switchport mode trunk
!
interface FastEthernet1/0
switchport mode trunk
sw2 配置
!
no ip routing
!
valn 10
valn 20
!
interface FastEthernet1/3
switchport access vlan 10
!
interface FastEthernet1/4
switchport access vlan 20
!
interface FastEthernet1/15
switchport mode trunk
M1配置
!
interface FastEthernet1/0
switchport mode trunk
!
interface Vlan10
ip address 192.168.1.1 255.255.255.0
!
interface Vlan20
ip address 192.168.2.1 255.255.255.0
!