路由器和交换机命令大全

合集下载

[修订]神州数码常用交换机和路由命令集

[修订]神州数码常用交换机和路由命令集

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-address switch(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.基于IOS1000的交换机的端口描述: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 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 Fas1000t 特征: 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,可以使用下列命令:A TM (config)# interface atm number.subint multiointA TM(config-subif)# lane serber-bus ethernet elan-name29. 配置LECS:A TM(config)# lane database database-nameA TM(lane-config-databade)# name elan1-name server-atm-address les1-nsap-address A TM(lane-config-databade)# name elan2-name server-atm-address les2-nsap-addressA TM(lane-config-databade)# name …30. 创建完数据库后,必须在主接口上启动LECS.命令如下:A TM(config)# interface atm numberA TM(config-if)# lane config database database-nameA TM(config-if)# lane config auto-config-atm-address31. 将每个LEC配置到一个不同的A TM子接口上.命令如下:A TM(config)# interface atm number.subint multipointA TM(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 multipointrouter(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,可在接口模式下使用下列命令:1000router(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高速缓存区的内容。

交换机路由器命令

交换机路由器命令

帧中继命令:router(config)#frame-relay switching ;使能帧中继交换router(config-s0)#encapsulation frame-relay ;使能帧中继router(config-s0)#fram-relay lmi-type cisco ;设置管理类型router(config-s0)#frame-relay intf-type DCE ;设置为DCErouter(config-s0)#frame-relay dlci 16 ;router(config-s0)#frame-relay local-dlci 20 ;设置虚电路号router(config-s0)#frame-relay interface-dlci 16 ;router(config)#log-adjacency-changes ;记录邻接变化router(config)#int s0/0.1 point-to-point ;设置子接口点对点router#show frame pvc ;显示永久虚电路router#show frame map ;显示映射基本访问控制列表:router(config)#access-list permit|denyrouter(config)#interface ;default:deny anyrouter(config-if)#ip access-group in|out ;default:out例1:router(config)#access-list 4 permit 10.8.1.1router(config)#access-list 4 deny 10.8.1.0 0.0.0.255router(config)#access-list 4 permit 10.8.0.0 0.0.255.255router(config)#access-list 4 deny 10.0.0.0 0.255.255.255router(config)#access-list 4 permit anyrouter(config)#int f0/0router(config-if)#ip access-group 4 in扩展访问控制列表:access-list permit|deny icmp <DESTINATIONIPwild>[type]access-list permit|deny tcp <DESTINATIONIPwild>[port]例3:router(config)#access-list 101 deny icmp any 10.64.0.2 0.0.0.0 echorouter(config)#access-list 101 permit ip any anyrouter(config)#int s0/0router(config-if)#ip access-group 101 in例3:router(config)#access-list 102 deny tcp any 10.65.0.2 0.0.0.0 eq 80router(config)#access-list 102 permit ip any anyrouter(config)#interface s0/1router(config-if)#ip access-group 102 out删除访问控制例表:router(config)#no access-list 102router(config-if)#no ip access-group 101 in路由器的nat配置Router(config-if)#ip nat inside ;当前接口指定为内部接口Router(config-if)#ip nat outside ;当前接口指定为外部接口Router(config)#ip nat inside source static [p] <私有IP><公网IP> [port]Router(config)#ip nat inside source static 10.65.1.2 60.1.1.1 Router(config)#ip nat inside source static tcp 10.65.1.3 80 60.1.1.1 80Router(config)#ip nat pool p1 60.1.1.1 60.1.1.20 255.255.255.0 Router(config)#ip nat inside source list 1 pool p1Router(config)#ip nat inside destination list 2 pool p2Router(config)#ip nat inside source list 2 interface s0/0 overload Router(config)#ip nat pool p2 10.65.1.2 10.65.1.4 255.255.255.0 type rotaryRouter#show ip nat translationrotary 参数是轮流的意思,地址池中的IP轮流与NAT分配的地址匹配。

交换机路由器配置命令大集合

交换机路由器配置命令大集合

配置命令大集合一、常用的子网掩码及反掩码/30 255.255.255.252 0.0.0.3/29 255.255.255.248 0.0.0.7/28 255.255.255.240 0.0.0.15/27 255.255.255.224 0.0.0.31/26 255.255.255.192 0.0.0.63/25 255.255.255.128 0.0.0.127/24 255.255.255.0 0.0.0.255/23 255.255.254.0 0.0.1.255/22 255.255.252.0 0.0.3.255/21 255.255.248.0 0.0.7.255/20 255.255.240.0 0.0.15.255二、锐捷交换机交换技术1、跨交换机实现VLAN互通交换机间相连端口模式下switch(config-if)#switchport mode trunk2、Trunk 口的运行VLAN列表步骤1:进入全局配置模式Switch#configure terminal步骤2:进入需要配置为Trunk的端口Switch(config)#interface interface步骤3:定义该端口模式为TrunkSwitch(config-range-if)#switchport mode trunk步骤4:定义Trunk的VLAN列表Switch(config-if)#switchport trunk allowed vlan { all | [ add | remove | except ] } vlan-list3、Native VLAN的概念与配置步骤1:进入到需要配置的Trunk端口中swtich(config)#interface interface步骤2:配置Trunk的Native VLANSwitch(config-if)#switchport trunk native vlan vlan-id4、链路聚合的配置建立聚合端口switch(config)#interface range fastEthernet 0/1 – 2switch(config-if-range)#port-group 1聚合端口设Trunk口switch(config)#interface aggregateport 1switch(config-if)# switchport mode trunk5、交换机上配置TelnetTelnet密码型:switch(config)#enable passwd 0 star //配置enable 密码或switch(config)#enable secret level 15 0 start(默认是level 15)switch(config)#line vty 0 4switch(config-line)#password 0 star //配置Telnet密码或switch(config)#enable secret level 1 0 start (level 1 为Telnet密码)switch(config-line)#loginTelnet用户+密码型:switch(config)#enable passwd 0 star //配置enable 密码switch(config)#username 用户名password 密码//配置Telnet用户和Telnet 密码switch(config)#line vty 0 4 switch(config-line)#login local6、生成树协议技术switch(config)#spanning-tree mode stp/rstp/mstpswitch(config)#spanning-tree mst configurationswitch(config-mst)#instance <实例名> vlan <vlanid 1> ,<vlanind 2>…switch(config-mst)#name <mst 配置名>switch(config-mst)#revision <版本名>switch(config-mst)# spanning-tree mst <实例名> priority <优先级号>(数字越小,优先级越高,最小者为根网桥)7、VRRP(虚拟路由冗余协议)技术(有几个vrrp网关就要设几个,每个交换机都要设置)switch(config-if)#vrrp <组名> ip <ip-address>switch(config-if)#vrrp <组名> preempt //设置抢占模式switch(config-if)#vrrp <组名> priority <优先级号>(数字越小,优先级越高,默认为100,最小者为主控虚拟路由,其余为备份虚拟路由)三、锐捷路由器路由技术1、三层交换机路由功能配置switch(config)#ip routing switch(config-if)#no switchport2、SVI实现VLAN间路由步骤1 开启路由功能(默认)Switch(config)#ip routing步骤2 创建VLAN Switch(config)#vlan vlan-id步骤3 进入VLAN的SVI接口配置模式Switch(config)#interface vlan vlan-id 步骤4 给SVI接口配置IP地址Switch(config-if)#ip address ip-address mask (如果VLAN内没有激活的端口,相应VLAN的SVI端口将无法被激活)交换机相连端口设置为tag vlan 模式,PC网关为相应VLAN的SVI接口地址3、单臂路由实现VLAN间路由Router(config)#int 端口Router(config-if)#no ip add Router(config-if)#no shu步骤1:创建以太网子接口Router(config)#interface interface.sub-port步骤2:为子接口封装802.1q协议,并指定接口所属的VLANRouter(config-subif)#encapsulation dot1q vlan-id步骤3:为子接口配置IP地址Router(config-subif)#ip address ip-address mask-address步骤4:启用子接口Router(config-subif)#no shutdown在给理由器子接口配置ip地址前先封装dot1q协议,各个Vlan的主机要以相应VLAN子接口的IP地址作为网关。

小结那些和路由器交换机相关的命令

小结那些和路由器交换机相关的命令

「基础配置」进入console口进行本地配置用户模式 xx>enable n特权模式 xx#configure terminal 全局配置模式 xx(config)#interface [f|s] n/m进入接口配置模式xx(config-if)# 进入(子)接口模式后配置IP(config-if)#ip addr A.B.C.D 子网掩码激活接口(config-if)#no shutdown配置速度(config-if)#speed {auto|10|100}配置接口工作模式(config-if)#duplex {auto|half|full}配置时钟(串行口DCE端) (config-if)#clock rate n反向操作(删除配置)no + 命令在换回接口上配多个ip(config-if)#ip addr A.B.C.D 子网掩码(config-if)#ip addr A.B.C.D 子网掩码secondary查看所有配置#show running-config 路由器关闭路由功能充当主机(config)#no ip routing为路由器设置网关(config)#ip default-gateway ip地址改机器名字(config)#hostname yy控制线路超时(config)#line n(config-line)#exec-timeout 0 0关闭域名解析功能(config)#no ip domain-lookup开启路由器http功能(config)#ip http server(config)#username xxx password yyy(config)#username xxx secret yyy(config)#enable secret yyy启用密码加密服务(config)#service password-encryption yyy开启路由器https功能(config)#ip http secure-server开启路由器远程登录功能(config)#line vty 0 4(config)#login local 或者(config)#no login(config)#enable n登录时使用命令telnet A.B.C.D「交换机」查看mac地址表#show mac-address-table绑定静态mac地址(config)#mac-address-table static H.H.H vlan n interface fx/x #show arp在主机上使用arp -a查看arp信息开启交换机端口安全(防止连接主机恶意发送随机mac填满mac 地址表) (conifg)#switchport port-security(conifg)#switchport ?#show port-security int fx/x恢复(config)#errdisable recovery为交换机vlan1配置管理ip(conifg)#int vlan 1(config-if)#ip addr A.B.C.D 子网掩码(config-if)#no shut「交换机vlan」查看vlan #show vlan-switch或是#show vlan创建vlan #vlan database(vlan)#vlan n将端口加入到vlan中(config-if)#switchport access vlan n给允许多个vlan的接口打trunk(config-if)#switchport mode trunk「单臂路由vlan」路由器上配置子接口实现不同vlan之间通信,先必须激活其父接口,另外IP不允许重复(config)#interface fx/x.x(config-subif)#encapsulation dot1q vlan-id(config-subif)#ip addr A.C.D.E 子网掩码(config-subif)#no shut「使用三层交换机交换虚拟接口」交换机上配置虚拟交换接口实现不同vlan之间通信,先必须在交换机上添加对应vlan(config)#int vlan n(config-if)#ip addr A.B.C.D 子网掩码(config-if)#no shut在删除时,务必先删除交换虚拟接口,再删对应vlan「VTP」配置VTP模式#vlan database(vlan)#vtp {server|client|transparent}只有域名和密码完全一样的路由器之间才能同步vlan信息(vlan)#vtp domain <域名>(vlan)#vtp password <密码>打开VTP裁剪(vlan)#vtp pruning退出激活(vlan)#exit「端口聚合」创建R1(config)#interface port-channel 1(config-if)#switchport trunk encapsulation dot1q(config-if)#switchport mode trunk将指定接口加入聚合组内#int range f x/x-x #channel-group 1 mode on查看聚合接口#show etherchannel summary「生成树协议」基于vlan的生成树可防止环路开启生成树协议(STP默认是开启的,可省略) (config)#spanning-tree vlan n修改生成树协议优先级(根网桥:mac最小、优先级最小) (config)#spanning-tree vlan n priority m交换机和主机之间连接的端口开启portfast,可防止主机发送BPDU伪造数据(config-if)#spanning-tree portfast查看生成树#show spanning-tree [vlan n]「静态路由」查看协议#show ip protocols查看路由表#show ip route添加静态路由(以默认路由举例) (config)#ip route 0.0.0.0 0.0.0.0{出接口|下一跳ip}浮动静态路由(备份链路,在原链路失效后起作用) (config)#ip route 0.0.0.0 0.0.0.0 出接口 AD管理距离静态黑洞路由(config)#ip route 192.168.0.0 255.255.0.0 null 0「RIP距离矢量路由,动态路由」配置RIP宣告直连网段(config)#router rip(config-router)#network 网段更改为版本2(config-router)#version {2|1}关闭自动汇总(如果被其他网路隔开时,最好关闭自动汇总) (config-router)#no auto-summary设置被动接口(只接受更新,不宣告自己) (config-router)#passive-interface 接口单播更新(只和指定的ip交换路由信息) (config-router)#neighbor ip地址清除路由表内容#clear ip route *「OSPF链路状态路由,动态路由」配置OSPF宣告直连网路(config)#router ospf <进程号>(config-router)#router-id <任意ip地址>(config-router)#network <反掩码> area n 重启OSPF进程#clear ip ospf process查看接口的OSPF信息#show ip ospf interface 查看邻居表#show ip ospf neighbor查看链路数据表#show ip ospf database「EIGRP链路状态路由,动态路由」配置EIGRP宣告直连网路(config)#router eigrp <系统编号>(config-router)#network 查看邻居表#show ip eigrp neighbors查看拓扑表#show ip eigrp topology「VRRP虚拟路由器路由协议」提供网关冗余查看VRRP信息#show vrrp <?> VRRP配置(在提供备份的两台路由器上做以下配置)端口跟踪(监视某个接口的状态)(config)#track 1 interface 接口 line-protocol(config-if)#vrrp <1~254> ip <ip 地址>额外配置优先级(IP和优先级越大Master)和抢占(config-if)#vrrp <1~254> priority <1~254>(config-if)#vrrp <1~254> preempt(config-if)#vrrp 1 track 1 decrement <1~255>「访问控制列表ACL」 ACL无法控制自身发起的流量,对于已经建立的流量不起作用标准ACL(不能单独删除、添加一条访问列表)(config)#access-list <1~99|1300~1999> {permit|deny} ip地址反掩码扩展ACL(config)#access-list <100-199> {permit|deny} <协议> <源ip> <反掩码> <源端口> <目标ip> <反掩码> <目标端口>应用到指定ACL到某个接口(config)#int 接口(config-if)#ip access-group <1~99|100-199|1300~1999> {in|out}命名ACL(config)#ip access-list standard <标准ACL名字>(config-std-nacl)#{permit|deny} ip地址反掩码(config)#ip access-list extended <扩展ACL名字>(config-ext-nacl)#{permit|deny} <协议> <源ip> <反掩码> <源端口> <目标ip> <反掩码> <目标端口>应用到指定ACL到某个接口(config)#int 接口(config-if)#ip access-group <标准ACL名字|扩展ACL名字> {in|out}自反ACL(RACL,可以只允许内网主动发起的流量通过)(config)#ip access-list extended OUTB (config-ext-nacl)#permit tcp any any reflect RACL(config)#ip access-list extended INB(config-ext-nacl)#evaluate RACL(config-ext-nacl)#deny ip any any应用到指定ACL到某个接口(config-if)#ip access-group OUTB out(config-if)#ip access-group INB in基于时间的ACL设置时区时间(config)#clock timezone GMT +8 #clock set hh:mm:ss <日> <月> <年>定义时间(config)#time-range <时间名>(config-time-range)#periodic <?> hh:mm to hh:mm(config-time-range)#absolute start hh:mm:ss <日> <月> <年> end hh:mm:ss <日> <月> <年>结合ACL(config)#ip access-list extended <扩展ACL名字>(config-ext-nacl)#deny tcp any any time-range <时间名>「NAT和PAT」定义内外网接口(config)#int 接口(config-if)#ip nat {inside|outside}静态NAT (config)#ip nat inside source static ip地址 <?>静态PAT(config)#ip nat inside source static <协议> ip地址 <端口号> <?>使用ACL捕获流量(config)#access-list n permit ip地址反掩码(config)#ip nat pool <地址池名> <起始ip地址> <终止ip 地址> netmask 掩码TCP负载均衡(轮询转换)(config)#ip nat pool <地址池名> <起始ip地址> <终止ip地址> netmask 掩码 type rotary动态NAT(config)#ip nat insidesource list n pool <地址池名>动态PAT(config)#ip nat inside source list n pool <地址池名> overload查看转换项#show ip nat translations「广域网PPP协议」在串行口上的两台路由器都封装ppp协议(config)#int sx/x(config-if)#encapsulation ppp(config-if)#no shut启用PAP认证,未加密认证方(config)#username <用户名> password <密码>(config-if)#ppp authentication pap请求认证方(config-if)#ppp pap sent-username <用户名> password <密码>启用CHAP认证,安全加密认证方(config)#username <请求认证方名> password <请求认证方密码>(config-if)#ppp authentication chap请求认证方(config)#username <认证方名> password <认证方密码>(config-if)#ppp authentication chap「帧中继」无广播的多路访问网络(NBMA)配置帧中继交换机关闭路由器路由功能(config)#no ip routing启用帧中继(config)#frame-relay switching进入串行接口R8(config)#int sx/x封装frame-relay 协议R8(config-if)#encapsulation frame-relay指定lmi-type类型(config-if)#frame-relay lmi-type cisco指定intf-type接口类型为DCE(config-if)#frame-relay intf-type dce配置时钟频率(config-if)#clock rate n配置DLCI(config-if)#frame-relay route <进DLCI号> int <出接口> <出DLCI号>配置路由器,封装frame-relay协议(config-if)#encapsulation frame-relay静态指定映射(config-if)#frame-relay map ip 清除动态学到的Frame Relay #clear frame-relay-inarp 查看映射#show frame-relay map调试#debug frame-relay lmi点到多点(解决水平分割问题,划分子接口)适用于全互联和部分互联(config)#int sx/x(config-if)#encapsulation frame-relay(config)#int sx/x.x multipoint关闭反向arp,禁止自学习DLCI号和IP对应,而采取静态Map(config-subif)#no frame-relay inverse-arp静态映射DLCI号和IP(config-subif)#frame-relay map ip broadcast如在R1上对R3 DLCI号103 IP地址192.168.1.3点到点子接口(不存在水平分割问题)子接口可以看作是专线,适用于星型(config)#int sx/x(config-if)#encapsulation frame-relay(config)#int sx/x.x point-to-point(config-subif)#frame-relay interface-dlci。

最新、最全cisco路由器交换机配置命令汇总。

最新、最全cisco路由器交换机配置命令汇总。

路由/交换机命令大全~!交换机命令switch> 用户模式1:进入特权模式enableswitch> enableswitch#2:进入全局配置模式configure terminalswitch> enableswitch#c onfigure terminalswitch(conf)#3:交换机命名hostname aptech2950 以aptech2950为例switch> enableswitch#c onfigure terminalswitch(conf)#hostname aptch-2950aptech2950(conf)#4:配置使能口令enable password cisco 以cisco为例switch> enableswitch#c onfigure terminalswitch(conf)#hostname aptch2950aptech2950(conf)# enable password cisco5:配置使能密码enable secret ciscolab 以cicsolab为例switch> enableswitch#c onfigure terminalswitch(conf)#hostname aptch2950aptech2950(conf)# enable secret ciscolab6:设置虚拟局域网vlan 1 interface vlan 1switch> enableswitch#c onfigure terminalswitch(conf)#hostname aptch2950aptech2950(conf)# interface vlan 1aptech2950(conf-if)#ip address 192.168.1.1 255.255.255.0 配置交换机端口ip和子网掩码aptech2950(conf-if)#no shut是配置处于运行中aptech2950(conf-if)#exitaptech2950(conf)#ip default-gateway 192.168.254 设置网关地址7:进入交换机某一端口interface fastehernet 0/17以17端口为例switch> enableswitch#c onfigure terminalswitch(conf)#hostname aptch2950aptech2950(conf)# interface fastehernet 0/17aptech2950(conf-if)#8:查看命令showswitch> enableswitch# show version 察看系统中的所有版本信息show interface vlan 1 查看交换机有关ip 协议的配置信息show running-configure 查看交换机当前起作用的配置信息show interface fastethernet 0/1 察看交换机1接口具体配置和统计信息show mac-address-table 查看mac地址表show mac-address-table aging-time 查看mac地址表自动老化时间9:交换机恢复出厂默认恢复命令switch> enableswitch# erase startup-configureswitch# reload10:双工模式设置switch> enableswitch#c onfigure terminalswitch2950(conf)#hostname aptch-2950aptech2950(conf)# interface fastehernet 0/17以17端口为例aptech2950(conf-if)#duplex full/half/auto有full , half, auto 三个可选项11:cdp相关命令switch> enableswitch# show cdp 查看设备的cdp全局配置信息show cdp interface fastethernet 0/17 查看17端口的cdp配置信息show cdp traffic 查看有关cdp包的统计信息show cdp nerghbors 列出与设备相连的cisco设备12:csico2950的密码恢复拔下交换机电源线。

交换机路由器基本命令

交换机路由器基本命令

准备工作:1)SecureCRT 软件(推荐使用8.0注册机版)2)console线一条,RS232转USB线一条(淘宝购买)RS232转USB线插在电脑上,打开设备管理(快捷键devmgmt.msc),就会有提示,用360驱动(或其他驱动软件)打上即可。

