路由器交换机命令.docx
《路由器交换机命令.docx》由会员分享,可在线阅读,更多相关《路由器交换机命令.docx(18页珍藏版)》请在冰豆网上搜索。
![路由器交换机命令.docx](https://file1.bdocx.com/fileroot1/2023-1/28/26699cad-fed4-495d-b393-2f78a271f8f8/26699cad-fed4-495d-b393-2f78a271f8f81.gif)
路由器交换机命令
1、查看交换表
showcamdynamic(大型交换机)
showcamip-address-table(小型交换机)
2、启动httpserver
switch-3548>enable
password:
switch-3548#configt
switch-3548(config)#
switch-3548(config)#iphttpserver
switch-6500>enable
Enterpassword:
switch-6500>(enable)setiphttpserverenable
switch-6500>(enable)
3、配置交换机主机名
switch-3548(config)#hostnameswitch-PHY-3548
switch-PHY-3548(config)#
switch-6500>(enable)setsystemnameswitch-PHY-6500
systemnameset
switch-PHY-6500>(enable)
4、设置系统提示
switch-6500>(enable)setsystempromptswitch-PHY-6500>
switch-6500>(enable)
5、配置超级用户口令
switch-3548(config)#enablesecret5zzz(加密口令)
switch-3548(config)#enablepasswordzzz(明码口令)
switch-3548(config)#enablepassword7zzz(加密口令)
switch-PHY-3548(config)#
switch-PHY-6500>setenablepass
Enteroldpasswoed:
Enternewpassword:
Retypenewpassword:
Passwordchanged.
switch-PHY-6500>(enable)
6、配置远程登录口令
switch-PHY-3548(config)#linevty04
switch-PHY-3548(config-line)#password7zzz(加密口令)
switch-PHY-3548(config-line)#password0zzz(明码口令)
switch-PHY-3548(config-line)#
switch-6500>(enable)setpassword
Enteroldpassword:
Enternewpassword:
Retypenewpassword:
switch-6500>(enable)
7、改变系统时间
switch-PHY-3548(config)#clockset23:
00:
0023February2007
switch-PHY-6500>settimeFri23/2/200723:
00:
00
8、配置设备管理地址(IP地址)
switch-PHY-3548(config)#interfaceVLAN1
switch-PHY-3548(config-if)#ipaddress<子网掩码>
switch-PHY-3548(config-if)#
switch-PHY-6500>(enable)setinterfacesc0<子网掩码><广播地址>
switch-PHY-6500>(enable)
9、配置缺省路由
switch-PHY-3548(config)#ipdefault-gateway<默认网关地址>
switch-PHY-3548(config)#
switch-PHY-6500>(enable)setiprouter0、0、0、0<默认网关地址>
switch-PHY-6500>(enable)
10、进入端口配置模式
switch-PHY-3548(config)#interfacef0/24
switch-PHY-3548(config-if)#
11、配置交换机端口描述
switch-PHY-3548(config-if)#descriptionTo-lib
switch-PHY-3548(config-if)#
switch-PHY-6500>(enable)setportname4/5mail-server
switch-PHY-6500>(enable)
12、配置交换机端口的关闭与开启
switch-PHY-3548(config-if)#shoudown(关闭端口)
switch-PHY-3548(config-if)#noshoudown(开启端口)
switch-PHY-3548(config-if)#
switch-PHY-6500>(enable)setportenable4/5(开启端口)
switch-PHY-6500>(enable)setportdisable4/5(关闭端口)
13、配置交换机端口的通信方式
switch-PHY-3548(config-if)#duplexauto(缺省值为自适应)
switch-PHY-3548(config-if)#duplexfull(设置为全双工)
switch-PHY-3548(config-if)#duplexhalf(设置为半双工)
switch-PHY-3548(config-if)#
switch-PHY-6500>(enable)setportduplex5/1full(设置为全双工)
switch-PHY-6500>(enable)setportduplex5/1-24full
switch-PHY-6500>(enable)setportduplex5/1half(设置为全双工)
switch-PHY-6500>(enable)setportduplex5/1-24half
14、配置交换机端口的传输速率
switch-PHY-3548(config-if)#speed10(设置为10Mbps)
switch-PHY-3548(config-if)#speed100(设置为100Mbps)
switch-PHY-3548(config-if)#speedauto(设置为自动速率配置)
switch-PHY-6500>(enable)setportspeed5/1auto(设置为自动速率配置)
switch-PHY-6500>(enable)setportspeed5/1-24auto
switch-PHY-6500>(enable)setportspeed5/110(设置为10Mbps)
switch-PHY-6500>(enable)setportspeed5/1100(设置为100Mbps)
switch-PHY-6500>(enable)setportspeed5/11000(设置为1000Mbps)
15、交换机VTP的配置
switch-PHY-3548(config)#vtpdomainpku(设置vtp域名为pku)
switch-PHY-3548(config)#vtpmodeserver(设置为vtpserver模式)
switch-PHY-3548(config)#vtpmodeclient(设置为vtpclient模式)
switch-PHY-3548(config)#vtpmodeTransparent(设置为vtpTransparent模式)
switch-PHY-3548(config)#
switch-PHY-6500>(enable)setvtpdomainpku(设置vtp域名为pku)
switch-PHY-6500>(enable)setvtpmodeserver(设置为vtpserver模式)
switch-PHY-6500>(enable)setvtpmodeclient(设置为vtpclient模式)
switch-PHY-6500>(enable)setvtpmodeTransparent(设置为vtpTransparent模式)
switch-PHY-6500>(enable)setvtpmodeoff(VTP关闭)
switch-PHY-6500>(enable)
16、进入VLAN配置模式
switch-PHY-3548#vlandata
switch-PHY-3548(vlan)#
17、建立、删除vlan
switch-PHY-3548(vlan)#vlan1000namevlan1000(建立、修改VLAN)
switch-PHY-3548(vlan)#
switch-PHY-3548(vlan)#novlan1000(删除VLAN)
switch-PHY-3548(vlan)#
switch-PHY-6500>(enable)setvlan999namevlan999(建立、修改VLAN)
switch-PHY-6500>(enable)
switch-PHY-6500>(enable)clearvlan999(删除VLAN)
Doyouwanttocontinue(y/n)[n]?
y
switch-PHY-6500>(enable)
18、进入交换机端口配置模式
switch-PHY-3548#configuret
switch-PHY-3548(config)#intf0/24
switch-PHY-3548(config-if)#
19、为交换机端口分配VLAN
switch-PHY-3548(config-if)#switchportaccessvlan248(端口f0/24在248号vlan)
switch-PHY-3548(config-if)#
switch-PHY-6500>(enable)setvlan425/20(将端口5/20划分在42号vlan中)
switch-PHY-6500>(enable)
20、配置VLANTrunk
switch-PHY-3548(config-if)#switchportmodetrunk
switch-PHY-3548(config-if)#switchporttrunkencapsulationdot1q(802.1)
switch-PHY-3548(config-if)#switchporttrunkencapsulationisl(isl)
switch-PHY-3548(config-if)#switchporttrunkencapsulationnegotiateP(自动协商)
switch-PHY-3548(config-if)#
switch-PHY-3548(config-if)#switchporttrunkallowedvlan10-24(10-24中继)
switch-PHY-3548(config-if)#switchporttrunkallowedvlanexcept100-1000
switch-PHY-3548(config-if)#(“except100-1000”除100-1000号VLAN以外,所有允许)
switch-PHY-6500>(enable)settrunk5/1ondot1qPort(s)1/2trunkmodesettoon.
(设置端口5/1为VLANTrunk模式,封装802.1协议)
switch-PHY-6500>(enable)cleartrunk5/243-36(从端口5/24允许删除3-36号vlan)
21、打开或关闭STP
switch-PHY-3548(config)#spanning-treevlan3(启用STP)
switch-PHY-3548(config)#nospanning-treevlan3(关闭STP)
switch-PHY-3548(config)#
switch-PHY-6500>(enable)setspantreeenable3(启用STP)
switch-PHY-6500>(enable)setspantreedisable3(关闭STP)
switch-PHY-6500>(enable)
22、配置根网桥和备份根网桥
switch-PHY-3548(config)#spanning-treevlan3rootprimary(设置主root)
switch-PHY-3548(config)#spanning-treevlan3rootsecondry(设置备份网桥)
switch-PHY-3548(config)#
switch-PHY-6500>(enable)setspantreeroot1,200-204(设置主root)
switch-PHY-6500>(enable)setspantreerootsecondry1,200-204(设置备份网桥)
23、设置生成树优先级
switch-PHY-3548(config)#spanning-treevlan3priority8192
switch-PHY-3548(config)#
switch-PHY-6500>(enable)setspantreepriority8192
switch-PHY-6500>(enable)
24、配置BackboneFast生成树可选功能
switch-PHY-3548(config)#spanning-treebackbonefast(允许backbonefast)
switch-PHY-3548(config)#
switch-PHY-6500>(enable)setspantreebackbonefastenable(允许backbonefast)
switch-PHY-6500>(enable)setspantreebackbonefastdisable(不允许backbonefast)
25、Uplinkfast设置
switch-PHY-3548(config)#spanning-treeuplinkfast
switch-PHY-3548(config)#spanning-treeuplinkfastmax-updata-rate3200
switch-PHY-3548(config)#
max-updata-rate的值是0-32000,单位是packet/s(每秒更新的包数)
switch-PHY-6500>(enable)setspantreeuplinkfastenable
switch-PHY-6500>(enable)setspantreeuplinkfastenablerate40
switch-PHY-6500>(enable)
rate的缺省值是15packets/100ms
26、配置PortFast生成树可选功能
switch-PHY-3548(config)#spanning-treeportfastdefault
switch-PHY-3548(config)#
switch-PHY-6500>(enable)setspantreeportfast3/2enable(打开portfast)
switch-PHY-6500>(enable)setspantreeportfast4/1-24disable(关闭portfast)
switch-PHY-6500>(enable)setspantreeportfast3/2default(缺省启用portfast)
27、被指BPDU生成树可选功能
switch-PHY-3548(config)#spanning-treeportfastbpdufilterdefault
switch-PHY-3548(config)#
switch-PHY-6500>(enable)setspantreeportfastbpdu-filterenable
(所有端口启用bpdu-filter)
switch-PHY-6500>(enable)setspantreeportfastbpdu-filterdisable
(所有端口关闭bpdu-filter)
switch-PHY-6500>(enable)setspantreeportfastbpdu-filter3/1-24enable
(3/1-24端口启用bpdu-filter)
switch-PHY-6500>(enable)setspantreeportfastbpdu-filter3/1-24disable
(3/1-24端口关闭bpdu-filter)
1、进入路由器模式
用户模式:
Router>进入用户模式telnet<路由器ip>
特权模式:
Router>password:
Router#
全局配置模式:
Router#configureterminal
Router(config)#
接口配置模式:
Router(config)#intf0/12
Router(config)#
进入虚拟终端配置模式
Router(config)#linevty015
Router(config-line)#
进入RIP路由协议配置模式
Router(config)#routerip
Router(config-router)#
2、在虚拟终端上配置远程登录密码
Router(config)#linevty015
Router(config-line)#password7zzz307
Router(config-line)#
3、拷贝配置文件到TFTPserver
Router#writenetwork
Remotehost[]?
Router#
4、拷贝running-config到TFTPserver
Router#copyrunning-configtftp:
Addressornameofremotehost[]?
<输入TFTPserver的ip地址>
Destinationfilename[Router-config]?
<输入文件名>
!
!
!
3519bytescopiedin3.368secs(1066bytes/sec)
Router#
5、拷贝bootflash中的配置文件到TFTPserver
Router#copybootflash:
tftp:
Sourcefilename[]?
<文件名>
Addressornameofremotehost[]?
Destnationfilename[config.txt]?
config.txt
!
!
!
23584bytescopiedin0.144secs(163778bytes/sec)
Router#
6、从TFTPserver上的配置文件拷贝到running-config
Router#copytftp:
running-config
Addressornameofremotehost[]?
<目的ip地址>
Sourcefilename[]?
1383-wireless-config(输入文件名)
Destinationfilename[running-config]?
Router#
7、将TFTPserver上的配置文件拷贝到bootflash
Router#copytftp:
bootflash:
Addressornameofremotehost[]?
<目的ip地址>
Sourcefilename[]?
config.txt
Destinationfilename[config.txt]?
Router#
8、配置路由器的主机名
Router(config)#hostnameRouter-phy
Router-phy(config)#
9、配置超级用户口令
Router(config)#enablesecretphy123
Router(config)#enablepassword7phy123
Router(config)#
10、设置系统时钟
Router#calendarset10:
24:
0022march2007
Router#
11、保存配置到路由器的NVRAM中:
Router#writememory
12、保存配置到TFTP服务器中:
Router#writenetworktftp
13、删除路由器全部配置:
Router#writeerase
14、查看每一级路由器工作情况:
Router>trace
15、查看flash:
Router>showflash
16、查看系统时钟:
Router>shclock
17、查看路由器软、硬件版本:
Router>shversion
18、查看路由器的配置:
Router#shconfiguration
19、查看路由表:
Router#shiprouter
20、查看ip路由协议的详细信息:
Router#shipprotocols
21、配置接口描述信息:
Router(config)#intg6/0
Router(config-if)#descriptionTO-BeijingForeignStudiesUniversity
Router(config-if)#
22、配置接口带宽:
Router(config)#interfacePOS3/0
Router(config-if)#bandwidth2500000(设置为2.5G)
23、配置接口的IP地址
Router(config)#interfacef2/3
Router(config-if)#ipaddress<子网掩码>
24、接口开启与关闭
Router(config)#interfacef2/3
Router(config-if)#shoudown(关闭接口)
Router(config-if)#noshoudown(开启接口)
25、配置标准的以太网接口(Enthrnet),简写e
Router(config)#interfaceEnthrnet0
Router(config-if)#descriptionToHuabeiQiQiuWANG
Router(config-if)#ipaddress202.112.7.4255.255.255.0
Router(config-if)#ba