设为首页收藏本站language 语言切换
查看: 3267|回复: 7
收起左侧

[分享] 思科交换机基本配置命令

[复制链接]
 成长值: 64660
发表于 2022-10-19 09:56:38 | 显示全部楼层 |阅读模式
Vlan 划分:
1. 用随机所配的 console 电缆连接 cisco4503 交换机的 console 口与 pc 机的 com 口,在系统的超级终端中新
建连接,设置波特率: 9600, 数据位: 8, 奇偶校验位: 无, 停止位: 1,流量控制: 无,打开交换机,可以看到 switch
的自检信息,自检结束后进入到 switch 的 privilege mode
2. Switch# show vlan 检查交换机的默认 vlan 设置,默认配置下所有端口属于 vlan1
3. Switch# conf t 进入 global config mode
Switch(config)#vlan 2 创建 vlan2
Switch (config-vlan)# name test-net 设置 vlan2 的 name 为 test-net(可选)
Switch (config-vlan)#end 退回到 privilege mode
Switch# show vlan
根据需要重复上述 1-5 步设置,创建 vlan3 、 vlan4……
4. Switch# conf t 进入 global config mode
Switch(config)# int range gi2/1 – 18 对第二个 module 的 1 到 18 端口进行设置, 注意: 1 与” - ” , ” - ”
与 18 之间的空格是必须的
Switch(config-if-range)#shutdown 关闭端口 1-18
Switch(config-if-range)#switchport mode access 设置端口特性为可访问
Switch(config-if-range)#switchport access vlan 2 将端口分配给 vlan2
Switch(config-if-range)#no shutdown 激活端口
Switch(config-if-range)#end
Switch# show vlan 检查当前 vlan 配置,可以看到端口 1-18 已经分配给 vlan2
Switch# copy running-config startup-config copy 当前配置到 NVRAM
Switch# sh interface status 检查各端口的状态
交换机 trunk 端口的配置:
在本方案中, 两台 CISCO4503 使用引擎上的第二个光纤模块端口进行连接,在其中的一台
switch# conf t 进入全局配置模式
switch(config)#interface gi1/2 进入到端口配置模式,对第二个光纤模块口进行设置
switch(config-if )shutdown
switch(config-if)switchprot trunk encapsulation isl 指定 trunk 端口封装 isl 协议
switch(config-if)switchprot mode trunk 指定这个端口作为 trunk
switch(config-if )no shutdown 启动这个端口
switch(config-if )end 退回到 privilege
switch#copy running-config startup-config 保存当前配置使重启时生效
在第二台 4503 交换机上重复上述操作。
用光纤线连接这两个端口。
switch: ; ROM 状态
hostname> ; 用户模式
hostname# ; 特权模式
hostname(config)# ; 全局配置模式
hostname(config-if)# ; 接口状态
switch>enable ; 进入特权模式
switch#config terminal ; 进入全局配置模式
switch(config)#hostname ; 设置交换机的主机名
switch(config)#enable secret xxx ; 设置特权加密口令
switch(config)#enable password xxa ; 设置特权非密口令
switch(config)#line console 0 ; 进入控制台口
switch(config-line)#line vty 0 4 ; 进入虚拟终端
switch(config-line)#login ; 允许登录
switch(config-line)#password xx ; 设置登录口令 xxswitch#
exit ; 返回命令
switch#vlan database ; 进入 VLAN 设置
switch(vlan)#vlan 2 ; 建 VLAN 2
switch(vlan)#no vlan 2 ; 删 vlan 2
switch(config)#int f0/1 ; 进入端口 1
switch(config-if)#switchport access vlan 2 ; 当前端口加入 vlan 2
switch(config-if)#switchport mode trunk ; 设置为干线
switch(config-if)#switchport trunk allowed vlan 1 , 2 ; 设置允许的 vlan
switch(config-if)#switchport trunk encap dot1 q ; 设置 vlan 中继
switch(config)#vtp domain ; 设置发 vtp 域名
switch(config)#vtp password ; 设置发 vtp 密码
switch(config)#vtp mode server ; 设置发 vtp 模式
switch(config)#vtp mode client ; 设置发 vtp 模式
switch(config)#interface vlan 1 ; 进入 vlan 1
switch(config-if)#ip address ; 设置 IP 地址
switch(config)#ip default-gateway ; 设置默认网关
switch#dir flash: ; 查看闪存
switch#write ; 保存配置信息
switch#show vtp ; 查看 vtp 配置信息
switch#show run ; 查看当前配置信息
switch#show vlan ; 查看 vlan 配置信息
switch#show interface ; 查看端口信息
switch#show int f0/0 ; 查看指定端口信息
思科交换机详细配置方法和命令
悬赏分: 0 | 解决时间: 2010-12-21 20:06 | 提问者: qq2510809
最佳答案
switch>
switch>enable
switch#
switch#vlan database(进入 vlan 维护模式)
switch(vlan)#vlan 2 name vlan2(给 vlan 2 命名为 vlan2)
switch(vlan)#vlan 4 name vlan4(给 vlan 4 命名为 vlan4)
switch(vlan)#exit(这里要注意一下, 要打入 exit 退出才有效, 不能用 ctrl+z
或 end 直接退出, 因为这么不能使配置生效!)
switch#show vlan(查看 vlan 的配置,默认有 vlan1 )
switch#configure terminal(进入全局配置模式)
switch(config)#interface f0/1 (进入 fastethernet0/1 接口配置模式)
switch(config-if)#switchport mode access(这步可以省略)
switch(config-if)#switchport access vlan 2 (把该接口划分到 vlan2,记得vlan2
之间有空格)
switch(config-if)#no shutdown(激活端口)
switch(config-if)#exit
switch(config)#interface f0/2
switch(config-if)#switchport mode access
switch(config-if)#switchport access vlan 4
switch(config-if)#no shutdown
switch(config-if)#exit
switch(config)#interface f0/3
switch(config-if)#switchport mode trunk(设置此口为中继模式)
switch(config-if)#no shutdown
witch(config-if)#exit(这里可以直接用 ctrl+z 或 end 直接退出到特权模式)
二.在路由器 Cisco2611 上的配置(!!!单臂路由!!!)
router#configure terminal
router(config)#interface f0/0.1 (进入子接口模式)
router(config-subif)#encapsulation dot1 q 2(设置封装类型为 dot1 q,它是思
科特有的。 此外还有 isl 封装, 要看该设备支不支持。 数字 2 是 vlan 号)
router(config-subif)#ip address 1 92.1 68.1 .1 255.255.255.0
router(config-subif)#exit
router(config)#interface f0/0.2
router(config-subif)#encapsulation dot1 q 4
router(config-subif)#ip address 1 92.1 68.3.1 255.255.255.0
router(config-subif)#exit
router(config)#interface f0/0
router(config-if)#no shutdown
router(config-if)#^z
router#show running-config
router#copy running-config startup-config
1 、 配置 IP 地址
交换机要能够被网管, 必须给它标识一个管理 IP 地址, 默认情况下 CISCO
交换机的 VLAN 1 为管理 VLAN, 为该 VLAN 配上 IP 地址, 交换机就可以被网
管了。 命令如下:
a、 进入全局模式: Switch#configure terminal
b、 进入 VLAN 1 接口模式:Switch(config)#interface vlan 1
c、 配置管理 IP 地址:Switch(config-if) # ip address [A.B.C.D] [mask]
如果当前 VLAN 不是管理 VLAN , 只需要将上面第 b 处命令的 vlan 的
号码换成管理 VLAN 的号码即可。
2、 打开 SNMP 协议
a、 进入全局模式: Switch#configure terminal
b、 配置只读的 Community, 产品默认的只读 Community 名为 public
Switch(config)#snmp-server community public ro
c、 配置可写的 Community, 产品默认的可写 Community 名为 private
Switch(config)#snmp-server community private rw
3、 更改 SNMP 的 Community 密码
a、 将设备分组, 并使能支持的各种 SNMP 版本
Switch(config)#snmp-server group qycx1 23 v1
Switch(config)#snmp-server group qycx 1 23 v2c
Switch(config)#snmp-server group qycx1 23 v3 noauth
b、 分别配置只读和可写 community 如:
Switch(config)#snmp-server community qycx1 23 ro
Switch(config)#snmp-server community qycx1 23 rw
4、 保存交换机配置
Switch#copy run start
常用命令
1 、 设置交换机密码
a、 更改远程 TELNNET 密码
Switch#configure terminal
Switch(config)#line vty 0 4
Switch(config-line)#password qycx1 23
Switch(config-line)#login
Switch(config-line)#exit
b、 更改进入全局配置模式时的密码
Switch#configure terminal
Switch(config)#enable secret qycx1 23
2、 创建并划分 VLAN
a、 创建 VLAN
Switch#vlan database
Switch(vlan) #vlan 99 name office
(创建 vlan 99 并命名为 office)
b、 将端口划分至 vlan
Switch(config)#interface fastEthernet 0/8
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 99
(将 8 号快速以太口划分至 vlan 99)
3、 常用调试命令
a、 显示所有配置命令: Switch#show run
b、 显示所有接口状态: Switch#show ip int brief
c、 显示所有 VLAN 的信息: Switch#show vlan brief
一、 网络配置
2950(config)#int vlan1
2950(config-if)#ip address 1 92.1 68.1 .1 00 255.255.255.0 (VLAN1 里面设
置 IP 地址)
2950(config)#ip default-gateway 1 92.1 68.1 .1 (设置默认网关)
2950(config)#ip name-server 1 92.1 68.1 .1 (设置域名服务
器)
2950(config)#ip domain-name wqs.com (设置域名)
二、 端口配置
2950(config)#int f0/1 (进入接口)
2950(config-if)#speed 1 00 (设置该接口速率为 1 00Mb/s)
2950(config-if)#duplex ?
auto Enable AUTO duplex configuration
full Force full duplex operation
half Force half-duplex operation
2950(config-if)#description to_router1 (设置端口描述)
2950#show interfaces fastethernet1 [status] (查看端口配置结果和状态)
三、 MAC 地址表相关命令
2950(config)#mac-address-table aging-time 1 00
(设置超时时间为 1 00S)
2950(config)#mac-address-table permanent 000.0c01 .bbcc f0/3
(加入永久地址)
2950(config)#mac-address-table restricted static 0000.0c02.bbcc f0/6 f0/7
(加入静态地址)
2950#show mac-address-table (查看整个 MAC 地
址表)
2950#clear mac-address-table restricted static (清除限制性 MAC 址表)
四、 VTP 的配置
2950#vlan database (进入 VLAN 配置模式)
2950(vlan)#vtp ? (查看 VTP 的子命令)
domain Set the name of the VTP administrative domain.
client Set the device to client mode.
server Set the device to server mode.
transparent Set the device to transparent mode.
password Set the password for the VTP administrative domain.
2950(vlan)#vtp domain server (设置本交换机为 SEVER 模式)
2950(vlan)#vtp domain wqs (设置域名)
2950(vlan)#vtp pruning (启动修剪模式)
2950#show vtp status (查看 VTP 设置信息)
五、 配置 VLAN TRUNK 端口
2950(config)#int f0/1 1 (进入 F 端口)
2950(config-if)#switchport mode trunk (设置该端口为 TRUNK 模式)
2950(config-if)#switchport trunk encapsulation {dot1 q | isl | negotiate }(设
置 TRUNK 封装)
六、 创建 VLAN
2950#vlan database (进入 VLAN 配置模式)
2950(vlan)#vlan 2 (创建 VLAN 2)
VLAN 2 added:
Name:VLAN0002 (系统默认名)
2950(vlan)#vlan 3 name wg_bisheng (创建 VLAN 3, 名为网工必
胜)
VLAN 3 added:
Name:wg_bisheng
2950(config)#int f0/9 (进入接口配置模式)
2950(config-if)#switchport mode access (设置该接口为 ACCESS
模式)
2950(config-if)#switchport access vlan 2 (把端口 9 分配给 VLAN2)
2950(config-if)#int f0/8
2950(config-if)#switchport mode access
2950(config-if)#switchport access vlan 3
2950(config-if)#end
七、 生成树协议的配置
生成树负载均衡实现方法(感谢黑客天使提醒)
1 使用 STP 端口权值实现。
2 使用 STP 路径值实现
2950(config)#int f0/1 1
2950(config-if)#spanning-tree vlan 2 port-priority 1 0 (将 VLAN2 的端口权
值设为 1 0)
2950(config-if)#spanning-tree vlan 2 cost 30 (设置 VLAN2 生成树路径
值为 30)
2
回答时间: 2010-12-6 21:51 | 我来评论
2950(config)#int vlan1
2950(config-if)#ip address 1 92.1 68.1 .1 00 255.255.255.0 (VLAN1 里面设置 IP
地址)
2950(config)#ip default-gateway 1 92.1 68.1 .1 (设置默认网关)
2950(config)#ip name-server 1 92.1 68.1.1 (设置域名服务器)
2950(config)#ip domain-name wqs.com (设置域名)
二、 端口配置
2950(config)#int f0/1 (进入接口)
2950(config-if)#speed 1 00 (设置该接口速率为 1 00Mb/s)
2950(config-if)#duplex ?
auto Enable AUTO duplex configuration
full Force full duplex operation
half Force half-duplex operation
2950(config-if)#description to_router1 (设置端口描述)
2950#show interfaces fastethernet1 [status] (查看端口配置结果和状态)
三、 MAC 地址表相关命令
2950(config)#mac-address-table aging-time 1 00 (设置
超时时间为 1 00S)
2950(config)#mac-address-table permanent 000.0c01 .bbcc f0/3
(加入永久地址)
2950(config)#mac-address-table restricted static 0000.0c02.bbcc f0/6 f0/7
(加入静态地址)
2950#show mac-address-table (查看整
个 MAC 地址表)
2950#clear mac-address-table restricted static (清除限制性
MAC 址表)
四、 VTP 的配置
2950#vlan database (进入 VLAN 配置模式)
2950(vlan)#vtp ? (查看 VTP 的子命令)
domain Set the name of the VTP administrative domain.
client Set the device to client mode.
server Set the device to server mode.
transparent Set the device to transparent mode.
password Set the password for the VTP administrative
domain.
2950(vlan)#vtp domain server (设置本交换机为 SEVER 模式)
2950(vlan)#vtp domain wqs (设置域名)
2950(vlan)#vtp pruning (启动修剪模式)
2950#show vtp status (查看 VTP 设置信息)
五、 配置 VLAN TRUNK 端口
2950(config)#int f0/1 1 (进入 F 端口)
2950(config-if)#switchport mode trunk (设置该端口为 TRUNK 模式)
2950(config-if)#switchport trunk encapsulation {dot1 q | isl | negotiate }(设置
TRUNK 封装)
六、 创建 VLAN
2950#vlan database (进入 VLAN 配置模式)
2950(vlan)#vlan 2 (创建 VLAN 2)
VLAN 2 added:
Name:VLAN0002 (系统默认名)
2950(vlan)#vlan 3 name wg_bisheng (创建 VLAN 3, 名为网工必胜)
VLAN 3 added:
Name:wg_bisheng
2950(config)#int f0/9 (进入接口配置模式)
2950(config-if)#switchport mode access (设置该接口为 ACCESS 模式)
2950(config-if)#switchport access vlan 2 (把端口 9 分配给 VLAN2)
2950(config-if)#int f0/8
2950(config-if)#switchport mode access
2950(config-if)#switchport access vlan 3
2950(config-if)#end
七、 生成树协议的配置
生成树负载均衡实现方法
1 使用 STP 端口权值实现。
2 使用 STP 路径值实现
2950(config)#int f0/1 1
2950(config-if)#spanning-tree vlan 2 port-priority 1 0 (将 VLAN2 的端口权值设
为 1 0)
2950(config-if)#spanning-tree vlan 2 cost 30 (设置 VLAN2 生成树路径值
为 30

发表于 2022-10-19 17:54:16 | 显示全部楼层
好东西谢谢楼主分享
沙发 2022-10-19 17:54:16 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2025-3-14 08:33:36 | 显示全部楼层
謝謝樓主分享
8# 2025-3-14 08:33:36 回复 收起回复
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2025-4-27 05:19 , Processed in 0.145104 second(s), 22 queries , Redis On.  

  Powered by Discuz!

  © 2001-2025 HH010.COM

快速回复 返回顶部 返回列表