下图为驱动安装成功后的设备管理器界面(本人电脑系统为win10)。

注意:com口与电脑上USB口是对应的,接在另一个USB口,com口的序号会变化。

file:///C:/Users/Potter/AppData/Local/Temp/msohtmlclip1/01/clip_image 002.jpg3)电脑一台4)网络基础知识(OSI,IP,路由交换基础等)5)登陆设备 ( CLI命令行)设备-----Console—RS232-USB---电脑,打开SecureCRT软件file:///C:/Users/Potter/AppData/Local/Temp/msohtmlclip1/01/clip_image 004.jpg一,锐捷交换机 ( 和cisco命令类似)1,设备登陆Web登陆:192.168.1.1admin/adminConsole密码:默认为空,如果不行试试ruijie / admin2,系统基本配置!enable //进入用户模式,华为H3C无对应命令clockset 10:00:00 3 17 2017//clock set 小时:分:秒月日年!config//进入全局模式,对应华为H3C的sys hostname xx //修改设备名称!3,配置vlan!config//进入全局模式vlan 10name xxx//创建一个vlan,并命名vlan 20name xxxexit!no vlan 10 //删除一个vlan!int range gi 0/2-4sw mo ac//配置多个接口为access模式sw ac vl 10//配置多个接口加入vlan10exit!int range gi 0/5-8sw mo tr//配置多个接口为trunk模式sw tr al vl al//配置trunk模式下,接口允许所有vlan(1-4094)通过sw tr na vl 20//配置多个接口为trunk,并指定native vlan为20sw tr al vl remove xx //配置trunk模式下,接口不允许哪些vlan不通过sw tr al vl add xx//配置trunk模式下,接口添加哪些vlan允许通过exit!!sh vlan//查看 vlan 信息,包括 vlan id、名称、状态、包括的接口!sh int gi 0/2 sw//查看接口 Gi 0/2 的 vlan 状态!4,配置接口!configint gi 0/1des xx //给接口配置描述ip add 1.1.1.1 255.255.255.0//路由口配置IP地址,交换口无法直接配置no sh!int vlan 10des xx//给SVI接口配置描述ip add 172.16.10.1 255.255.255.0//创建SVI接口,一般为作为网关或管理地址!注意:SVI接口状态跟是否创建vlan,以及是否存在加入该vlan的up状态的接口。

