思科交换机详细配置方法和命令

如题所述

思科交换机的基本配置命令学习
一、交换机口令设置:

switch>enable ;进入特权模式
switch#config terminal ;进入全局配置模式

switch(config)#hostname csico ;设置交换机的主机名
switch(config)#enable secret
csico1 ;设置特权加密口令
switch(config)#enable password csico8 ;设置特权非密口令

switch(config)#line console 0 ;进入控制台口
switch(config-line)#line vty 0 4
;进入虚拟终端
switch(config-line)#login ;虚拟终端允许登录
switch(config-line)#password
csico6 ;设置虚拟终端登录口令csico6
switch#exit ;返回命令

二、交换机显示命令:
switch#write ;保存配置信息

switch#show vtp ;查看vtp配置信息
switch#show run ;查看当前配置信息
switch#show
vlan ;查看vlan配置信息
switch#show interface ;查看端口信息
switch#show int f0/0
;查看指定端口信息
switch#show int f0/0 status;查看指定端口状态
switch#dir flash: ;查看闪存

Cisco路由器配置命令大全网络 2010-06-26 06:43:44 阅读657 评论0 字号:大中小 订阅 .

(1)模式转换命令
用户模式----特权模式,使用命令"enable"
特权模式----全局配置模式,使用命令"config
t"
全局配置模式----接口模式,使用命令"interface+接口类型+接口号"

全局配置模式----线控模式,使用命令"line+接口类型+接口号"
注:
用户模式:查看初始化的信息.

特权模式:查看所有信息、调试、保存配置信息
全局模式:配置所有信息、针对整个路由器或交换机的所有接口
接口模式:针对某一个接口的配置

线控模式:对路由器进行控制的接口配置
(2)配置命令
show running config 显示所有的配置
show
versin 显示版本号和寄存器值
shut down 关闭接口
no shutdown 打开接口
ip add +ip地址
配置IP地址
secondary+IP地址 为接口配置第二个IP地址
show interface+接口类型+接口号 查看接口管理性

show controllers interface 查看接口是否有DCE电缆
show history 查看历史记录
show
terminal 查看终端记录大小
hostname+主机名 配置路由器或交换机的标识
config memory
修改保存在NVRAM中的启动配置
exec timeout 0 0 设置控制台会话超时为0
service password-encryptin
手工加密所有密码
enable password +密码 配置明文密码
ena sec +密码 配置密文密码
line vty 0
4/15 进入telnet接口
password +密码 配置telnet密码
line aux 0 进入AUX接口
password
+密码 配置密码
line con 0 进入CON接口
password +密码 配置密码
bandwidth+数字 配置带宽

no ip address 删除已配置的IP地址
show startup config 查看NVRAM中的配置信息
copy
run-config atartup config 保存信息到NVRAM
write 保存信息到NVRAM
erase
startup-config 清除NVRAM中的配置信息
show ip interface brief 查看接口的谪要信息
banner
motd # +信息 + # 配置路由器或交换机的描素信息
description+信息 配置接口听描素信息
vlan database
进入VLAN数据库模式
vlan +vlan号+ 名称 创建VLAN
switchport access vlan +vlan号
为VLAN为配接口
interface vlan +vlan号 进入VLAN接口模式
ip add +ip地址 为VLAN配置管理IP地址

vtp+service/tracsparent/client 配置SW的VTP工作模式
vtp +domain+域名 配置SW的VTP域名

vtp +password +密码 配置SW的密码
switchport mode trunk 启用中继
no vlan +vlan号
删除VLAN
show spamming-tree vlan +vlan号 查看VLA怕生成树议

三. 路由器配置命令
ip
route+非直连网段+子网掩码+下一跳地址 配置静态/默认路由
show ip route 查看路由表
show protocols
显示出所有的被动路由协议和接口上哪些协议被设置
show ip protocols 显示了被配置在路由器上的路由选择协议,同时给出了在路由选择协议中使用

