思科交换机基本命令(全)
- 格式:doc
- 大小:63.00 KB
- 文档页数:8
1. 交换机支持的命令:交换机基本状态:交换机口令设置:交换机VLAN设置:交换机设置IP地址:交换机显示命令:2. 路由器支持的命令:路由器显示命令:路由器口令设置:路由器配置:路由器文件操作:静态路由:动态路由:帧中继命令:基本访问控制列表:删除访问控制例表:router(config)#no access-list 102router(config-if)#no ip access-group 101 in 路由器的nat配置外部网关协议配置:配置PPP验证:3.PIX防火墙命令1. 交换机支持的命令:交换机基本状态:switch: ;ROM状态,路由器是rommon>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 ;返回命令交换机VLAN设置:switch#vlan database ;进入VLAN设置switch(vlan)#vlan 2 ;建VLAN 2switch(vlan)#no vlan 2 ;删vlan 2switch(config)#int f0/1 ;进入端口1switch(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 dot1q ;设置vlan 中继switch(config)#vtp domain ;设置发vtp域名switch(config)#vtp password ;设置发vtp密码switch(config)#vtp mode server ;设置发vtp模式switch(config)#vtp mode client ;设置发vtp模式交换机设置IP地址:switch(config)#interface vlan 1 ;进入vlan 1switch(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 ;查看指定端口信息2. 路由器支持的命令:路由器显示命令:router#show run ;显示配置信息router#show interface ;显示接口信息router#show ip route ;显示路由信息router#show cdp nei ;显示邻居信息router#reload ;重新起动路由器口令设置:router>enable ;进入特权模式router#config terminal ;进入全局配置模式router(config)#hostname ;设置交换机的主机名router(config)#enable secret xxx ;设置特权加密口令router(config)#enable password xxb ;设置特权非密口令router(config)#line console 0 ;进入控制台口router(config-line)#line vty 0 4 ;进入虚拟终端router(config-line)#login ;要求口令验证router(config-line)#password xx ;设置登录口令xxrouter(config)#(Ctrl+z) ;返回特权模式router#exit ;返回命令路由器配置:router(config)#int s0/0 ;进入Serail接口router(config-if)#no shutdown ;激活当前接口router(config-if)#clock rate 64000 ;设置同步时钟router(config-if)#ip address ;设置IP地址router(config-if)#ip address second ;设置第二个IProuter(config-if)#int f0/0.1 ;进入子接口router(config-subif.1)#ip address ;设置子接口IProuter(config-subif.1)#encapsulation dot1q ;绑定vlan中继协议router(config)#config-register 0x2142 ;跳过配置文件router(config)#config-register 0x2102 ;正常使用配置文件router#reload ;重新引导路由器文件操作:router#copy running-config startup-config ;保存配置router#copy running-config tftp ;保存配置到tftprouter#copy startup-config tftp ;开机配置存到tftprouter#copy tftp flash: ;下传文件到flashrouter#copy tftp startup-config;下载配置文件ROM状态:Ctrl+Break ;进入ROM监控状态rommon>confreg 0x2142 ;跳过配置文件rommon>confreg 0x2102 ;恢复配置文件rommon>reset ;重新引导rommon>copy xmodem: flash: ;从console传输文件rommon>IP_ADDRESS=10.65.1.2 ;设置路由器IPrommon>IP_SUBNET_MASK=255.255.0.0 ;设置路由器掩码rommon>TFTP_SERVER=10.65.1.1 ;指定TFTP服务器IPrommon>TFTP_FILE=c2600.bin ;指定下载的文件rommon>tftpdnld ;从tftp下载rommon>dir flash: ;查看闪存内容rommon>boot ;引导IOS静态路由:ip route ;命令格式router(config)#ip route 2.0.0.0 255.0.0.0 1.1.1.2 ;静态路由举例router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2 ;默认路由举例动态路由:router(config)#ip routing ;启动路由转发router(config)#router rip ;启动RIP路由协议。
Cisco思科光纤交换机配置常用命令介绍交换机除了能够连接同种类型的网络之外,还可以在不同类型的网络(如以太网和快速以太网)之间起到互连作用。
你还在为不知道Cisco思科光纤交换机配置说明而烦恼么?下面小编为大家收集的Cisco思科光纤交换机配置说明教程,希望能帮到大家,一起来看看吧!Cisco思科光纤交换机配置说明的方法1. 初始化信息首次设置,必须通过console进行连接(需要U口转DB9针的接口线,专门卖接口线的有卖大约30元),然后进行初始化设计,以后设定IP后可通过LAN进行登陆具体步骤:(红色字体部分着重注意,需要进行设置,大部分按照默认设置即可,而且设置的部分进入管理工具软件可以更改) ---- System Admin Account Setup ----Enter the password for "admin": passwordConfirm the password for "admin": password--- Basic System Configuration Dialog ---This setup utility will guide you through the basic configuration of the system. Setup configures only enough connectivity for management of the system.Press Enter at any time to skip any dialog. Use ctrl-c at anytime to skip the remaining dialogs.Would you like to enter the basic configuration dialog (yes/no): yCreate another login account (yes/no) [n]:Configure read-only SNMP community string (yes/no) [n]:Configure read-write SNMP community string (yes/no) [n]: Enter the switch name: Pxx-MDS-x (where xx is your pod number and x is the switch number; for example:P01-MDS-1) Continue with Out-of-band (mgmt0) managementconfiguration? (yes/no) [y]:Mgmt0 IPv4 address : <10.0.x.y> (where x is your pod number and y is 5 for MDS-1 and 3 for MDS-2)(客户)0.16 Mgmt0 IPv4 netmask : 255.255.255.0Configure the default gateway? (yes/no) [y]:IPv4 address of the default gateway : 10.0.x.254 (where x is your pod number)Configure advanced IP options? (yes/no) [n]:Enable the telnet service? (yes/no) [y]:Enable the ssh service? (yes/no) [n]:Configure the ntp server? (yes/no) [n]:Configure default switchport interface state (shut/noshut) [shut]: (注意一下)noshutConfigure default switchport trunk mode (on/off/auto) [on]: Configure default zone policy (permit/deny) [deny]:Enable full zoneset distribution (yes/no) [n]:NOTE:初始设定的配置对新的VSAN起作用,即原始VSAN1无这些配置解决办法:1 zone default-zone permit VSAN2 新建 NEW VSAN2 将port转移VSAN2里面。
思科、华为全系列交换机路由器常用命令交换机/路由器配置综合复习交换机/路由器常用命令汇总/sxjd/network本课内容交换机常用命令路由器常用命令2·>Enable 进入特权模式··#Exit#End返回上一级操作模式返回到特权模式·#write memory 或copy running-config startup-config 保存配置文件·#del flash:config.text 删除配置文件(交换机及1700系列路由器)·#del flash:vlan.dat 删除Vlan配置信息(交换机)·(config)# hostname switchA 配置设备名称为switchA 4·(config)#enable secret level 1 0 star配置远程登陆密码为star·(config)#enable secret level 15 0 star 配置特权密码为star·Level 1为普通用户级别,可选为1~15,15为最高权限级别;0表示密码不加密·(config)#enable services web-server 开启交换机WEB管理功能·Services 可选以下:web-server(WEB管理)、telnet-server(远程登陆)等5查看信息·#show running-config查看当前生效的配置信息·#show interface fastethernet 0/3 查看F0/3端口信息·#show interface serial 1/2 查看S1/2端口信息·#show interface 查看所有端口信息·#show ip interface brief 以简洁方式汇总查看所有端口信息·#show ip interface 查看所有端口信息·#show version 查看版本信息6查看信息·#show mac-address-table 查看交换机当前MAC 地址表信息·#show running-config 查看当前生效的配置信息··#show vlan#show vlan id 10查看所有VLAN信息查看某一VLAN (如VLAN10)的信息·#show interface fastethernet 0/1 switchport 查看某一端口模式(如F 0/1)·#show aggregateport 1 summary 查看聚合端口AG1的信息7查看信息·#show spanning-tree 查看生成树配置信息·#show spanning-tree interface fastethernet 0/1 查看该端口的生成树状态·#show port-security 查看交换机的端口安全配置信息·#show port-security address 查看地址安全绑定配置信息·#show ip access-lists listname 查看名为listname的列表的配置信息·#show access-lists 8端口的基本配置·(config)#Interface fastethernet 0/3 进入F0/3的端口配置模式·(config)#interface range fa 0/1-2,0/5,0/7- 9 进入F0/1、F0/2、F0/5、F0/7、F0/8、F0/9的端口配置模式·(config-if)#speed 10 配置端口速率为10M,可选10,100,auto9端口的基本配置·(config-if)#duplex full 配置端口为全双工模式,可选full(全双工),half(半双式),auto(自适应)··(config-if)#no shutdown 开启该端口(config-if)#switchport access vlan 10 将该端口划入VLAN10中,用于VLAN·(config-if)#switchport mode trunk将该端口设为trunk模式, 可选模式为access , trunk ·(config-if)#port-group 1 将该端口划入聚合端口AG1中,用于聚合端口10聚合端口的创建·(config)# interface aggregateport 1 创建聚合接口AG1·(config-if)# switchport mode trunk 配置并保证AG1为 trunk 模式·(config)#int f0/23-24·(config-if-range)#port-group 1 将端口(端口组)划入聚合端口AG1中11生成树·(config)#spanning-tree 开启生成树协议·(config)#spanning-tree mode stp 指定生成树类型为stp可选模式stp , rstp , mstp·(config)#spanning-tree priority 4096 设置交换机的优先级为4096 , 优先级值小为高。
CISCO思科交换机3650G配置命令⼤全CISCO思科交换机3650G配置命令⼤全1.在基于IOS的交换机上设置主机名/系统名: switch(config)# hostname hostname在基于CLI的交换机上设置主机名/系统名: switch(enable) set system name name-string 2.在基于IOS的交换机上设置登录⼝令:switch(config)# enable password level 1 password 在基于CLI的交换机上设置登录⼝令: switch(enable) set password switch(enable) set enalbepass3.在基于IOS的交换机上设置远程访问: switch(config)# interface vlan 1switch(config-if)# ip address ip-address netmask switch(config-if)# ip default-gateway ip-address 在基于CLI的交换机上设置远程访问:switch(enable) set interface sc0 ip-address netmask broadcast-address switch(enable) set interface sc0 vlanswitch(enable) set ip route default gateway 4.在基于IOS的交换机上启⽤和浏览CDP信息: switch(config-if)# cdp enable switch(config-if)# no cdp enable为了查看Cisco邻接设备的CDP通告信息:switch# show cdp interface [type modle/port]switch# show cdp neighbors [type module/port] [detail] 在基于CLI的交换机上启⽤和浏览CDP信息:switch(enable) set cdp {enable|disable} module/port 为了查看Cisco邻接设备的CDP通告信息:switch(enable) show cdp neighbors[module/port] [vlan|duplex|capabilities|detail] 5.基于IOS的交换机的端⼝描述:switch(config-if)# description description-string 基于CLI的交换机的端⼝描述:switch(enable)set port name module/number description-string 6.在基于IOS的交换机上设置端⼝速度: switch(config-if)# speed{10|100|auto} 在基于CLI的交换机上设置端⼝速度: switch(enable) set port speed moudle/number {10|100|auto} switch(enable) set port speed moudle/number {4|16|auto} 7.在基于IOS的交换机上设置以太⽹的链路模式: switch(config-if)# duplex {auto|full|half} 在基于CLI的交换机上设置以太⽹的链路模式:switch(enable) set port duplex module/number {full|half} 8.在基于IOS的交换机上配置静态VLAN: switch# vlan databaseswitch(vlan)# vlan vlan-num name vlaswitch(vlan)# exitswitch# configure teriminalswitch(config)# interface interface module/number switch(config-if)# switchport mode accessswitch(config-if)# switchport access vlan vlan-num switch(config-if)# end在基于CLI的交换机上配置静态VLAN:switch(enable) set vlan vlan-num [name name]switch(enable) set vlan vlan-num mod-num/port-list 9. 在基于IOS的交换机上配置VLAN中继线:switch(config)# interface interface mod/port switch(config-if)# switchport mode trunkswitch(config-if)# switchport trunk encapsulation {isl|dotlq} switch(config-if)# switchport trunk allowed vlan remove vlan-list switch(config-if)# switchport trunk allowed vlan add vlan-list 在基于CLI的交换机上配置VLAN中继线:switch(enable) set trunk module/port [on|off|desirable|auto|nonegotiate] Vlan-range [isl|dotlq|dotl0|lane|negotiate] 10.在基于IOS的交换机上配置VTP管理域: switch# vlan database switch(vlan)# vtp domain domain-name 在基于CLI的交换机上配置VTP管理域:switch(enable) set vtp [domain domain-name] 11.在基于IOS的交换机上配置VTP 模式: switch# vlan databaseswitch(vlan)# vtp domain domain-nameswitch(vlan)# vtp {sever|cilent|transparent} switch(vlan)# vtp password password 在基于CLI的交换机上配置VTP 模式: switch(enable) set vtp [domain domain-name] [mode{ sever|cilent|transparent }][password password] 12. 在基于IOS的交换机上配置VTP版本: switch# vlan database switch(vlan)# vtp v2-mode在基于CLI的交换机上配置VTP版本: switch(enable) set vtp v2 enable13. 在基于IOS的交换机上启动VTP剪裁: switch# vlan database switch(vlan)# vtp pruning在基于CL I 的交换机上启动VTP剪裁: switch(enable) set vtp pruning enable 14.在基于IOS的交换机上配置以太信道:switch(config-if)# port group group-number [distribution {source|destination}] 在基于CLI的交换机上配置以太信道:switch(enable) set port channel moudle/port-range mode{on|off|desirable|auto} 15.在基于IOS的交换机上调整根路径成本:switch(config-if)# spanning-tree [vlan vlan-list] cost cost 在基于CLI的交换机上调整根路径成本:switch(enable) set spantree portcost moudle/port costswitch(enable) set spantree portvlancost moudle/port [cost cost][vlan-list] 16.在基于IOS的交换机上调整端⼝ID:switch(config-if)# spanning-tree[vlan vlan-list]port-priority port-priority 在基于CLI的交换机上调整端⼝ID:switch(enable) set spantree portpri {mldule/port}priorityswitch(enable) set spantree portvlanpri {module/port}priority [vlans] 17. 在基于IOS的交换机上修改STP时钟:switch(config)# spanning-tree [vlan vlan-list] hello-time seconds switch(config)# spanning-tree [vlan vlan-list] forward-time seconds ` switch(config)# spanning-tree [vlan vlan-list] max-age seconds 在基于CLI的交换机上修改STP时钟:switch(enable) set spantree hello interval[vlan] switch(enable) set spantree fwddelay delay [vlan] switch(enable) set spantree maxage agingtiame[vlan] 18. 在基于IOS的交换机端⼝上启⽤或禁⽤Port Fast 特征: switch(config-if)#spanning-tree portfast在基于CLI的交换机端⼝上启⽤或禁⽤Port Fast 特征:switch(enable) set spantree portfast {module/port}{enable|disable} 19. 在基于IOS的交换机端⼝上启⽤或禁⽤UplinkFast 特征:switch(config)# spanning-tree uplinkfast [max-update-rate pkts-per-second] 在基于CLI的交换机端⼝上启⽤或禁⽤UplinkFast 特征:switch(enable) set spantree uplinkfast {enable|disable}[rate update-rate] [all-protocols off|on]20. 为了将交换机配置成⼀个集群的命令交换机,⾸先要给管理接⼝分配⼀个IP地址,然后使⽤下列命令: switch(config)# cluster enable cluster-name 21. 为了从⼀条中继链路上删除VLAN,可使⽤下列命令: switch(enable) clear trunk module/port vlan-range 22. ⽤show vtp domain 显⽰管理域的VTP参数. 23. ⽤show vtp statistics显⽰管理域的VTP参数. 24. 在Catalyst交换机上定义TrBRF的命令如下:switch(enable) set vlan vlan-name [name name] type trbrf bridge bridge-num[stp {ieee|ibm}]25. 在Catalyst交换机上定义TrCRF的命令如下:switch (enable) set vlan vlan-num [name name] type trcrf {ring hex-ring-num|decring decimal-ring-num} parent vlan-num26. 在创建好TrBRF VLAN之后,就可以给它分配交换机端⼝.对于以太⽹交换,可以采⽤如下命令给VLAN分配端⼝:switch(enable) set vlan vlan-num mod-num/port-num 27. 命令show spantree显⽰⼀个交换机端⼝的STP状态.28. 配置⼀个ELAN的LES和BUS,可以使⽤下列命令:ATM (config)# interface atm number.subint multioint ATM(config-subif)# lane serber-bus ethernet elan-name 29. 配置LECS:ATM(config)# lane database database-nameATM(lane-config-databade)# name elan1-name server-atm-address les1-nsap-address ATM(lane-config-databade)# name elan2-name server-atm-address les2-nsap-address ATM(lane-config-databade)# name …30. 创建完数据库后,必须在主接⼝上启动LECS.命令如下: ATM(config)# interface atm numberATM(config-if)# lane config database database-name ATM(config-if)# lane config auto-config-atm-address 31. 将每个LEC配置到⼀个不同的ATM⼦接⼝上.命令如下: ATM(config)# interface atm number.subint multipoint ATM(config)# lane client ethernet vlan-num elan-num 32. ⽤show lane server 显⽰LES的状态. 33. ⽤show lane bus显⽰bus的状态.34. ⽤show lane database显⽰LECS数据库可内容. 35. ⽤show lane client显⽰LEC的状态. 36. ⽤show module显⽰已安装的模块列表. 37. ⽤物理接⼝建⽴与VLAN的连接: router# configure terminalrouter(config)# interface media module/portrouter(config-if)# description description-string router(config-if)# ip address ip-addr subnet-mask router(config-if)# no shutdown 38. ⽤中继链路来建⽴与VLAN的连接:router(config)# interface module/port.subinterfacerouter(config-ig)# encapsulation[isl|dotlq] vlan-number router(config-if)# ip address ip-address subnet-mask 39. ⽤LANE 来建⽴与VLAN的连接:router(config)# interface atm module/port router(config-if)# no ip addressrouter(config-if)# atm pvc 1 0 5 qsaal router(config-if)# atm pvc 2 0 16 ilnirouter(config-if)# interface atm module/port.subinterface multipoint router(config-if)# ip address ip-address subnet-mask router(config-if)# lane client ethernet elan-numrouter(config-if)# interface atm module/port.subinterface multipoint router(config-if)# ip address ip-address subnet-name router(config-if)# lane client ethernet elan-name router(config-if)# …40. 为了在路由处理器上进⾏动态路由配置,可以⽤下列IOS命令来进⾏: router(config)# ip routingrouter(config)# router ip-routing-protocolrouter(config-router)# network ip-network-number router(config-router)# network ip-network-number 41. 配置默认路由:switch(enable) set ip route default gateway42. 为⼀个路由处理器分配VLANID,可在接⼝模式下使⽤下列命令: router(config)# interface interface number router(config-if)# mls rp vlan-id vlan-id-num 43. 在路由处理器启⽤MLSP: router(config)# mls rp ip44. 为了把⼀个外置的路由处理器接⼝和交换机安置在同⼀个VTP域中: router(config)# interface interface number44. 为了把⼀个外置的路由处理器接⼝和交换机安置在同⼀个VTP域中: router(config)# interface interface numberrouter(config-if)# mls rp vtp-domain domain-name 45. 查看指定的VTP域的信息:router# show mls rp vtp-domain vtp domain name46. 要确定RSM或路由器上的管理接⼝,可以在接⼝模式下输⼊下列命令: router(config-if)#mls rp management-interface 47. 要检验MLS-RP的配置情况: router# show mls rp48. 检验特定接⼝上的MLS配置:router# show mls rp interface interface number49. 为了在MLS-SE上设置流掩码⽽⼜不想在任⼀个路由处理器接⼝上设置访问列表: set mls flow [destination|destination-source|full]50. 为使MLS和输⼊访问列表可以兼容,可以在全局模式下使⽤下列命令: router(config)# mls rp ip input-acl51. 当某个交换机的第3层交换失效时,可在交换机的特权模式下输⼊下列命令: switch(enable) set mls enable52. 若想改变⽼化时间的值,可在特权模式下输⼊以下命令: switch(enable) set mls agingtime agingtime 53. 设置快速⽼化:switch(enable) set mls agingtime fast fastagingtime pkt_threshold54. 确定那些MLS-RP和MLS-SE参与了MLS,可先显⽰交换机引⽤列表中的内容再确定: switch(enable) show mls include 55. 显⽰MLS⾼速缓存记录: switch(enable) show mls entry56. ⽤命令show in arp显⽰ARP⾼速缓存区的内容。
思科交换机的基本配置命令学习CISCO交换机基本配置:Console端口连接交换机口令设置: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(config)#int f0/1 ;进入端口1switch(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_PC1switch(config-if)#switchport access vlan 2 ;当前端口加入vlan 2switch(config-if)#switchport mode trunk ;设置为trunk模式(access 模式)switch(config-if)#switchport trunk allowed vlan 1,2 ;设置允许的vlanswitch(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 1switch(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 设置域名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 设置超时时间为100msswitch(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/7switch(config)#endswitch#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电缆【VLAN的基本配置命令】创建配置vlan1、从特权模式进入vlan模式,交换机添加VLAN创建,删除,端口属性的设置,配置trunk端口,将某端口加入vlan中,配置VTP:Switch>Switch>enSwitch#vlan database ;进入VLAN设置% Warning: It is recommended to configure VLAN from config mode,as VLAN database mode is being deprecated. Please consult userdocumentation for configuring VTP/VLAN in config mode.switch(vlan)#vlan 2 ;建VLAN 2switch(vlan)#vlan 3 name vlan3 ;建VLAN 3并命名为vlan3 switch(vlan)#no vlan 2 ;删vlan 2如下实例:Switch(vlan)#vlan 2 name yv1VLAN 2 added:Name: yv1Switch(vlan)#vlan 3 name yv2VLAN 3 added:Name: yv2Switch(vlan)#vlan 4 name yv3VLAN 4 added:Name: yv3Switch(vlan)#exit 保存退出APPLY completed.Exiting....划端口进VLAN首先进入用户模式“<Sw>"在用户模式下输入”en“,进入特权模式”Sw#<switch>enswitch#在特权模式下输入”configure terminal“,进入全局模式”Sw(config)#switch#configure terminalswitch#(config)#接下来在全局模式下进入接口模式,输入”int range f0/1-3“,这里注意了使用range参数才可以进入多接口,这里选择f0/1、f0/2、f0/3,三个接口。
思科交换机-常⽤命令及配置switch> ⽤户模式1:进⼊特权模式enableswitch> enableswitch#
2:进⼊全局配置模式configure terminalswitch> enableswitch#configure terminalswitch(conf)#
3:交换机命名hostname name 以cisco001 为例switch> enableswitch#c onfigure terminalswitch(conf)#hostname cisco001cisco001(conf)#
4:配置使能⼝令(未加密)enable password cisco 以cisco 为例switch> enableswitch#configure terminalcisco001(conf)# enable password cisco
5:配置使能密码(加密)enable secret ciscolab 以cicsolab 为例switch> enableswitch#configure terminalswitch(conf)# enable secret ciscolab
6:设置虚拟局域⽹vlan 1 interface vlan 1switch> enableswitch#configure terminalswitch(conf)# interface vlan 1switch(conf)# ip address 192.168.1.1 255.255.255.0 配置交换机端⼝ip 和⼦⽹掩码switch (conf-if)#no shut 激活端⼝switch (conf-if)#exitswitch (conf)#ip default-gateway 192.168.254 设置⽹关地址 7:进⼊交换机某⼀端⼝interface fastehernet 0/17 以17 端⼝为例switch> enableswitch#configure terminalswitch(conf)# interface fastehernet 0/17switch(conf-if)#
思科交换机基本配置实例讲解目录1、基本概念介绍 (1)2、密码、登陆等基本配置 (1)3、CISCO设备端口配置详解 (7)4、VLAN的规划及配置 (12)4.1核心交换机的相关配置 (12)4.2接入交换机的相关配置 (24)5、配置交换机的路由功能 (29)6、配置交换机的DHCP功能 (30)7、常用排错命令 (31)1、基本概念介绍IOS: 互联网操作系统,也就是交换机和路由器中用的操作系统VLAN: 虚拟lanVTP: VLAN TRUNK PROTOCOLDHCP: 动态主机配置协议ACL:访问控制列表三层交换机:具有三层路由转发能力的交换机本教程中“#”后的蓝色文字为注释内容。
2、密码、登陆等基本配置本节介绍的内容为cisco路由器或者交换机的基本配置,在目前版本的cisco交换机或路由器上的这些命令是通用的。
本教程用的是cisco的模拟器做的介绍,一些具体的端口显示或许与你们实际的设备不符,但这并不影响基本配置命令的执行。
Cisco 3640 (R4700) processor (revision 0xFF) with 124928K/6144K bytes of memory. Processor board ID 00000000R4700 CPU at 100MHz, Implementation 33, Rev 1.22 Ethernet interfaces8 Serial interfacesDRAM configuration is 64 bits wide with parity enabled.125K bytes of NVRAM.8192K bytes of processor board System flash (Read/Write)--- System Configuration Dialog ---Would you like to enter the initial configuration dialog? [yes/no]: n# 此处我们选择no,不进入他的初始化配置向导Press RETURN to get started!# 选择no以后,提示你按回车键开始,此处我们需要按回车键*Mar 1 00:43:56.591: %IP-5-WEBINST_KILL: Terminating DNS process*Mar 1 00:43:58.379: %SYS-5-RESTART: System restarted --Cisco IOS Software, 3600 Software (C3640-JK9O3S-M), Version 12.3(14)T7, RELEASE SOFTWARE (fc2)Technical Support: /techsupportCopyright (c) 1986-2006 by Cisco Systems, Inc.Compiled Wed 22-Mar-06 21:46 by pwade*Mar 1 00:43:58.411: %SNMP-5-COLDSTART: SNMP agent on host Router is undergoing a cold startRouter># 等显示稳定后,出现最初的提示符,注意提示符是“>”,目前所处的状态称为用户模式。
思科交换机配置命令大全switch>用户模式1:进入特权模式enableswitch>enableswitch#2:进入全局配置模式configureterminalswitch>enableswitch#configureterminal3switch4switch5switch6switch7switch#configureterminalswitch(conf)#hostnameaptch2950aptech2950(conf)#interfacefastehernet0/17aptech2950(conf-if)#8:查看命令showswitch>enableswitch#showversion察看系统中的所有版本信息showinterfacevlan1查看交换机有关ip协议的配置信息showrunning-configure查看交换机当前起作用的配置信息showinterfacefastethernet0/1察看交换机1接口具体配置和统计信息showmac-address-table查看mac地址表showmac-address-tableaging-time查看mac地址表自动老化时间9:交换机恢复出厂默认恢复命令switch>enableswitch#erasestartup-configureswitch#reload10:双工模式设置switch>enableswitch#configureterminalswitch2950(conf)#hostnameaptch-2950aptech2950(conf)#interfacefastehernet0/17以17端口为例11:cdp12:在查看把“执行把“把“”:13switchaptech2950(conf)#interfacefastethernet0/1以17端口为telnet远程登录端口aptech2950(conf-if)#noshutaptech2950(conf-if)#exitaptech2950(conf)linevty04设置0-4个用户可以telnet远程登陆aptech2950(conf-line)#loginaptech2950(conf-line)#passwordedge以edge为远程登录的用户密码主机设置:运行:进入telnet远程登录界面password:edgeaptech2950>enpassword:ciscoaptech#14:交换机配置的重新载入和保存设置完成交换机的配置后:aptech2950(conf)#reload是否保存(y/n)y:保存设置信息n:不保存设置信息1.在基于IOS的交换机上设置主机名/系统名:switch(config)#hostnamehostname在基于CLI的交换机上设置主机名/系统名:switch(enable)setsystemnamename-string2.在基于3.在基于4.在基于5.基于基于CLI的交换机的端口描述:switch(enable)setportnamemodule/numberdescription-string 6.在基于IOS的交换机上设置端口速度:switch(config-if)#speed{10|100|auto}在基于CLI的交换机上设置端口速度:switch(enable)setportspeedmoudle/number{10|100|auto} switch(enable)setportspeedmoudle/number{4|16|auto}7.在基于IOS的交换机上设置以太网的链路模式:switch(config-if)#duplex{auto|full|half}在基于CLI的交换机上设置以太网的链路模式:switch(enable)setportduplexmodule/number{full|half} 8.在基于IOS的交换机上配置静态VLAN:switch#vlandatabaseswitch(vlan)#vlanvlan-numnamevlaswitch(vlan)#exitswitch#configureteriminalswitch(config)#interfaceinterfacemodule/number switch(config-if)#switchportmodeaccessswitch(config-if)#switchportaccessvlanvlan-num switch(config-if)#end在基于CLI的交换机上配置静态VLAN:9.在基于10.在基于11.在基于ord]12.switch#vlandatabaseswitch(vlan)#vtpv2-mode在基于CLI的交换机上配置VTP版本:switch(enable)setvtpv2enable13.在基于IOS的交换机上启动VTP剪裁:switch#vlandatabaseswitch(vlan)#vtppruning在基于CLI的交换机上启动VTP剪裁:switch(enable)setvtppruningenable14.在基于IOS的交换机上配置以太信道:switch(config-if)#portgroupgroup-number[distribution{source|destination}]在基于CLI的交换机上配置以太信道:switch(enable)setportchannelmoudle/port-rangemode{on|off|desirable|auto}15.在基于IOS的交换机上调整根路径成本:switch(config-if)#spanning-tree[vlanvlan-list]costcost在基于CLI的交换机上调整根路径成本:switch(enable)setspantreeportcostmoudle/portcostswitch(enable)setspantreeportvlancostmoudle/port[costcost][vlan-list]16.在基于IOS的交换机上调整端口ID:switch(config-if)#spanning-tree[vlanvlan-list]port-priorityport-priority在基于CLI的交换机上调整端口ID:17.在基于18.在基于19.在基于|on]20.列命令21.22.用23.用24.在Catalyst交换机上定义TrBRF的命令如下:switch(enable)setvlanvlan-name[namename]typetrbrfbridgebridge-num[stp{ieee|ibm}] 25.在Catalyst交换机上定义TrCRF的命令如下:switch(enable)setvlanvlan-num[namename]typetrcrf{ringhex-ring-num|decringdecimal-ring-num}parentvlan-num26.在创建好TrBRFVLAN之后,就可以给它分配交换机端口.对于以太网交换,可以采用如下命令给VLAN分配端口:switch(enable)setvlanvlan-nummod-num/port-num27.命令showspantree显示一个交换机端口的STP状态.28.配置一个ELAN的LES和BUS,可以使用下列命令:ATM(config)#interfaceatmnumber.subintmultiointATM(config-subif)#laneserber-busethernetelan-name29.配置LECS:ATM(config)#lanedatabasedatabase-nameATM(lane-config-databade)#nameelan1-nameserver-atm-addressles1-nsap-address ATM(lane-config-databade)#nameelan2-nameserver-atm-addressles2-nsap-address ATM(lane-config-databade)#name…30.创建完数据库后,必须在主接口上启动LECS.命令如下:ATM(config)#interfaceatmnumberATM(config-if)#laneconfigdatabasedatabase-nameATM(config-if)#laneconfigauto-config-atm-address31.32.用33.用34.用35.用36.用37.38.39.用router(config-if)#laneclientethernetelan-numrouter(config-if)#interfaceatmmodule/port.subinterfacemultipointrouter(config-if)#ipaddressip-addresssubnet-namerouter(config-if)#laneclientethernetelan-namerouter(config-if)#…40.为了在路由处理器上进行动态路由配置,可以用下列IOS命令来进行:router(config)#iproutingrouter(config)#routerip-routing-protocolrouter(config-router)#networkip-network-numberrouter(config-router)#networkip-network-number41.配置默认路由:switch(enable)setiproutedefaultgateway42.为一个路由处理器分配VLANID,可在接口模式下使用下列命令:router(config)#interfaceinterfacenumberrouter(config-if)#mlsrpvlan-idvlan-id-num43.在路由处理器启用MLSP:router(config)#mlsrpip44.为了把一个外置的路由处理器接口和交换机安置在同一个VTP域中:router(config)#interfaceinterfacenumberrouter(config-if)#mlsrpvtp-domaindomain-name45.查看指定的VTP域的信息:46.47.48.49.50.为使51.52.53.54.55.显示56.57.58.router(config-if)#standygroup-numberpreempt59.访问时间和保持时间参数是可配置的:router(config-if)#standygroup-numbertimershellotimeholdtime60.配置HSRP跟踪:router(config-if)#standygroup-numbertracktype-numberinterface-priority 61.要显示HSRP路由器的状态:router#showstandbytype-numbergroupbrief62.用命令showipigmp确定当选的查询器。
交换机的常用操作项1、更改主机名switch(config)#hostname sw12、设置进入特权模式的密码switch(config)#enable password 1234switch(config)#enable secret cisco3、设置console口密码switch(config)#line console 0switch(config-line)#password 123switch(config-line)#login4、查看mac地址列表switch#show mac-address-table5、查看mac地址列表刷新时间switch#show mac-address-table aging-time6、更改mac地址列表刷新时间switch(config)#mac-address-table aging-time 200 7、查看当前配置(RAM)switch#show running-config8、查看交换机的配置(NVRAM)switch#show startup-config9、保存配置switch#copy running-config startup-configswitch#write10、恢复出厂默认设置switch#erase startup-configswitch#reload11、查看cdp的全局信息switch#show cdp12、查看接口的cdp配置信息switch#show cdp interface f0/213、查看有关cdp包的统计信息switch#show cdp traffic14、查看邻居信息switch#show cdp neighbors15、查看所有入口项的详细信息switch#show cdp neighbors detailswitch#show cdp entry *16、添加接口的描述信息switch(config-if)# description connection to routerA 17、设置交换机的网关switch(config)#ip default-gateway 192.168.1.118、关掉DNS解析switch(config)# no ip domain-lookup19、实现交换机的远程管理switch(config)#enable secret ciscoswitch(config)#interface vlan 1switch(config-if)#ip address 192.168.1.100 255.255.255.0switch(config-if)#no shutdownswitch(config)#line vty 0 4switch(config-line)#password 123switch(config-line)#loginc:\>telnet 192.168.1.10020、交换机的密码恢复1、将交换机的电源拔下2、按mode键将电源插上,当出现switch:时将手松开3、switch:flash_init //加载到flash中4、switch:dir flash: //查看flash中的文件5、rename flash:config.text flash:config.old //更改文件名6、boot //重新启动交换机7、rename flash:config.old flash:config.text //将文件名改回8、copy flash:config.text running-config9、enable password cisco //重新设置密码10、write //保存21、创建vlan方法一switch#vlan databaseswitch(vlan)#vlan 10 name scswitch(vlan)#exit22、创建vlan方法二switch(config)#vlan 10switch(config-vlan)#name sc23、删除vlan方法一switch(vlan)#no vlan 10switch(vlan)#exit24、删除vlan方法二switch(config)#no vlan 1025、删除vlan方法三switch#delete vlan.dat26、将端口加入到vlan中switch(config-if)#switchport access vlan 1027、将一组连续的端口加入到vlan中switch(config)# interface range f0/1 – 5 (端口范围管理switch(config-if-range)#switchport access vlan 10 端口范围管理模式28、将端口从vlan中删除switch(config-if)#no switchport access vlan 10switch(config-if)#switchport access vlan 1switch(config-if-range)#no switchport access vlan 10 switch(config-if-range)#switchport access vlan 1 29、查看所有vlan的摘要信息switch#show vlan brief30、查看指定vlan的信息switch#show vlan id 1031、指定端口成为trunkswitch(config-if)#switchport mode trunk 两个端口全要设成trunk32、Trunk的自动协商switch(config-if)#switchport mode dynamic desirable switch(config-if)#switchport mode dynamic auto注意:如果中继链路两端都设置成auto将不能成为trunk 33、查看端口状态switch#show interface f0/24 switchport34、在trunk上移出vlanswitch(config-if)#switchport trunk allowed vlan remove 235、在trunk上添加vlanswitch(config-if)#switchport trunk allowed vlan add236、Cisco 2600路由器的基本操作从用户模式进入特权模式router>enablerouter#从特权模式进入全局配置模式router#config terminalrouter(config)#为路由器配置主机名router(config)#hostname teacherteacher(config)#进入路由器的以太口配置模式teacher(config)#interface fastethernet 0/0teacher(config_if)#37、查看Cisco 2600路由器的串口状态router#show interface serial 0/0serial 0/0 is up ,line protocol is up可操作状态………serial 0/0 is up ,line protocol is up连接问题…………serial 0/0 is up ,line protocol is down接口问题…………serial 0/0 is down ,line protocol isdown禁用状态…………serial 0/0 is administratively down ,line protocol is down38、 静态路由的实现router(config)#hostname AA(config)#interface f0/0 A(config-if)#ip address 192.168.1.1 255.255.255.0 A(config-if)#no shutdownA(config)#interface f0/1A(config-if)#ip address 192.168.2.1 255.255.255.0 A(config-if)#no shutdownA(config)#iproute 192.168.3.0 255.255.255.0 192.168.2.2B(config)#iproute 192.168.1.0 255.255.255.0 192.168.2.139、 配置默认路由route(config)#ip route 0.0.0.0 0.0.0.0 下一跳地址40、 查看路由表router#show ip route其中C 代表直连的网络,S 代表静态的路由,S*代表默认的路由 192.168.1.1 192.168.2.2 192.168.2.1 192.168.3.1 192.168.1.10 192.168.3.1041、为Cisco 2600路由器配置密码配置控制台密码router (config)#line console 0router (config-line)# password ciscorouter (config-line)# login42、配置特权模式密码router (config)#enable password cisco43、配置安全的加密密码router (config)#enable secret 123444、配置路由器标识router(config)#banner motd $This is Aptech company’s Router! Please don’t change the configuration whithout permissions$45、对所有密码进行加密router (config)#service password-encryption46、配置超时router(config)#line console 0router(config-line)#exec-timeout 0 0 //第一个0代表分钟,第二个0代表秒47、显示同步router(config)#line console 0router(config-line)#logging synchronous48、配置禁用DNSrouter(config)#no ip domain-lookup49、利用三台路由器实现静态路由和默认路由50、路由器密码恢复重启路由器按Ctrl+Break键进入ROM Monitor 模式rommon 1>confreg 0x2142rommon 2>reset重启后选择norouter>enablerouter#copy startup-config running-configrouter#config terminalrouter(config)#enable password ciscorouter(config)#config-register 0x2102router#copy running-config startup-configrouter#reload51、单臂路由——实现不同vlan之间的通信V L A N11、划分vlanswitch#vlan databaseswitch(vlan)#vlan 2写NAME,不行,switch(vlan)#vlan 3switch(vlan)#exit2、将端口加入vlanswitch(config)#interface range f0/6 -8switch(config-if-range)#switchport access vlan 2 switch(config-if-range)# interface range f0/9 -11 switch(config-if-range)#switchport access vlan 3 3、配置trunkswitch(config)#interface f0/12switch(config-if)#switchport mode trunk4、配置路由器的子接口封装dot1q,并设置IP地址router(config)#interface f0/0.1router(config-subif)#encapsulation dot1q 1router(config-subif)#ip address 192.168.0.1 255.255.255.0router(config-subif)#no shutrouter(config)#interface f0/0.2router(config-subif)#encapsulation dot1q 2router(config-subif)#ip address 192.168.1.1 255.255.255.0router(config-subif)#no shutrouter(config)#interface f0/0.3router(config-subif)#encapsulation dot1q 3router(config-subif)#ip address 192.168.2.1 255.255.255.0router(config-subif)#no shutrouter(config)#interface f0/0router(config-if)#no shut5、设置pc的IP地址和默认网关52、RIP版本V1和V2 的区别RIP v1发送路由更新时不携带子网掩码,属于有类路由协议发送路由更新时,目标地址为广播地址:255.255.255.255RIP v2发送路由更新时携带子网掩码,属于无类路由协议发送路由更新时,目标地址为组播地址:224.0.0.953、 RIP V1的配置配置步骤:1、配置路由器接口IP 地址routerA(config)#interface f0/0routerA(config-if)#ipaddress 192.168.1.1 255.255.255.0routerA(config-if)#no shutdownrouterA(config-if)#interface f0/1routerA(config-if)# ip address 10.0.0.2 255.0.0.0routerA(config-if)#no shutdownrouterB(config)#interface f0/0routerB(config-if)#ip address 10.0.0.1 255.0.0.0 192.168.2.0/24192.168.1.0/24routerB(config-if)#no shutdownrouterB(config)#interface f0/1routerB(config-if)#ip address 20.0.0.2 255.0.0.0 routerB(config-if)#no shutdownrouterC(config)#interface f0/0routerC(config-if)#ip address 20.0.0.1 255.0.0.0 routerC(config-if)#no shutdownrouterC(config)#interface f0/1routerC(config-if)#ip address 192.168.2.2 255.255.255.0routerC(config-if)#no shutdown2、在路由器上启动RIP进程,并宣告网络号:routerA(config)#router riprouterA(config-router)#network 10.0.0.0routerA(config-router)#network 192.168.1.0routerB(config)#router riprouterB(config-router)#network 10.0.0.0routerB(config-router)#network 20.0.0.0routerC(config)#router riprouterC(config-router)#network 20.0.0.0routerC(config-router)#network 192.168.2.03、验证配置是否正确1)查看路由表router#show ip route2)查看路由协议配置router#show ip protocols3)打开RIP协议调试命令router#debug ip rip4)退出router# no debug ip rip4、在PC上设置IP地址、子网掩码、默认网关,用ping命令测试连通性54、RIP V2的配置10.1.1.0/24 192.168.1.0/241、配置各路由器接口IP地址routerA(config)#interface f0/0routerA(config-if)#ip address 10.1.1.1 255.255.255.0routerA(config-if)#no shutdownrouterA(config-if)#interface f0/1routerA(config-if)# ip address 192.168.1.1 255.255.255.0routerA(config-if)#no shutdownrouterB(config)#interface f0/0routerB(config-if)#ip address 10.1.2.1 255.255.255.0routerB(config-if)#no shutdownrouterB(config)#interface f0/1routerB(config-if)#ip address 192.168.1.2 255.255.255.0routerB(config-if)#no shutdownrouterC(config)#interface f0/0routerC(config-if)#ip address 192.168.1.3 255.255.255.0routerC(config-if)#no shutdownrouterC(config)#interface f0/1routerC(config-if)#ip address 192.168.2.1 255.255.255.0routerC(config-if)#no shutdown2、在路由器上配置RIP V2 路由协议routerA(config)#router riprouterA(config-router)#version 2routerA(config-router)#no auto-summary不合并同段网络routerA(config-router)#network 10.0.0.0 routerA(config-router)#network 192.168.1.0 routerB(config)#router riprouterB(config-router)#version 2routerB(config-router)# no auto-summary routerB(config-router)#network 10.0.0.0 routerB(config-router)#network 192.168.1.0 routerC(config)#router riprouterC(config-router)# version 2routerC(config-router)# no auto-summary routerC(config-router)#network192.168.1.0 routerC(config-router)#network 192.168.2.0 3、验证配置是否正确1)查看路由表router#show ip route2)查看路由协议配置router#show ip protocols3)打开RIP协议调试命令router#debug ip rip4、在PC上设置IP地址、子网掩码、默认网关,用ping命令测试连通性55、上传路由器上的IOSrouter#show flash //查看IOS文件名router#copy flash tftpSource filename []? c2600-ik8o3s-mz.122-11.T.binAddress or name of remote host []? 192.168.1.11Destination filename [c2600-ik8o3s-mz.122-11.T.bin]?下载IOS到路由器router#copy tftp flash上传路由器上配置文件router#copy nvram:startup-config tftp:Address or name of remote host []? 192.168.1.11Destination filename [router-config]? startup-config下载配置文件到路由器router#copy tftp:startup-config nvramC2600路由器IOS被删除的恢复方法:1、ctrl+breakrommon 1>IP_ADDRESS=192.168.0.100 //路由器接口地址rommon 2>IP_SUBNET_MASK=255.255.255.0rommon 3>DEFAULT_GATEWAY=192.168.0.100rommon 4>TFTP_SERVER=192.168.0.254rommon 5>TFTP_FILE=c2600-ik8o3s-mz.122-11.T.binrommon 6>tftpdnld希望各位学员努力学习,将交换机和路由器的操作命令练会、练熟学如逆水行舟,不进则退。
思科模拟器命令: 设置交换机名字为yzh Switch> 进入超级终端控制台 Switch>enable 进入交换机特权模式 Switch# Switch#configure terminal 进入交换机全局配置模式 Switch(configure)#hostname yzh 改变名字为XXX yzh(configure)# 显示改名成功 yzh(configure)#exit 退回上级操作模式,即返回特权模式 yzh# yzh#exit 返回到用户模式 yzh> 参看交换机有关信息 yzh# yzh#configure terminal 进入交换机全局配置模式 yzh#show version 查看交换机的版本信息 yzh#show vlan 查看交换机的VLAN信息,默认情况下所有借口均属于VLAN yzh#show running-config 查看交换机当前生效的配置信息 配置交换机接口f0/2 yzh> yzh>enable yzh# yzh#configure terminal 进入交换机配置模式 yzh(config)#interface fastEthernet 0/2 进入交换机接口fa0/2 yzh(config-if)# 进入接口配置模式 yzh(config-if)#speed 100 设置接口F0/2速率为100M yzh(config-if)#duplex half 配置接口的双工模式是半双工 yzh(config-if)#no shutdown 开启接口,使得处于工作状态,等待转发数据。 yzh(config-if)#exit 输入exit返回全局模式 yzh(config)#exit 返回特权模式 yzh# 位于特权模式 yzh#show interfaces fastEthernet 0/2 查看刚才对接口f0/2配置情况 设置交换机Enable特权密码为admin yzh> 进入超级终端控制台 yzh>enable 进入交换机特权模式 yzh#configure terminal 进入交换机配置模式 yzh(config)#enable secret admin 设置Enable密码为admin 注:验证密码自己思考。 查看设备配置信息 yzh#show running-config 保存配置信息 yzh#write 保存设置配置,把配置指令写入对到系统文件夹中 yzh#dir 查看系统文件 删除配置,恢复初始配置 yzh# yzh#dir 查看系统文件 yzh#delete? 输入“?”号,获得帮助 yzh#delete flash:config.txt 删除配置文件 系统就恢复了出厂配置
三层交换机与二层交换机的大多数都相同。 配置三层交换机的名称为SW3,enable密码为admin,并且配置与远程登陆相关的选项。 Switch>enable 进入交换机特权模式 Switch#configure terminal 进入交换机全局模式 Swirch(config)#hostname yzh 修改交换机名称 Yzh(config)#enable password admin 设置交换机enable密码为admin Yzh(config)#interface vlan1 进入vlan1 Yzh(config-if-VLAN1)#ip address 192.168.1.1 255.255.255.0 配置IP地址 yzh(config-if-VLAN1)#exit 退出配置vlan1 yzh(config)#username admin password admin 配置登陆交换机的用户名与密码 yzh(config)#line vty 0 4 进入vty端口配置 yzh(config-line)#login local 配置vty端口使用本地数据库验证 yzh(config-line)#exit 退出vty端口配置 yzh(config)# 配置OK 保存三层交换机配置。 SW3#write 配置三层交换机名称与VLAN yzh>enable 进入交换机特权模式 yzh#configure terminal 进入交换机全局模式 yzh(config)#hostname YZH 修改交换机名称为YZH YZH(config)#vlan10 创建vlan10 YZH(config-vlan)#vlan20 创建vlan20 YZH(config-vlan)#exit YZH(config)#interface range fastEthernet 0/1-10 进入fa/1-10端口 YZH(config-if-range)#switchport access vlan10 划分fa/1-10端口为vlan10 YZH(config-if-range)exit YZH(config)#interface range fastEthernet 0/11-20 进入fa/11-20端口 YZH(config-if-range)#switchport access vlan20 划分fa/11-20端口为vlan20 YZH(config-if-range)#exit 查看vlan配置信息 YZH(config)#exit YZH#show vlan 查看交换机vlan信息 配置vlan10与vlan20的IP地址,使vlan10与vlan20之间能相互通讯。 YZH(config)#interface vlan10 进入vlan10 YZH(config-vlan10)#ip address 192.168.1.1 255.255.255.0 配置vlan10的IP地址 YZH(config-vlan10)#exit YZH(config)#interface vlan20 进入vlan20 YZH(config-vlan20)#ip address 192.168.2.1 255.255.255.0 配置vlan20的IP地址 YZH(config)#exit YZH#show running-config 查看交换机配置信息 在三层交换机上配置vlan10与20的IP地址后,PC1与PC2可以相互通讯 YZH>enable 进入特权模式 YZH#configure terminal 进入全局模式 YZH(config)#hostname yzh 修改名称 yzh(config)#interface range fasrEthernet 0/1-2 进入fa0/1、fa0/2端口 yzh(config-if-range)#port-group 1 把fa0/1、fa0/2端口聚合为端口组1 yzh(config-if-range)#exit yzh(config)#exit 注:验证测试:查看交换机配置 yzh#show running-config 配置三层交换机SW1的生成树协议 yzh>enable yzh#configure yzh(config)#hostname YZH YZH(config)#spanning-tree 配置生成树 YZH(config)#exit 验证配置: YZH#show vlan 查看VLAN划分信息 配置二层交换机SWB的VLAN划分 YZH>enable YZH #configure terminal YZH(config)#hostname SWB 配置交换机名称 YZH (config)#vlan20 创建VLAN20 YZH (config-vlan)#exit YZH (config)#int fa0/1 YZH (config-if)#swit YZH (config-if)#switchport access vlan20 将端口Fa0/1划分为VLAN20 YZH (config-if)#exit YZH (config)#int fa0/24 YZH (config-if)#switchport access vlan20 将端口Fa0/24划分为VLAN20 YZH (config-if)#exit 配置三层交换机SW1不同VLAN之间的通信 YZH>enable YZH #configure terminal YZH (config)#hostname yzh !配置交换机名称 yzh (config)#vlan10 !创建VLAN10 yzh (config-vlan)#vlan20 !创建VLAN20 yzh (config-vlan)#vlan 30 !创建VLAN30 yzh (config-vlan)#exit yzh (config)#interface vlan10 !配置VLAN10的IP地址 yzh (config-VLAN10)#ip address 192.168.1.1 255.255.255.0 yzh (config-VLAN10)#exit yzh config)#interface vlan20 !配置VLAN20的IP地址 yzh (config-VLAN20)#ip address 192.168.2.1 255.255.255.0 yzh config-VLAN20)#exit yzh (config)#interface vlan 30 !配置VLAN30的IP地址 yzh (config-VLAN 30)#ip address 192.168.3.1 255.255.255.0 yzh (config-VLAN 30)#exit yzh (config)#interface range fastEthernet 0/1-7 yzh (config-if-range)#switchport access vlan10 !划分VLAN10 yzh (config-if-range)#exit yzh (config)#interface range fastEthernet 0/8-14 yzh (config-if-range)#switchport access vlan20 !划分VLAN20 yzh (config-if-range)#exit yzh (config)#interface range fastEthernet 0/15-21 yzh (config-if-range)#switchport access vlan 30 !划分VLAN30 yzh (config-if-range)#exit 配置风暴控制。 在交换机配置F0/1端口(连接PC1 的端口)对广播报文进行风暴控制,限制其端口收到的报文速率(pps) yzh#configure yzh(config)#interface fastEthernet 0/1 yzh(config-if)#storm-control broadcast pps 100 配置报文速率阈每秒100个报文 yzh(config-if)#exit 配置交换机端口安全的最大连接数和端口违背模式,绑定PC机IP地址和MAC地址到端口上 yzh>enable yzh#configure yzh(config)#interface fastEthernet 0/1 yzh(config-FastEthernet 0/1)#switchport port-security 打开端口安全功能 yzh(config-FastEthernet 0/1)#switchport port-security mac address 0023.7d51.72ad ip-addreess 192.168.1.1 yzh(config-if-range)#switchport port-security violation shutdown 配置安全违背关闭模式 验证交换机端口的最大连接数和端口违背模式 yzh(config)#show port-secruity 验证端口绑定的MAC地址和IP地址 yzh(config)#show port-security 验证端口绑定的MAC地址和IP地址 yzh(config)#show port-security address 配置镜像源端口0/1-2的进出流量映射到目的端口F0/20