路由交换机命令大全

路由/交换机命令大全~!交换机命令switch> 用户模式1:进入特权模式 enableswitch> enableswitch#2:进入全局配置模式 configure terminalswitch> enableswitch#c onfigure terminalswitch(conf)#3:交换机命名 hostname aptech2950 以aptech2950为例switch> enableswitch#c onfigure terminalswitch(conf)#hostname aptch-2950aptech2950(conf)#4:配置使能口令 enable password cisco 以cisco为例switch> enableswitch#configure terminalswitch(conf)#hostname aptch2950aptech2950(conf)# enable password cisco5:配置使能密码 enable secret ciscolab 以cicsolab 为例switch> enableswitch#c onfigure terminalswitch(conf)#hostname aptch2950aptech2950(conf)# enable secret ciscolab6:设置虚拟局域网vlan 1 interface vlan 1switch> enableswitch#c onfigure terminalswitch(conf)#hostname aptch2950aptech2950(conf)# interface vlan 1aptech2950(conf-if)#ip address 192.168.1.1255.255.255.0 配置交换机端口ip和子网掩码aptech2950(conf-if)#noshut是配置处于运行中aptech2950(conf-if)#exitaptech2950(conf)#ip default-gateway设置端口VLANSwitch>conf tSwitch(sonfig)#vlan 1 name ** (命名**)Switch(config)#int e0/2 (进入端口)Switch(config)#vlan-menbership static(静态) 1192.168.254 设置网关地址如何在交换机上配置VLAN 责任编辑:admin 更新日期:2005-8-61.设置VLAN名称2.应用到端口我们先设置VLAN的名称。