的定时器
等信息
router rip 激活RIP协议
network +直连网段 发布直连网段

interface lookback 0 激活逻辑接口
passive-interface +接口类型+接口号 配置接口为被动模式

debug ip +协议 动态查看路由更新信息
undebug all 关闭所有DEBUG信息
router eigrp +as号
激活EIGRP路由协议
network +网段+子网掩码 发布直连网段
show ip eigrp neighbors 查看邻居表

show ip eigrp topology 查看拓扑表
show ip eigrp traffic 查看发送包数量
router
ospf +process-ID 激活OSPF协议
network+直连网段+area+区域号 发布直连网段
show ip ospf
显示OSPF的进程号和ROUTER-ID
encapsulation+封装格式 更改封装格式
no ip admain-lookup
关闭路由器的域名查找
ip routing 在三层交换机上启用路由功能
show user 查看SW的在线用户
clear line
+线路号 清除线路

四. 三层交换机配置命令
配置一组二层端口
configure terminal 进入配置状态

nterface range {port-range} 进入组配置状态
配置三层端口
configure terminal 进入配置状态

interface {{fastethernet | gigabitethernet} interface-id} | {vlan vlan-id} |
{port-

channel port-channel-number} 进入端口配置状态
no switchport
把物理端口变成三层口
ip address ip_address subnet_mask 配置IP地址和掩码
no shutdown 激活端口

例:
Switch(config)# interface gigabitethernet0/2
Switch(config-if)#
no switchport
Switch(config-if)# ip address 192.20.135.21 255.255.255.0

Switch(config-if)# no shutdown
配置VLAN
configure terminal 进入配置状态

vlan vlan-id 输入一个VLAN号, 然后进入vlan配态,可以输入一个新的VLAN号或旧的来进行修改
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-08-06
CISCO交换机基本配置:Console端口连接

用户模式hostname# ;

特权模式hostname(config)# ;

全局配置模式hostname(config-if)# ;

交换机口令设置:

switch>enable ;进入特权模式

switch#config terminal ;进入全局配置模式

switch(config)#hostname csico ;设置交换机的主机名

switch(config)#enable secret csico1 ;设置特权加密口令

switch(config)#enable password csico8 ;设置特权非密口令

switch(config)#line console 0 ;进入控制台口

switch(config-line)#line vty 0 4 ;进入虚拟终端

switch(config-line)#login ;虚拟终端允许登录

switch(config-line)#password csico6 ;设置虚拟终端登录口令csico6

switch#exit ;返回命令

交换机VLAN创建,删除,端口属性的设置,配置trunk端口,将某端口加入vlan中,配置VTP:

switch#vlan database ;进入VLAN设置

switch(vlan)#vlan 2 ;建VLAN 2

switch(vlan)#vlan 3 name vlan3 ;建VLAN 3并命名为vlan3

switch(vlan)#no vlan 2 ;删vlan 2

switch(config)#int f0/1 ;进入端口1

switch(config)#speed ? 查看speed命令的子命令

switch(config)#speed 100 设置该端口速率为100mb/s (10/auto)

switch(config)#duplex ? 查看duplex的子命令

switch(config)#duplex full 设置该端口为全双工(auto/half)

switch(config)#description TO_PC1 这是该端口描述为TO_PC1

switch(config-if)#switchport access vlan 2 ;当前端口加入vlan 2

switch(config-if)#switchport mode trunk ;设置为trunk模式(access模式)

switch(config-if)#switchport trunk allowed vlan 1,2 ;设置允许的vlan

switch(config-if)#switchport trunk encap dot1q ;设置vlan 中继

switch(config)#vtp domain vtpserver ;设置vtp域名相同

switch(config)#vtp password ;设置发vtp密码

switch(config)#vtp server ;设置vtp服务器模式

switch(config)#vtp client ;设置vtp客户机模式

交换机设置IP地址,默认网关,域名,域名服务器,配置和查看MAC地址表:

