交换机vlan配置的一些操作

这篇博客详细介绍了如何配置网络设备,包括基于华三设备的VLAN创建、端口分配以及三层交换机和二层交换机的设置。内容涵盖VLAN接口IP地址配置、Trunk端口设置、控制台及虚拟终端口令管理和设备的初始配置。同时,展示了不同类型的交换机配置示例,如主干端口封装协议和VLAN网关的设定。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

基于华三设备操作。

基于思科模拟器


基于华三设备操作。

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值