神州数码交换机路由器配置命令(2023最新版)

神州数码交换机路由器配置命令神州数码交换机路由器配置命令章节一:引言⑴文档目的本文档旨在提供神州数码交换机路由器的详细配置命令,以指导管理员进行设备的初始化和配置。

⑵背景神州数码交换机路由器是一种用于数据传输的网络设备,拥有多种功能和特性。

本文档将介绍如何使用各种命令来配置交换机路由器的不同功能。

⑶受众本文档适用于所有需要配置神州数码交换机路由器的管理员和网络工程师。

章节二:初始化设备⑴登录设备使用如下命令登录设备:`login`⑵修改设备密码使用如下命令修改设备密码:`configure terminalenable secret [password]`章节三:基本配置⑴设置主机名使用如下命令设置设备的主机名:`configure terminalhostname [hostname]`⑵配置IP地质使用如下命令配置设备的IP地质:`configure terminalinterface [interface]ip address [ip-address] [subnet-mask]`⑶设置默认网关使用如下命令设置设备的默认网关:`configure terminalip default-gateway [gateway-address]`章节四:VLAN配置⑴创建VLAN使用如下命令创建一个新的VLAN:`configure terminalvlan [vlan-id]name [vlan-name]`⑵将接口加入VLAN使用如下命令将接口加入指定的VLAN:`configure terminalinterface [interface]switchport mode accessswitchport access vlan [vlan-id]`章节五:路由配置⑴静态路由使用如下命令配置静态路由:`configure terminalip route [destination-network] [subnet-mask] [next-hop]`⑵动态路由使用如下命令配置动态路由协议:`configure terminalrouter [routing-protocol]network [network-address] [subnet-mask]`章节六:安全配置⑴访问控制列表(ACL)使用如下命令配置ACL:`configure terminalaccess-list [acl-number] [permit----deny] [source] [destination] [protocol]`⑵端口安全使用如下命令配置端口安全:`configure terminalinterface [interface]switchport mode accessswitchport port-securityswitchport port-security maximum [max] switchport port-security violation [mode]`章节七:QoS配置⑴优先级队列使用如下命令配置优先级队列:`configure terminalinterface [interface]priority-queue out`⑵带宽限制使用如下命令配置带宽限制:`configure terminalinterface [interface]bandwidth [rate]`章节八:设备管理⑴ NTP服务使用如下命令启用NTP服务:`configure terminalntp server [server-address]`⑵ Telnet和SSH访问使用如下命令配置Telnet和SSH访问:`configure terminalline vty 0 15transport input telnet ssh`⑶登录Banner使用如下命令配置登录Banner:`configure terminalbanner login [banner-text]`附录:本文档涉及附件附件1:设备配置备份说明附录:法律名词及注释⒈ACL:访问控制列表,用于控制网络流量的访问权限。