switch(config)#interface vlan 1 ;进入vlan 1

switch(config-if)#ip address 192.168.1.1 255.255.255.0 ;设置IP地址

switch(config)#ip default-gateway 192.168.1.6 ;设置默认网关

switch(config)#ip domain-name cisco.com 设置域名

switch(config)#ip name-server 192.168.1.18 设置域名服务器

switch(config)#mac-address-table? 查看mac-address-table的子命令

switch(config)#mac-address-table aging-time 100 设置超时时间为100ms

switch(config)#mac-address-table permanent 0000.0c01.bbcc f0/3 加入永久地址在f0/3端口

switch(config)#mac-address-table restricted static 0000.0c02.bbcc f0/6 f0/7 加入静态地址目标端口f0/6源端口f0/7

switch(config)#end

switch#show mac-address-table 查看整个MAC地址表

switch#clear mac-address-table restricted static 清除限制性静态地址

交换机显示命令:

switch#write ;保存配置信息

switch#show vtp ;查看vtp配置信息

switch#show run ;查看当前配置信息

switch#show vlan ;查看vlan配置信息

switch#show interface ;查看端口信息

switch#show int f0/0 ;查看指定端口信息

switch#show int f0/0 status;查看指定端口状态

switch#dir flash: ;查看闪存

(1)模式转换命令

用户模式----特权模式,使用命令"enable"

特权模式----全局配置模式,使用命令"config t"

全局配置模式----接口模式,使用命令"interface+接口类型+接口号"

全局配置模式----线控模式,使用命令"line+接口类型+接口号"

注:

用户模式:查看初始化的信息.

特权模式:查看所有信息、调试、保存配置信息

全局模式:配置所有信息、针对整个路由器或交换机的所有接口

接口模式:针对某一个接口的配置

线控模式:对路由器进行控制的接口配置

(2)配置命令

show running config 显示所有的配置

show versin 显示版本号和寄存器值

shut down 关闭接口

no shutdown 打开接口

ip add +ip地址 配置IP地址

secondary+IP地址 为接口配置第二个IP地址

show interface+接口类型+接口号 查看接口管理性

show controllers interface 查看接口是否有DCE电缆

show history 查看历史记录

show terminal 查看终端记录大小

hostname+主机名 配置路由器或交换机的标识

config memory 修改保存在NVRAM中的启动配置

exec timeout 0 0 设置控制台会话超时为0

service password-encryptin 手工加密所有密码

enable password +密码 配置明文密码

ena sec +密码 配置密文密码

line vty 0 4/15 进入telnet接口

password +密码 配置telnet密码

line aux 0 进入AUX接口

password +密码 配置密码

line con 0 进入CON接口

password +密码 配置密码

bandwidth+数字 配置带宽

no ip address 删除已配置的IP地址

show startup config 查看NVRAM中的配置信息

copy run-config atartup config 保存信息到NVRAM

write 保存信息到NVRAM

erase startup-config 清除NVRAM中的配置信息

show ip interface brief 查看接口的谪要信息

banner motd # +信息 + # 配置路由器或交换机的描素信息

description+信息 配置接口听描素信息

vlan database 进入VLAN数据库模式

vlan +vlan号+ 名称 创建VLAN

switchport access vlan +vlan号 为VLAN为配接口

interface vlan +vlan号 进入VLAN接口模式

ip add +ip地址 为VLAN配置管理IP地址

vtp+service/tracsparent/client 配置SW的VTP工作模式

vtp +domain+域名 配置SW的VTP域名

vtp +password +密码 配置SW的密码

switchport mode trunk 启用中继

no vlan +vlan号 删除VLAN

show spamming-tree vlan +vlan号 查看VLA怕生成树议

3. 三层交换机配置命令

配置一组二层端口

configure terminal 进入配置状态

nterface range {port-range} 进入组配置状态

配置三层端口

