目录
基于华三设备操作。
sys
vlan 10 #创建一个vlan 10,(默认vlan 1)
port Ethernet 1/0/1 to port Ethernet 1/0/10 #将交换机上1至10端口分给vlan1
vlan 20 #创建一个vlan 20
interface Ethernet 1/0/11 #对11端口操作
port access vlan 20 #将11端口加入至valn 20
quit #退出
interface Ethernet 1/0/12 #对12端口操作
port link-type trunk #进行公共端口设置,trunk主干
port trunk permit vlan 10 20 #将12端口设为vlan 10、vlan 20的公共端口
quit #退出
interface vlan-interface 10 #对vlan 10设置
ip address 192.168.1.1 24 #设置vlan 10 ip为192.168.1.1,子网掩码255.255.255.0
interface vlan-interface 20 #对vlan 20设置
ip address 192.168.2.1 24 #设置vlan 20 ip为192.168.2.1,子网掩码255.255.255.0
dis vlan all #显示所有vlan设置
- 三层交换机
基于思科模拟器
en # 进入特殊模式
configure terminal # 进入全局配置模式
# PC3 超级终端
# 控制台端口口令
en
conf t
# 进入(config)#
line console 0
# 进入(config-line)#
password 123
login
ex
ex
# 添加至启动配置
# 到#
copy running-config startup-config
# 重启
Reload
# 虚拟终端端口口令
en
conf t
# 进入(config)#
line vty 0 4
# 进入(config-line)#
password 456
login
# enable password/secret 口令
en
conf t
# 进入(config)#
# 明文
enable password 12
# 密文(优先级高于明文)
enable sercret 12
- PC3通过RS232口-Switch1的Console口完成初次配置
SW 配置信息
SW1#show running-config
Building configuration...
!主机名是 SW1
hostname SW1
!enable password口令 12 (用户模式切换特权模式时明文口令)
enable password 12
!
spanning-tree mode pvst
spanning-tree extend system-id
!
interface FastEthernet0/1
!
interface FastEthernet0/2
!
interface Vlan1
ip address 192.168.3.245 255.255.255.0
!
!控制台端口口令 123 (通过console进入时口令)
line con 0
password 123
login
!虚拟终端端口口令 456 (通过PC1或PC2 telnet,也仅允许0至4端口)
line vty 0 4
password 456
login
line vty 5 15
login
!
end
配置PC1 和 PC2 同网段IP
- 二层交换机
en
# 进入#
vlan database
vlan 2 name vlan2
vlan 3 name vlan3
ex
conf t
# 端口加入vlan 例
# 进入(config)#
interface fastEthernet 0/1
# 进入(config-if)#
switchport mode access # 可省略
switchport access vlan 2
ex
# 主干端口配置
# 进入(config)#
interface fastEthernet 0/5
# 进入(config-if)#
switchport mode trunk
SW 配置信息
Switch#show running-config
Building configuration...
!
hostname Switch
!
spanning-tree mode pvst
spanning-tree extend system-id
!
interface FastEthernet0/1
switchport access vlan 2
switchport mode access
!
interface FastEthernet0/2
switchport access vlan 2
switchport mode access
!
interface FastEthernet0/3
switchport access vlan 3
switchport mode access
!
interface FastEthernet0/4
switchport access vlan 3
switchport mode access
!
interface FastEthernet0/5
switchport mode trunk
!
interface Vlan1
no ip address
shutdown
end
- 三层交换机
# 设置vlan加入端口同二层,但使用三层交换机,主干端口还需封装协议,vlan配置ip为网关
# 主干端口配置
# 进入(config)#
interface fastEthernet 0/5
# 进入(config-if)#
switchport mode trunk
switchport trunk encapsulation dot1q
ex
# vlan配置ip为网关
# 进入(config)#
interface vlan 2
ip address 192.168.3.1 255.255.255.248
PC配置IP和网关(对应vlan的IP)
SW 配置信息
Switch#show running-config
Building configuration...
!
interface FastEthernet0/1
switchport access vlan 2
switchport mode access
switchport nonegotiate
!
interface FastEthernet0/2
switchport access vlan 2
switchport mode access
switchport nonegotiate
!
interface FastEthernet0/3
switchport access vlan 3
switchport mode access
switchport nonegotiate
!
interface FastEthernet0/4
switchport access vlan 3
switchport mode access
switchport nonegotiate
!
interface FastEthernet0/5
switchport trunk encapsulation dot1q
switchport mode trunk
!
interface Vlan1
no ip address
shutdown
!
interface Vlan2
mac-address 0009.7cd7.d001
ip address 192.168.3.1 255.255.255.248
!
interface Vlan3
mac-address 0009.7cd7.d002
ip address 192.168.3.254 255.255.255.248
!
end