锐捷交换机、路由器常用命令

锐捷交换机、路由器常用命令锐捷交换机、路由器常用命令EXEC模式:用户模式switch>交换机信息的查看,简单测试命令特权模式switch#查看、管理交换机配置信息,测试、调试配置模式:全局配置模式switch(config)#配置交换机的整体参数接口配置模式switch(config-if)#配置交换机的接口参数进入全局配置模式Switch#c onfigure terminalSwitch(config)#exitSwitch#进入接口配置模式Switch(config)#interface fastethernet 0/1 Switch(config-if)#exitSwitch(config)#从子模式下直接返回特权模式Switch(config-if)#endSwitch#命令行其他功能获得帮助switch#?switch#show ?命令简写全写:switch# configure terminal简写:Switch# config使用历史命令Switch# (向上键)Switch# (向下键)配置交换机T elnet功能配置远程登陆密码Switch(config)#enable secret level 1 0 ruijie 配置进入特权模式密码Switch (config)#enable secret level 15 0 ruijie为交换机配置管理IPSwitch (config)#interface vlan 1Switch (config-if)#no shutdownSwitch (config-if)#ip address 192.168.1.1 255.255.255.0 Switch (config-if)#end配置文件的管理保存配置将当前运行的参数保存到flash 中用于系统初始化时初始化参数Switch#copy running-config startup-configSwitch#write memorySwitch#write删除配置永久性的删除flash 中不需要的文件使用命令delete flash:config.text删除当前的配置:在配置命令前加no例:switch(config-if)# no ip address查看配置文件内容Switch#show configure 查看保存在FLASH里的配置信息Switch#show running-config 查看RAM里当前生效的配置配置Port VLAN创建VLAN10,将它命名为test的例子Switch# configure terminalSwitch(config)# vlan 10Switch(config-vlan)# name testSwitch(config-vlan)# end把接口 0/10加入VLAN10Switch# configure terminalSwitch(config)# interface fastethernet 0/10Switch(config-if)# switchport mode accessSwitch(config-if)# switchport access vlan 10Switch(config-if)# end将一组接口加入某一个VLANSwitch(config)#interface range fastethernet 0/1-8,0/15,0/20Switch(config-if-range)# switchport access vlan 20注:连续接口0/1-8,不连续接口用逗号隔开,但一定要写明模块编号配置Tag VLAN-Trunk把Fa0/1配成Trunk口Switch# configure terminalSwitch(config)# interface fastethernet0/1Switch(config-if)# switchport mode trunk把端口Fa0/20 配置为Trunk端口,但是不包含VLAN 2:Switch(config)# interface fastethernet 0/20Switch(config-if)# switchport trunk allowed vlan remove 2 Switch(config-if)# endNative VLAN配置命令:Switch(config-if)# switchport trunk native vlan 20 Switch(config-if)# end注意:每个Trunk口的缺省native VLAN是VLAN 1在配置Trunk链路时,请确保连接链路两端的Trunk口属于相同的native VLAN保存/清除VLAN信息将VLAN信息保存到flash中Switch#write memory从flash中只清除VLAN信息Switch#delete flash:vlan.dat从RAM中删除VLANSwitch(config)#no vlan VLAN-id生成树协议的配置开启生成树协议Switch(config)#Spanning-tree关闭生成树协议Switch(config)#no Spanning-tree配置生成树协议的类型Switch(config)#Spanning-tree mode stp/rstp锐捷全系列交换机默认使用MSTP协议配置交换机优先级Switch(config)#spanning-tree priority <0-61440>(“0”或“4096”的倍数、共16个、缺省32768)恢复到缺省值Switch(config)# no spanning-tree priority配置交换机端口的优先级Switch(config)#interface interface-type interface-numberSwitch(config-if)#spanning-tree port-priority number配置STP、RSTPSpanning Tree 的缺省配置:关闭STPSTP Priority 是32768STP port Priority 是128STP port cost 根据端口速率自动判断Hello Time 2秒Forward-delay Time 15秒Max-age Time 20秒可通过spanning-tree reset 命令让spanning tree参数恢复到缺省配置查看生成树协议配置显示生成树状态Switch#show spanning-tree显示端口生成树协议的状态Switch#show spanning-tree interface fastethernet <0-2/1-24> 配置aggregate port将该接口加入一个APSwitch#c onfigure terminalSwitch(config) # interface interface-type interface-idSwitch(config-if-range)#port-group port-group-number如果这个AP不存在,可自动创建AG端口查看聚合端口的汇总信息Switch#show aggregateport summary查看聚合端口的流量平衡方式Switch#show aggregateport load-balance路由器上配置telnet第一步: 配置端口地址RouterA# configure terminal !进入全局配置模式RouterA(config)# interface fastethernet 1/0!进入路由器接口配置模式RouterA(config-if)# ip address 192.168.0.1 255.255.255.0!配置路由器管理接口IP地址RouterA(config-if)# no shutdown !开启路由器 f 1/0接口第二步:配置远程登录密码RouterA(config)# line vty 0 4 !进入路由器线路配置模式RouterA(config-line)# login !配置远程登录RouterA(config-line)# password star !设置路由器远程登录密码为“star”RouterA(config-line)#end第三步:配置路由器特权模式密码RouterA(config)# enable secret star !设置路由器特权模式密码为“star”或者RouterA(config)# enable password star查看配置文件show version !查看版本及引导信息show running-config !查看运行配置show startup-config !查看用户保存在NVRAM中的配置文件保存配置文件Router#copy running-config startup-configRouter#write memoryRouter#write删除配置文件Router#delete flash:config.text !删除初始配置文件查看路由信息router#show ip routeCodes: C - connected,S – static, R – RIP, O- OSPF IA - OSPF inter area,E1-OSPF external type 1E2 - OSPF external type 2,* - candidate default Gateway of last resort is 10.5.5.5 to network 0.0.0.0 172.16.0.0/24 is subnetted, 1 subnetsC 172.16.11.0 is directly connected, serial1/2O E2 172.22.0.0/16 [110/20] via 10.3.3.3, 01:03:01, Serial1/2S* 0.0.0.0/0 [1/0] via 10.5.5.5静态路由配置命令配置静态路由用命令ip routerouter(config)#ip route [网络编号] [子网掩码] [转发路由器的IP 地址/本地接口]例:ip route 192.168.10.0 255.255.255.0 serial 1/2 例:ip route 192.168.10.0 255.255.255.0 172.16.2.1静态路由描述转发路径的方式有两种指向本地接口(即从本地某接口发出)指向下一跳路由器直连接口的IP地址(即将数据包交给X.X.X.X)配置默认路由:router(config)#ip route 0.0.0.0 0.0.0.0 [转发路由器的IP 地址/本地接口]RIP路由协议的版本RIPv1有类路由协议,不支持VLSM以广播的形式发送更新报文不支持认证RIPv2无类路由协议,支持VLSM以组播的形式发送更新报文支持明文和MD5的认证配置RIP协议配置步骤1、开启RIP路由协议进程Router(config)#router rip2、申请本路由器参与RIP协议的直连网段信息Router(config-router)#network 192.168.1.03、指定RIP协议的版本2(默认是version1) Router(config-router)#version 24、在RIPv2版本中关闭自动汇总Router(config-router)#no auto-summary查看RIP配置信息验证 RIP的配置Router#show ip protocols显示路由表的信息Router#show ip route清除 IP路由表的信息Router#clear ip route在控制台显示 RIP的工作状态Router#debug ip ripOSPF协议OSPF配置如下:1、创建loopback接口,定义ROUTE IDrouterA(config)#interface loopback 10routerA(config)#ip address 192.168.100.1 255.255.255.0 2、开启OSPF进程routerA(config)#router ospf 1010代表进程编号,只具有本地意义3、申请直连网段routerA(config-router)#network 10.1.1.0 0.0.0.255 area 0 注意反掩码和区域号查看OSPF配置信息验证 OSPF的配置Router#show ip ospf显示路由表的信息Router#show ip route清除 IP路由表的信息Router#clear ip route在控制台显示 OSPF的工作状态Router#debug ip ospf三层交换的路由功能三层交换机默认开启路由功能Switch(config)#ip routing (开启三层交换机路由功能)三层交换机配置路由接口的两种方法开启三层交换机物理接口的路由功能Switch(config)#interface fastethernet 0/5Switch(config-if)#no switchportSwitch(config-if)#ip address 192.168.1.1 255.255.255.0 Switch(config-if)#no shutdown关闭物理接口路由功能Switch(config-if)# switchport采用SVI方式(switch virtual interface)Switch(config)#interface vlan 10Switch(config-if)#ip address 192.168.1.1.255 255.255.0 Switch(config-if)#no shutdown三层交换机和路由器相连的网络方法一(SVI):Switch(config)#interface f0/10Switch(config-if)#switchport access vlan 10Switch(config-if)#exitSwitch(config)#interface vlan 10 switch(config-if)#ip address 192.168.10.1 255.255.255.0Switch(config-if)#no shutdown方法二(路由接口):Switch(config)#interface f0/10Switch(config-if)#no switchportSwitch(config-if)#ip address 192.168.10.1 255.255.255.0 Switch(config-if)#no shutdown三层交换机路由协议的配置静态路由Switch(config)#ip route x.x.x.x x.x.x.x [x.x.x.x/interface] RIPSwitch(config)#router ripSwitch(config-router)#network X.X.X.XSwitch(config-router)#version 2注:三层交换机不支持no auto-summaryOSPFSwitch(config)#router ospfSwitch(config)#network X.X.X.X X.X.X.X area x查看三层交换机路由配置查看路由接口信息Switch#show ip interface。