configure terminal 进入配置状态

interface {{fastethernet | gigabitethernet} interface-id} | {vlan vlan-id} | {port-

channel port-channel-number} 进入端口配置状态

no switchport 把物理端口变成三层口

ip address ip_address subnet_mask 配置IP地址和掩码

no shutdown 激活端口

例:

Switch(config)# interface gigabitethernet0/2

Switch(config-if)# no switchport

Switch(config-if)# ip address 192.20.135.21 255.255.255.0

Switch(config-if)# no shutdown

配置VLAN

configure terminal 进入配置状态

vlan vlan-id 输入一个VLAN号, 然后进入vlan配态,可以输入一个新的VLAN号或旧的来进行修改

name vlan-name 可选)输入一个VLAN名,如果没有配置VLAN名,缺省的名字是VLAN号前面用0填满

的4位数,如VLAN0004是VLAN4的缺省名字

mtu mtu-size (可选) 改变MTU大小



Switch# configure terminal

Switch(config)# vlan 20

Switch(config-vlan)# name test20

Switch(config-vlan)# end



Switch# vlan database

Switch(vlan)# vlan 20 name test20

Switch(vlan)# exit

将端口分配给一个VLAN

configure terminal 进入配置状态

interface interface-id 进入要分配的端口

switchport mode access 定义二层口

switchport access vlan vlan-id 把端口分配给某一VLAN



Switch# configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)# interface fastethernet0/1

Switch(config-if)# switchport mode access

Switch(config-if)# switchport access vlan 2

Switch(config-if)# end

Switch#

配置VLAN trunk

configure terminal 进入配置状态

interface interface-Id 进入端口配置状态

switchport trunk encapsulation {isl | dot1q | negotiate}配置trunk封装ISL 或 802.1Q 或
第2个回答  2010-12-07
说说你需要配置什么
第3个回答  2010-12-07
楼上认真。

到我空间看看。 交换机和路由比较全了。
第4个回答  2010-12-06
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 dot1q 2(设置封装类型为dot1q,它是思科特有的。此外还有isl封装,要看该设备支不支持。数字2是vlan号)
router(config-subif)#ip address 192.168.1.1 255.255.255.0
router(config-subif)#exit
router(config)#interface f0/0.2
router(config-subif)#encapsulation dot1q 4
router(config-subif)#ip address 192.168.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 qycx123 v1
Switch(config)#snmp-server group qycx 123 v2c
Switch(config)#snmp-server group qycx123 v3 noauth
b、分别配置只读和可写community 如:
Switch(config)#snmp-server community qycx123 ro
Switch(config)#snmp-server community qycx123 rw
4、保存交换机配置
Switch#copy run start

常用命令

1、设置交换机密码
a、更改远程TELNNET密码
Switch#configure terminal
Switch(config)#line vty 0 4
Switch(config-line)#password qycx123
Switch(config-line)#login
Switch(config-line)#exit
b、更改进入全局配置模式时的密码
Switch#configure terminal
Switch(config)#enable secret qycx123
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 192.168.1.100 255.255.255.0 (VLAN1里面设置IP地址)

2950(config)#ip default-gateway 192.168.1.1 (设置默认网关)

2950(config)#ip name-server 192.168.1.1 (设置域名服务器)

2950(config)#ip domain-name wqs.com (设置域名)

二、端口配置

2950(config)#int f0/1 (进入接口)

2950(config-if)#speed 100 (设置该接口速率为100Mb/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 100 (设置超时时间为100S)

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/11 (进入F端口)

2950(config-if)#switchport mode trunk (设置该端口为TRUNK模式)

2950(config-if)#switchport trunk encapsulation {dot1q | 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/11

2950(config-if)#spanning-tree vlan 2 port-priority 10 (将VLAN2的端口权值设为10)

2950(config-if)#spanning-tree vlan 2 cost 30 (设置VLAN2生成树路径值为30)本回答被提问者采纳