交换机和路由器常用命令注释
- 格式:doc
- 大小:48.00 KB
- 文档页数:5
交换机与路由器基本命令交换机部分命令一、交换机五种模式Swith> (用户模式)Swith# (特权模式)Swith(config)# (全局配置模式)Swith(config-if)# (接口模式)Swith(config-line)# (线模式)二、交换机模式切换Swith>enable //切换到特权Swith#config t //切换到全局配置模式Swith(config)# interface f0/1 //进入接口f0/0Swith(config)# interface vlan 1 //进入VLAN 1中Swith(config-if)#ip address 192.168.1.1 255.255.255.0 //对VLAN1设置IP地址和子网掩码Swith(config-if)#no shutdown //激活VLAN1三、设置交换机的密码1、用户到特权的密码Swith(config)#enable password 123 (优先级低)Swith(config)#enable secret 456 (优先级高) //如果两个都设置则456生效2、控制台console密码设置Swith(config)# line con 0Swith(config-line)#loginSwith(config-line)#password console123 //设置console密码为telnet1233、启用telnet密码Swith(config)#line vty 0 15 //最多有0~15人可以telnet访问swith,合计16人Swith(config-line)#loginSwith(config-line)#password telnet123 //设置telnet密码为telnet123注:要想真正生效telnet还要设置特权密码三、交换机命名hostname BENETSW01Swith(config)#hostname BENETSW01 //使用hostname命名交换机的名字四、show命令集Swith#show version //显示IOS版本信息Swith#show int vlan 1 brief //简单的显示VLAN1的信息Swith#show running-config //显示正在运行的配置文件Swith#show startup-config //显示己经保存的配置文件Swith#show mac-address-table //显示MAC地址表Swith#show mac-address-table //显示MAC地址表更新的间隔,默认为5分钟Swith#show neighbor detail //显示邻居详细信息Swith#show traffic //显示CDP流量Swith#show五、设置交换机的网关和DNS名称服务器的IP地址Swith(config)# ip default-gateway 192.168.10.8 //交换机的网关设置为192.168.10.8 Swith(config)#ip domain -name server 202.106.0.20 //设置DNS名称服务器地址Swith(config)# no ip domain-lookup //交换机名称服务器的域名查询六、创建、删除、查看VLANSwitch#vlan database //进入vlan数据库配置模式Switch(vlan)#vlan 2 //创建VLAN2命名为vlan0002,也可以使用vlan2 name sales VLAN 2 added:Name: VLAN0002Switch(vlan)#exit //退出时应用生效Swith(vlan)#no vlan 2 //删除vlan2Switch(config)# interface f0/1Switch(config-if)# switchport access vlan 2 //将端口加入vlan 2中Switch(config-if)# no switchport access vlan 2 //将端口从vlan2中删除Switch(config)# interface range f0/1 –10 // 进行F0/1到10端口范围Switch(config-if-range)# switchport access vlan 2 //将f0/1到f0/10之间的所有端口加入vlan 2Switch# show vlan brief //查看所有VLAN的摘要信息Switch# show vlan id vlan-id //查看指定VLAN的信息七、开启并查看trunk端Swith(config)#interface f0/24Swith(config-if)#swith mode trunk //将f0/24端口设置为trunkSwitch#show interface f0/24 switchport //查看f0/24的接口状态八、从Trunk中添加、删除VlanSwitch (config-if )# switchport trunk allowed vlan remove 3 //从trunk端口删除v lan3通过Switch (config-if)# switchport trunk allowed vlan add 3 //从trunk端口添加vlan3通过Switch # show interface interface-id switchport //检查中继端口允许VLAN的列表九、单臂路由配置Router(config)# interface f0/0.1Router(config-subif)# encapsolution dot1q 1 //子接口封装dot1q 针对的是VLAN1Router(config-subif)# ip address 192.168.1.1 255.255.255.0 //设置VLAN的网关地址Router(config)# interface f0/0.2Router(config-subif)# encapsolution dot1q 2 //子接口封装dot1q针对的是vlan2Router(config-subif)# ip address 192.168.2.1 255.255.255.0 //设置vlan2的网关的地址路由命令部分一、路由器的模式v 用户模式:Router> //用户模式v 特权模式:Router# //特权模式v 全局配置模式:Router(config)# //配置模式v 接口配置模式:Router(config-if)# //接口模式v 子接口配置模式:Router(config)#interface fa0/0.1 //进入子接口Router(config-subif)# //子接口状态v Line模式:Router(config-line)# //进行线模式v 路由模式:Router(config-router)# //路由配置模式二、配置静态路由条目Router(config)#ip route 192.168.10.0 255.255.255.0 192.168.9.2 //到达192.168.10.0网段及掩码需要经过相邻路由器的接口的IP地址三、配置默认路由Router B(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2 //所以外出的数据包如果找不到路由表目均找192.168.2.2接口四、密码配置v 配置控制台密码teacher(config)#line console 0teacher((config_line)#loginteacher((config_line)#password ciscoteacher(config)#enable password cisco //配置特权模式密码teacher(config)#enable secret 1234 //配置加密保存的密码teacher(config)#service password-encryption //对所有密码加密五、配置路由器的banner信息teacher(config)#banner motd $This is Aptech company’s Router! Please don’t change the configuration without permission! $六、配置路由器接口的描述信息teacher(config)#interface fastethernet 0/0teacher(config_if)#description connectin g the company’s intranet!七、配置控制台配置控制台会话时间teacher(config)#line console 0teacher(config_line)#exec-timeout 0 0配置控制台输出日志同步teacher(config)#line console 0teacher(config_line)#logging synchronous八、动态路由相关命令Router(config)# router rip //启动RIP进程Router(config-router#version 2 //指定启动rip v2版本Router(config-router)# network network-number //宣告主网络号Router# show ip route //查看路由表Router#show ip route static //仅显示静态路由信息Router# show ip protocols //查看路由协议配置Rouetr# debug ip rip //打开RIP协议调试命令九、动态路由配置RouterA(config)#interface f0/0RouterA(config-if)#ip address 192.168.1.1 255.255.255.0RouterA(config-if)#no shutdownRouterA(config)#interface f0/1RouterA(config-if)#ip address 10.0.0.2 255.0.0.0RouterA(config-if)#no shutdownRouterA(config)#router ripRouterA(config-router)#network 10.0.0.0RouterA(config-router)#network 192.168.1.0十、路由器密码恢复进入ROM Monitor模式修改配置寄存器的值,启动时绕过startup-config文件:rommon1>confreg 0×2142rommon2>reset用startup-config覆盖running-config:Router#copy startup-config running-config修改密码:Router(config)#enable password cisco修改配置寄存器的值:Router(config)#config-register 0×2102。
华为路由器交换机常用命令一、设备管理命令1.登录管理命令- ssh [ip地质] -p [端口号]:通过SSH协议登录设备。
- telnet [ip地质]:通过Telnet协议登录设备。
- logout:退出设备。
2.用户管理命令- display current-configuration:显示当前设备配置信息。
- save:保存当前配置。
- undo save:取消保存的配置。
- super:切换到超级用户模式。
- user-interface console 0:配置控制台终端的参数。
- user-interface vty 0 4:配置远程登录终端的参数。
3.设备操作命令- reboot:重启设备。
- reset saved-configuration:恢复出厂配置。
- display version:显示设备的硬件和软件版本信息。
- display device:显示设备的基本信息。
- display interface[接口名称]:显示指定接口信息。
- display ip routing-table:显示IP路由表信息。
二、网络配置命令1.IP配置命令- interface [接口名称]:进入指定接口。
- ip address [IP地质] [子网掩码]:配置接口IP地质。
- undo ip address:取消接口IP地质配置。
- ip route-static [目标网络] [子网掩码] [下一跳地质]:配置静态路由。
- undo ip route-static [目标网络] [子网掩码] [下一跳地质]:取消静态路由配置。
2.VLAN配置命令- vlan [VLAN ID]:创建指定VLAN。
- quit:退出VLAN配置模式。
- interface vlan [VLAN ID]:进入指定VLAN接口。
- ip address [IP地质] [子网掩码]:为VLAN接口配置IP地质。
H3C交换机路由器常用命令及注释H3C交换机路由器常用命令及注释2009-10-09 13:04H3C交换机常用命令注释1、system-view 进入系统视图模式2、sysname 为设备命名3、display current-configuration 当前配置情况4、language-mode Chinese|English 中英文切换5、interface Ethernet 1/0/1 进入以太网端口视图6、port link-type Access|Trunk|Hybrid 设置端口访问模式7、undo shutdown 打开以太网端口8、shutdown 关闭以太网端口9、quit 退出当前视图模式10、vlan 10 创建VLAN 10并进入VLAN 10的视图模式11、port access vlan 10 在端口模式下将当前端口加入到vlan 10中12、port E1/0/2 to E1/0/5 在VLAN模式下将指定端口加入到当前vlan中13、port trunk permit vlan all 允许所有的vlan通过H3C路由器############################################################## ########################1、system-view 进入系统视图模式2、sysname R1 为设备命名为R13、display ip routing-table 显示当前路由表4、language-mode Chinese|English 中英文切换5、interface Ethernet 0/0 进入以太网端口视图6、ip address 192.168.1.1 255.255.255.0 配置IP地址和子网掩码7、undo shutdown 打开以太网端口8、shutdown 关闭以太网端口9、quit 退出当前视图模式10、ip route-static 192.168.2.0 255.255.255.0 192.168.12.2 description To.R2 配置静态路由11、ip route-static 0.0.0.0 0.0.0.0 192.168.12.2 description To.R2 配置默认的路由H3C S3100 SwitchH3C S3600 SwitchH3C MSR 20-20 Router############################################################## ############################1、调整超级终端的显示字号;2、捕获超级终端操作命令行,以备日后查对;3、language-mode Chinese|English 中英文切换;4、复制命令到超级终端命令行,粘贴到主机;5、交换机清除配置:<H3C>reset save ;<H3C>reboot ;6、路由器、交换机配置时不能掉电,连通测试前一定要检查网络的连通性,不要犯最低级的错误。
路由器和交换机的基本命令大家知道路由器和交换机的命令有哪一些吗?下面是小编为大家搜集整理出来的有关于路由器和交换机的基本命令,希望通过以下学习能够帮助到大家!路由器和交换机的基本命令en进入特权模式conft全局模式Int接口号进入接口模式exit返回上一个模式End返回特权模式hostname主机名配置主机名Shver查看版本信息Showmac-address-table查看Mac地址表Duplex双工模式配置双工模式(全双工full,半双half,自动协商auto)Speed速率值配置接口速率(auto自动匹配)Ifconfig查看IP地址的配置信息PingIP地址测试连通*Exec-timeout00永远在线,不超时锁定Noipdomain-lookup禁用DNS查找Loggsyn信息同步IPaddIP地址子网掩码配置IP地址(在全局模式下)Ipdefault-gatewaty网关地址配置交换机默认网关Password密码配置console口密码Nosh打开接口Showarp查看ARP缓存表Cleararp-cache清除ARP缓存表Arpip地址Mac地址arpaARP绑定Ping-t+IP地址无限测试下去(连通*)Ping-a+IP地址显示IP地址对应的主机名PingIP地址-l字节大小测试连通*IprouteIP网段子网掩码下一接口IP地址配置静态路由NoIprouteIP网段子网掩码下一接口IP地址删除静态路由Tracertip地址显示路由器经过的路径Wr或者copyrunning-configstarup-config保存当前配置Erasenvram或者erasestarup-config删除已保存的配置Shiproute查看路由表(路由器专用)Shmac-address-table查看Mac地址表(交换机专用)Shrun查看当前配置Shstar查看已保存的配置Linecon0进入console口Password密码配置console口密码Login保存信息Linevty04进入vty0-4这5个虚拟控制台,远程连接Enablepassword密码配置特权模式密码(明文)Enablesecret密码配置密文密码Ipdefault-gatewaty网关地址配置交换机默认网关Copyflashtftp备份IOS系统Copytftpflash升级IOS系统Vlandatabase进入VLAN配置模式Vlan数值配置VLANNovlan数值删除配置VLANShowvlanbr查看VLAN配置SwitchportaccessvlanID分VLAN到接口中Switchportmodeaccess/trunk/dynamic配置端口模式Swtrunkallowedvlanremove/add序号在trunk上删除、添加摸个VLANChannel-group序号modeon配置以太网通道Encapsulation封装类型vlanID号配置VLAN标签的封装结构Ipdhcppool地址池名称定义地址池Network网段子网掩码动态分配IP段Default-router网关地址设定网关地址Dns-server地址配置dns地址Lease租期设定地址的租期Vtpdomain名字创建vtp域Vtpmodeserver/client/transparent配置交换机vtp模式Showvtppassword查看vtp配置口令Showvtpstatus查看其他vtp配置信息。
一. 端口:路由器——ethernet(以太口)、Serial(串口)、loopback(虚拟端口)交换机——ethernet、vlan、loopback注意:交换机默认其24个端口全在vlan 1里面,交换机在给vlan配了ip之后就具有路由器的功能了。
另一个需要注意的是,所用的端口是否被shutdown了,如果被shutdown 了,需要进入相应的端口执行undo shutdown。
二. 配置ip除了交换机的以太口不可以配置ip外,其他端口都可以,配置方法相同。
[Quidway] interface *(所要配置的端口,如vlan 1)[Quidway-*]ip add *.*.*.*(ip)*.*.*.*(掩码)/*(掩码位数,一般只在路由器上适用)—————————————————————————————————————1.在基于IOS的交换机上设置主机名/系统名:switch(config)# hostname hostname在基于CLI的交换机上设置主机名/系统名:switch(enable) set system name name-string2.在基于IOS的交换机上设置登录口令:switch(config)# enable password level 1 password在基于CLI的交换机上设置登录口令:switch(enable) set passwordswitch(enable) set enalbepass3.在基于IOS的交换机上设置远程访问:switch(config)# interface vlan 1switch(config-if)# ip address ip-address netmaskswitch(config-if)# ip default-gateway ip-address在基于CLI的交换机上设置远程访问:switch(enable) set interface sc0 ip-address netmask broadcast-addressswitch(enable) set interface sc0 vlanswitch(enable) set ip route default gateway4.在基于IOS的交换机上启用和浏览CDP信息:switch(config-if)# cdp enableswitch(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-string6.在基于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/numberswitch(config-if)# switchport mode accessswitch(config-if)# switchport access vlan vlan-numswitch(config-if)# end在基于CLI的交换机上配置静态VLAN:switch(enable) set vlan vlan-num [name name]switch(enable) set vlan vlan-num mod-num/port-list9. 在基于IOS的交换机上配置VLAN中继线:switch(config)# interface interface mod/portswitch(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 databaseswitch(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 databaseswitch(vlan)# vtp v2-mode在基于CLI的交换机上配置VTP版本:switch(enable) set vtp v2 enable13. 在基于IOS的交换机上启动VTP剪裁:switch# vlan databaseswitch(vlan)# vtp pruning在基于CL I 的交换机上启动VTP剪裁:switch(enable) set vtp pruning enable14.在基于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 secondsswitch(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-name21. 为了从一条中继链路上删除VLAN,可使用下列命令:switch(enable) clear trunk module/port vlan-range22. 用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-num27. 命令show spantree显示一个交换机端口的STP状态.28. 配置一个ELAN的LES和BUS,可以使用下列命令:ATM (config)# interface atm number.subint multiointATM(config-subif)# lane serber-bus ethernet elan-name29. 配置LECS:ATM(config)# lane database database-nameATM(lane-config-databade)# name elan1-name server-atm-address les1-nsap-addressATM(lane-config-databade)# name elan2-name server-atm-address les2-nsap-addressATM(lane-config-databade)# name …30. 创建完数据库后,必须在主接口上启动LECS.命令如下:ATM(config)# interface atm numberATM(config-if)# lane config database database-nameATM(config-if)# lane config auto-config-atm-address31. 将每个LEC配置到一个不同的ATM子接口上.命令如下:ATM(config)# interface atm number.subint multipointATM(config)# lane client ethernet vlan-num elan-num32. 用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-stringrouter(config-if)# ip address ip-addr subnet-maskrouter(config-if)# no shutdown38. 用中继链路来建立与VLAN的连接:router(config)# interface module/port.subinterfacerouter(config-ig)# encapsulation[isl|dotlq] vlan-numberrouter(config-if)# ip address ip-address subnet-mask39. 用LANE 来建立与VLAN的连接:router(config)# interface atm module/portrouter(config-if)# no ip addressrouter(config-if)# atm pvc 1 0 5 qsaalrouter(config-if)# atm pvc 2 0 16 ilnirouter(config-if)# interface atm module/port.subinterface multipoint router(config-if)# ip address ip-address subnet-maskrouter(config-if)# lane client ethernet elan-numrouter(config-if)# interface atm module/port.subinterface multipointrouter(config-if)# ip address ip-address subnet-namerouter(config-if)# lane client ethernet elan-namerouter(config-if)# …40. 为了在路由处理器上进行动态路由配置,可以用下列IOS命令来进行: router(config)# ip routingrouter(config)# router ip-routing-protocolrouter(config-router)# network ip-network-numberrouter(config-router)# network ip-network-number41. 配置默认路由:switch(enable) set ip route default gateway42. 为一个路由处理器分配VLANID,可在接口模式下使用下列命令: router(config)# interface interface numberrouter(config-if)# mls rp vlan-id vlan-id-num43. 在路由处理器启用MLSP:router(config)# mls rp ip44. 为了把一个外置的路由处理器接口和交换机安置在同一个VTP域中: router(config)# interface interface numberrouter(config-if)# mls rp vtp-domain domain-name45. 查看指定的VTP域的信息:router# show mls rp vtp-domain vtp domain name46. 要确定RSM或路由器上的管理接口,可以在接口模式下输入下列命令:router(config-if)#mls rp management-interface47. 要检验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 agingtime53. 设置快速老化:switch(enable) set mls agingtime fast fastagingtime pkt_threshold54. 确定那些MLS-RP和MLS-SE参与了MLS,可先显示交换机引用列表中的容再确定:switch(enable) show mls include55. 显示MLS高速缓存记录:switch(enable) show mls entry56. 用命令show in arp显示ARP高速缓存区的容。
交换机和路由器常用命令大全交换机和路由器配置命令Cisco 交换机的命令行模式:1、用户模式Switch>2、特权模式Switch>enableSwitch#3、全局配置模式Switch#config terminalSwitch(config)#4、接口模式Switch(config)#interface fastethernet 0/1Switch(config-if)#Fastethernet表示百兆位以太网接口。
Ethernet表示十兆位以太网接口。
Gigabitethernet表示千兆位以太网接口。
Tengigabitethernet表示万兆位以太网接口。
如果从特权模式回到用户模式,需要输入disable命令,其他无论在那个模式,只要输入命令exit就能回到前一个模式,在全局模式或是接口模式,只要输入命令end都能回到特权模式,或者按下ctrl+z 组合键等效于命令end。
(命令行帮助机制:1、“?”。
2、Tab键。
)常用快捷组合键:Ctrl+A 光标移动到命令行的开始位置。
Ctrl+E 光标移动到命令行的结束位置。
一、常用命令介绍:1、hostname 用于配置主机名,可简写为host.Switch(config)#host sw1Sw1(config)#2、show version 显示系统IOS名称以及版本信息,可简写为sh ver.3、Show running-config 查看交换机当前配置信息,可简写为shrun.4、Show startup-config 显示已保存的配置信息,可简写为sh star.5、Copy running-config startup-config 保存当前配置信息,可简写为copy run star。
这个命令还等效于write(简写为wr)。
保存当前配置如下:Switch#wr 或者switch#copy run star6、erase nvram 删除已保存的配置信息,这命令等效于erasestartup-config.(擦除)。
交换机路由器命令大全(结合配置实例)交换机路由器命令大全(结合配置实例)交换机和路由器是计算机网络中常用的网络设备,用于实现数据包的转发和路由选择。
在实际应用中,我们需要使用命令来配置交换机和路由器的各项参数。
本文将给出交换机和路由器常用命令的大全,并结合实际配置示例进行说明。
一、交换机命令1. 查看交换机基本信息查看交换机型号、固件版本、序列号等基本信息:show version2. 配置交换机端口设置交换机接口的速率、全双工模式等参数:interface interface_namespeed speed_valueduplex {full | half}3. 查看交换机端口状态查看交换机端口的连接状态、速率、工作模式等信息:show interfaces status4. 配置交换机VLAN创建VLAN和端口关联,实现VLAN的隔离和管理:vlan vlan_idname vlan_nameinterface interface_name5. 查看交换机MAC表显示交换机学习到的MAC地址和对应的端口:show mac-address-table6. 配置交换机链路聚合将多个物理端口绑定为一个逻辑端口,提高带宽和冗余性:interface port-channel channel_numberdescription description_textswitchport mode trunk/access7. 交换机Spanning Tree配置配置交换机的Spanning Tree协议参数,避免网络环路:spanning-tree vlan vlan_idpriority priority_value二、路由器命令1. 查看路由表显示路由器的路由表,包括直连路由、静态路由和动态路由表项:show ip route2. 配置静态路由手动配置路由器的静态路由表,指定目的网络和下一跳信息:ip route destination_network subnet_mask next_hop_ip3. 配置路由器接口配置路由器的接口参数,包括IP地址、子网掩码、描述等:interface interface_nameip address ip_address subnet_maskdescription description_text4. 配置路由器OSPF协议配置路由器之间的OSPF动态路由协议,实现网络的动态路由选择:router ospf process_idnetwork network_address wildcard_mask area area_number5. 配置路由器ACL配置路由器的访问控制列表,用于控制数据包的流量:access-list access_list_number permit/deny source destination6. 配置路由器NAT配置路由器的网络地址转换功能,实现内网与外网的互通:interface interface_nameip nat inside/outside三、配置实例1. 配置交换机端口接口GigabitEthernet0/1配置为100Mbps全双工模式:interface GigabitEthernet0/1speed 100duplex full2. 配置交换机VLAN创建VLAN10,将接口GigabitEthernet0/1划分到VLAN10:vlan 10name VLAN10interface GigabitEthernet0/13. 配置路由器接口将接口GigabitEthernet0/0配置为192.168.1.1/24的IP地址:interface GigabitEthernet0/0ip address 192.168.1.1 255.255.255.0description LAN interface4. 配置静态路由配置路由器的静态路由表,将目的网络192.168.2.0/24指向下一跳192.168.1.2:ip route 192.168.2.0 255.255.255.0 192.168.1.25. 配置路由器ACL设置访问控制列表,允许源IP地址为192.168.1.0/24的流量通过:access-list 1 permit 192.168.1.0 0.0.0.2556. 配置路由器NAT设置路由器的NAT,将内部接口GigabitEthernet0/1地址转换为公网地址:interface GigabitEthernet0/1ip nat inside以上是交换机和路由器常用命令的大全以及配置实例。
使用的是cisco网络设备操作系统命令,其他厂商设备应该相差不远,实验使用的设备时cisco catalyst1912交换机和cisco 2621路由器。
终端的IP配置命令:Ipconfig /ip IP地址子网掩码;Ipconfig /dg 网关IP常用的交换机的配置命令:交换机工作在OSI 模型的第二层(数据链路层), 地址学习, 转发过滤, 消除循环是交换机的三个主要功能。
有三种模式,“>”用户模式,“#”特权模式,“(CONFIG)#”全局模式.从用户模式进入特权模式:enable从特权模式进入全局模式:configure terminal,在特权模式下输入disable或者exit 回到用户模式,其他模式类似。
从全局模式进入端口模式:interface e0/1。
switch: ;ROM状态,路由器是rommon>hostname> ;用户模式hostname# ;特权模式hostname(config)# ;全局配置模式hostname(config-if)# ;接口状态用户模式(>)下:可以查看一些基本的配置信息。
特权模式(#)下:show ip 查看交换机的IP地址。
Show interface 查看所有端口的配置信息show interfaces Ethernet 0/1 查看E0/1口的信息Show interface e0/1 查看e0/1端口的配置信息。
show version 查看系统硬件的配置,软件版本号等。
show port ;(CatOS)显示每个端口的简要信息(号、VLAN、双工、…)show interface ;(IOS)show trunk ;(CatOS)显示中继信息(模式、封装、允许端口、剪裁、…)show interface trunk ;(IOS)show spantree 45 ;(CatOS)显示端口的STP模式、类型、状态、速端口、…) show spanning-tree 45 ;(IOS)Show running-config (show running也可以)查看当前正在运行的配置信息全局模式//配置模式((config)#):设置交换机名:hostname[交换机名]如:hostname switch1设置交换机的IP地址:ip address [ip address ][netmask]如ip address 172.16.0.1 255.255.0.0设置交换机的缺省网关:ip default-gatway [ip address]如:ip default-gatway 172.16.0.1设置密码enable password level [1-15] [passwork]1-15 表示级别,1表示设置登录时的密码,15设置进入全局模式的密码。
H3C交换机和路由器常用命令注释原文地址:H3C交换机和路由器常用命令注释作者:济南百谷信息、system-view 进入系统视图模式2、sysname 为设备命名3、display current-configuration 当前配置情况4、language-mode Chinese|English 中英文切换5、interface Ethernet 1/0/1 进入以太网端口视图6、port link-type Access|Trunk|Hybrid 设置端口访问模式7、undo shutdown 打开以太网端口8、shutdown 关闭以太网端口9、quit 退出当前视图模式10、vlan 10 创建VLAN 10并进入VLAN 10的视图模式11、port access vlan 10 在端口模式下将当前端口加入到vlan 10中12、port E1/0/2 to E1/0/5 在VLAN模式下将指定端口加入到当前vlan中13、port trunk permit vlan all 允许所有的vlan通过H 3C路由器常用命令注释1、system-view 进入系统视图模式2、sysname R1 为设备命名为R13、display ip routing-table 显示当前路由表4、language-mode Chinese|English 中英文切换5、interface Ethernet 0/0 进入以太网端口视图6、ip address 192.168.1.1 255.255.255.0 配置IP地址和子网掩码7、undo shutdown 打开以太网端口8、shutdown 关闭以太网端口9、quit 退出当前视图模式10、ip route-static 192.168.2.0 255.255.255.0 192.168.12.2 description To.R2 配置静态路由11、ip route-static 0.0.0.0 0.0.0.0 192.168.12.2 description To.R2 配置默认的路由H3C S3100 SwitchH3C S3600 SwitchH3C MSR 20-20 Router小技巧1、调整超级终端的显示字号;2、捕获超级终端操作命令行,以备日后查对;3、language-mode Chinese|English 中英文切换;4、复制命令到超级终端命令行,粘贴到主机;5、交换机清除配置:<H3C>reset save ;<H3C>reboot ;6、路由器、交换机配置时不能掉电,连通测试前一定要检查网络的连通性,不要犯最低级的错误。
7、192.168.1.1/24 等同192.168.1.1 255.255.255.0;在配置交换机和路由器时,192.168.1.1 255.255.255.0 可以写成:192.168.1.1 248、设备命名规则:地名-设备名-系列号例:PingGu-R-S3600一、交换机简单管理协议增加指令----以便接入华为的管理软件中snmp-agentsnmp-agent community read publicsnmp-agent community write privatesnmp-agent sys-info version v1 v3snmp-agent trap enable备注:每台新增的交换机均需加入上述指令集合,否则不能为管理软件所管理二、将新增交换机的VLAN1段设置IP地址interface vlan 1ip address 10.63.0.1 255.255.254.0三、华为交换机指令的相关案例Quidway]super password 修改特权用户密码[Quidway]sysname 交换机命名[Quidway]interface ethernet 0/1 进入接口视图[Quidway]interface vlan x 进入X段VLAN接口视图[Quidway-Vlan-interfacex]ip address 10.65.1.1 255.255.0.0 为VLAN段设置地址[Quidway]ip route-static 0.0.0.0 0.0.0.0 10.65.1.2 静态路由=网关[Quidway]user-interface vty 0 4[S3026-ui-vty0-4]authentication-mode password[S3026-ui-vty0-4]set authentication-mode password simple 222[S3026-ui-vty0-4]user privilege level 3[Quidway-Ethernet0/1]duplex {half|full|auto} 配置端口双工工作状态[Quidway-Ethernet0/1]speed {10|100|auto} 配置端口工作速率[Quidway-Ethernet0/1]flow-control 配置端口流控[Quidway-Ethernet0/1]mdi {across|auto|normal} 配置端口MDI/MDIX状态平接或扭接[Quidway-Ethernet0/1]port link-type {trunk|access|hybrid} 设置接口工作模式[Quidway-Ethernet0/1]shutdown 关闭/重起接口[Quidway-Ethernet0/2]quit 退出系统视图[Quidway]vlan 3 创建/删除一个VLAN/进入VLAN模式[Quidway-vlan3]port ethernet 0/1 to ethernet 0/4 在当前VLAN增加/删除以太网接口[Quidway-Ethernet0/2]port access vlan 3 将当前接口加入到指定VLAN [Quidway-Ethernet0/2]port trunk permit vlan {ID|All} 设trunk允许的VLAN [Quidway-Ethernet0/2]port trunk pvid vlan 3 设置trunk端口的PVID[Quidway]monitor-port <interface_type interface_num> 指定和清除镜像端口[Quidway]port mirror <interface_type interface_num> 指定和清除被镜像端口[Quidway]port mirror int_list observing-port int_type int_num 指定镜像和被镜像[Quidway]description string 指定VLAN描述字符[Quidway]description 删除VLAN描述字符[Quidway]display vlan [vlan_id] 查看VLAN设置[Quidway]stp {enable|disable} 开启/关闭生成树,默认关闭[Quidway]stp priority 4096 设置交换机的优先级[Quidway]stp root {primary|secondary} 设置交换机为根或根的备份[Quidway-Ethernet0/1]stp cost 200 设置交换机端口的花费[SwitchA-vlanx]isolate-user-vlan enable 设置主vlan[SwitchA]Isolate-user-vlan <x> secondary <list> 设置主vlan包括的子vlan[Quidway-Ethernet0/2]port hybrid pvid vlan <id> 设置vlan的pvid [Quidway-Ethernet0/2]port hybrid pvid 删除vlan的pvid[Quidway-Ethernet0/2]port hybrid vlan vlan_id_list untagged 设置无标识的vlan如果包的vlan id与PVId一致,则去掉vlan信息. 默认PVID=1。
所以设置PVID为所属vlan id, 设置可以互通的vlan为untagged.----------------------------------------、system-view 进入系统视图模式2、sysname 为设备命名3、display current-configuration 当前配置情况4、language-mode Chinese|English 中英文切换5、interface Ethernet 1/0/1 进入以太网端口视图6、port link-type Access|Trunk|Hybrid 设置端口访问模式7、undo shutdown 打开以太网端口8、shutdown 关闭以太网端口9、quit 退出当前视图模式10、vlan 10 创建VLAN 10并进入VLAN 10的视图模式11、port access vlan 10 在端口模式下将当前端口加入到vlan 10中12、port E1/0/2 to E1/0/5 在VLAN模式下将指定端口加入到当前vlan中13、port trunk permit vlan all 允许所有的vlan通过H3C路由器常用命令注释1、system-view 进入系统视图模式2、sysname R1 为设备命名为R13、display ip routing-table 显示当前路由表4、language-mode Chinese|English 中英文切换5、interface Ethernet 0/0 进入以太网端口视图6、ip address 192.168.1.1 255.255.255.0 配置IP地址和子网掩码7、undo shutdown 打开以太网端口8、shutdown 关闭以太网端口9、quit 退出当前视图模式10、ip route-static 192.168.2.0 255.255.255.0 192.168.12.2 description To.R2 配置静态路由11、ip route-static 0.0.0.0 0.0.0.0 192.168.12.2 description To.R2 配置默认的路由H3C S3100 SwitchH3C S3600 SwitchH3C MSR 20-20 Router小技巧1、调整超级终端的显示字号;2、捕获超级终端操作命令行,以备日后查对;3、language-mode Chinese|English 中英文切换;4、复制命令到超级终端命令行,粘贴到主机;5、交换机清除配置:<H3C>reset save ;<H3C>reboot ;6、路由器、交换机配置时不能掉电,连通测试前一定要检查网络的连通性,不要犯最低级的错误。