思科交换机路由器命令大全

思科交换机路由器命令大全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 ;设置登录口令xx switch#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 2switch(config-if)#switchport mode trunk ;设置为干线switch(config-if)#switchport trunk allowed vlan 1,2 ;设置允许的vlanswitch(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 ;设置登录口令xx router(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 ;设置第二个IP router(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 ;保存配置到tftp router#copy startup-config tftp ;开机配置存到tftprouter(config-if)#ip access-group in|out ;default:out 例1:router(config)#access-list 4 permit 10.8.1.1router(config)#access-list 4 deny 10.8.1.0 0.0.0.255 router(config)#access-list 4 permit 10.8.0.0 0.0.255.255 router(config)#access-list 4 deny 10.0.0.0 0.255.255.255 router(config)#access-list 4 permit anyrouter(config)#int f0/0router(config-if)#ip access-group 4 in扩展访问控制列表:access-list permit|deny icmp wild>[type]access-list permit|deny tcp wild>[port]例3:router(config)#access-list 101 deny icmp any 10.64.0.2 0.0.0.0 echorouter(config)#access-list 101 permit ip any anyrouter(config)#int s0/0router(config-if)#ip access-group 101 in例3:router(config)#access-list 102 deny tcp any 10.65.0.2 0.0.0.0 eq 80router(config)#access-list 102 permit ip any anyrouter(config)#interface s0/1router(config-if)#ip access-group 102 out删除访问控制例表:router(config)#no access-list 102router(config-if)#no ip access-group 101 in路由器的nat配置Router(config-if)#ip nat inside ;当前接口指定为内部接口Router(config-if)#ip nat outside ;当前接口指定为外部接口Router(config)#ip nat inside source static [p] <私有IP>< 公网IP> [port]Router(config)#ip nat inside source static 10.65.1.260.1.1.1Router(config)#ip nat inside source static tcp 10.65.1.380 60.1.1.1 80Router(config)#ip nat pool p1 60.1.1.1 60.1.1.20255.255.255.0Router(config)#ip nat inside source list 1 pool p1Router(config)#ip nat inside destination list 2 pool p2Router(config)#ip nat inside source list 2 interface s0/0overloadRouter(config)#ip nat pool p2 10.65.1.2 10.65.1.4255.255.255.0 type rotaryRouter#show ip nat translationrotary 参数是轮流的意思,地址池中的IP轮流与NAT分配的地址匹配。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

路由器和交换机命令大全
路由器和交换机是计算机网络中常用的设备,它们在数据传输和网
络管理中发挥着重要的作用。

掌握路由器和交换机的命令是网络管理
和故障排除的基本要求。

本文将为您提供常见的路由器和交换机命令
大全,以帮助您更好地理解和应用这些设备。

一、路由器命令
1. show ip route:显示路由表中的所有路由信息。

2. show interfaces:显示接口的状态和统计信息。

3. show running-config:显示当前路由器的配置信息。

4. show version:显示路由器的硬件和软件版本信息。

5. configure terminal:进入全局配置模式。

6. interface interface-name:进入指定接口的配置模式。

7. ip address ip-address subnet-mask:为接口配置IP地址和子网掩码。

8. ip route destination-network subnet-mask next-hop:配置静态路由。

9. access-list access-list-number {deny | permit} source destination:配
置访问控制列表。

10. clear arp-cache:清除路由器的ARP缓存。

11. debug {protocols | ip | interface}:启用某个调试功能来监控网络
流量或接口状态。

二、交换机命令
1. show interfaces:显示接口的状态和统计信息。

2. show mac-address-table:显示交换机的MAC地址表。

3. show running-config:显示当前交换机的配置信息。

4. show vlan:显示交换机的VLAN信息。

5. configure terminal:进入全局配置模式。

6. interface interface-name:进入指定接口的配置模式。

7. switchport mode {access | trunk}:配置接口的工作模式。

8. switchport access vlan vlan-id:为接口配置访问端口所属的VLAN。

9. switchport trunk native vlan vlan-id:为接口配置Trunk模式下的原生VLAN。

10. spanning-tree vlan vlan-id:配置指定VLAN的生成树协议。

11. vlan vlan-id:进入指定VLAN的配置模式。

12. ip default-gateway ip-address:配置交换机的默认网关。

13. clear mac-address-table:清除交换机的MAC地址表。

14. debug {spanning-tree | mac-address-table}:启用某个调试功能来
监控生成树或MAC地址表。

三、其他常用命令
1. ping ip-address:测试与指定IP地址的连通性。

2. traceroute ip-address:显示到达目标IP地址所经过的路由器。

3. telnet ip-address:通过Telnet协议远程登录到目标设备。

4. ssh ip-address:通过SSH协议远程登录到目标设备。

5. copy running-config startup-config:将当前配置保存到下次启动时加载的配置文件中。

请注意,以上命令仅为常见的示例,不同的路由器和交换机厂商可能会有略微的差异。

在实际使用时,请参考设备的用户手册或官方文档以获取对应设备的命令详细说明。

总结:本文为您提供了常见的路由器和交换机命令大全,涵盖了路由器和交换机的基本配置和管理命令。

熟练掌握这些命令对于网络管理和故障排除至关重要。

希望通过本文的介绍,能够帮助您更好地理解和应用路由器和交换机。

如果您在使用过程中遇到任何问题,请参考相关设备的官方文档或寻求专业人士的帮助。

相关文档
最新文档