交换机和路由器常用命令大全

合集下载

路由与交换的配置命令

路由与交换的配置命令

1、switch>:用户模式——能查看版本信息2、在用户模式下输入enable会进特权模式——它能保存、修改、删除这一系列的配置switch>enable→switch#:特权模式,下面有一些命令就在此命令下完成:①、删除vlan的文件配置:delete flash:vlan.dat②、删除vlan中的配置文件:erase startup-config③、查看vlan配置文件是否被删除及vlan的是否创建:show vlan④、重新启动交换机:reload⑤、查看当前交换机的配置:show running-config⑥、保存对交换机所配置的内容,即是保存在Nvram:copy running-configstartup-config⑦、检查Nvram的内容:show startup-config⑧、检查虚拟接口 vlan的特征:show interface vlan 1⑨、查看接口IP的属性:show ip interface vlan 1⑩、查看cisco的信息:show version⑪、查看交换机所用快速以太网接口的默认属性:show interface fastethernet 0/18⑫、查看闪存目录中的内容:show flash 或dir flash3、在特权模式下输入configure terninal后会进入全局模式,一切的配置必须在此模式中进行配置Switch#configure terninal→switchp(config)#:全局模式①、配置路由器设备的名字:switch(config)#hostname + 交换机的名字②、配置进入特权模式的密码,即使能密码:switch(config)#enable password +密码③、配置非明文密码:switch(config)#enable secret + 密码4、为交换机配置console口①、进入现成配置模式,即进入console口:switch(config)# line console 0②、设置密码(重新启动时需要此密码):switch(config-line)#password + 密码③、允许登录:switch(config-line)#login5、配置远程登录的密码:①、首先要配置使能密码②、允许让几个人登录:switch(config)#line vty 0 4(即允许五个登录)③、设置密码:switch(config-line)#password + 密码④、允许远程登录:switchp(config-line)#login6、在全局模式下的有关命令①对所有密码进行加密:switch(config)#service password-encryption②、不解析错误的命令:switch(config)#no ip domain-lookup7、创建vlan(2—1001,注vlan 1既不可以创建,也不可以删除)①、创建vlan :vlan + 要创建vlan的值②、给vlan取名:switch(config-vlan)#name + 名字(此步可以不要)③、把PC与交换机相连的端口添加到相应的vlan中:a、Switch(config)#interface + 端口b、Switch(config-if)#switchport access vlan + 相应vlan的值④、需要传递多个vlan信息就要打中继口,即trunka、switch(config)#interface + 交换机另一端口b、switch(config-if)#switchport mode trunk8、传统vlan 的通信(1)、router的配置①、为接口配置IP地址(该IP是相应vlan的PC网关)②、激活端口:no shutdown(2)、switch的配置①、创建vlan,将PC端口划入相应vlan②、将switch与router相连的端口划入相应的vlan(3) 、PC的配置:就是给PC配置IP,注PC的默认网关与router的IP相同,网关相同9、单臂路由实现vlan的通信(1)router配置①、添加子接口:interface f0/0.1(此处有多少个vlan就添加多少个子接口)②、将子接口封装到相应的vlan:encapsulation dot + 相应vlan的值③、将子接口配置IP:ip add +ip地址 + 子网掩码④、激活物理接口:no shutdown(2)、switch的配置①、创建 vlan,交PC的端口划入到相应vlan②、与router相连的端口打trunk(3)、配置PC的IP9、三层交换(1)、配置三层交换①、启用三层交换:(config)#ip routing②、创建vlan:(config)# vlan + 要创建vlan的值③、把相应的vlan配置IPa、指定一个vlan:(config)#interface vlan + vlan相应的值c、配置IP:(config-if)#ip add + ip + 子网掩码(2)、配置switch①、每个交换机创建vlan②、把端口划分到相应的vlan中③、打中继口(trunk)Show命令1、show version 这个命令可以查看IOS版本号,已启动时间,Flash中的IOS 的文件名,router里面共有什么端口,寄存器的值等等。

路由与交换机基本命令

路由与交换机基本命令

交换机配置命令集锦1、进入全局配置2、启用交换机的HTTP Server3配置主机名4、配置超级用户口令5、配置远程登录口令6、配置系统时间7、配置设备管理地址(IP地址及缺省路由)8、进入端口配置模式9、配置端口描述信息10、配置交换机端口的关闭与开启11、配置交换机端口的通信方式12、配置交换机端口的传输速率13、配置VTP域名14、配置VTP工作模式15、进入VLAN配置模式16、建立VLAN17、删除VLAN18、修改VLAN 19、为端口分配VLAN 20、配置VLAN Trunk模式21、封装VLAN协议22、设置允许中继的VLAN 23、打开或关闭STP 24、配置根网桥和备份根网桥25、配置生成树优先级26、配置BackboneFast 生成树可选功能27、配置UplinkFast 生成树可选功能28、配置PortFast 生成树可选功能29、配置BPDU Filter 生成树可选功能交换机配置命令集锦之Catalyst 35481、Switch-3548 > enablePassword : ********Switch-3548 # config tSwitch-3548 (config) #2、Switch-3548 (config) # ip http server3、Switch-3548 (config) # hostname Switch-PHY-35484、Switch-PHY-3548 (config) # enable secret 5 zzzSwitch-PHY-3548 (config) # enable password zzzSwitch-PHY-3548 (config) #Switch-PHY-3548 (config) # enable password 7 zzzSwitch-PHY-3548 (config) #5、Switch-PHY-3548 (config) # line vty 0 4Switch-PHY-3548 (config-line) # password 7 zzzSwitch-PHY-3548 (config-line) # password 0 zzzSwitch-PHY-3548 (config-line) #6、Switch-PHY-3548 # clock set 23:00:00 29 March 20097、Switch-PHY-3548 (config) # interface VLAN1Switch-PHY-3548 (config-if) # ip address 203.105.1.62 255.255.255.0Switch-PHY-3548 (config) # ip default-gateway 203.105.1.18、Switch-PHY-3548 (config) # interface f0/249、Switch-PHY-3548 (config-if) # description To-lib10、Switch-PHY-3548 (config-if) # (no) shutdown11、Switch-PHY-3548 (config-if) # duplex auto/full/half12、Switch-PHY-3548 (config-if) # speed 10/100/auto13、Switch-PHY-3548 (config) # vtp domain pku14、Switch-PHY-3548 (config) # vtp mode server/client/transparent15、Switch-PHY-3548 # vlan data16、Switch-PHY-3548 (vlan) # vlan 1000 name vlan100017、Switch-PHY-3548 (vlan) # no vlan 100018、Switch-PHY-3548 (vlan) # vlan 1000 name v100019、Switch-PHY-3548 (config-if) # switchport access vlan 24820、Switch-PHY-3548 (config-if) # switchport mode trunk21、Switch-PHY-3548 (config-if) # switchport trunk encapsulation dot1 q/isl/negotiate P22、Switch-PHY-3548 (config-if) # switchport trunk allowed vlan 10,14/10-14/except 100-100023、Switch-PHY-3548 (config) # (no) spanning-tree vlan 324、Switch-PHY-3548 (config) # spanning-tree vlan 3 root primary/secondary25、Switch-PHY-3548 (config) # spanning-tree vlan 3 priority 819226、Switch-PHY-3548 (config) # spanning-tree backbonefast27、Switch-PHY-3548 (config) # spanning-tree uplinkfast max-update-rate 32000Switch-PHY-3548 (config) # spanning-tree uplinkfast28、Switch-PHY-3548 (config) # spanning-tree portfast default29、Switch-PHY-3548 (config) # spanning-tree portfast bpdufilter default交换机配置命令集锦之Catalyst 65001、Switch-6509 > enableEnter password :Switch-6509 > (enable)2、Switch-6509 > (enable) set ip http server enable3、Switch-6500 > (enable) set system name Switch-PHY-6500 orSwitch-6500 > (enable) set prompt Switch-PHY-6500 >4、Switch-PHY-6500 > (enable) set enablepass5、Switch-PHY-6500 > (enable) set password6、Switch-PHY-6500 > (enable) set time fri 3/29/2009 23:00:007、Switch-PHY-6500 > (enable) set interface sc0 203.105.1.63 255.255.255.0 203.105.1.2558、Switch-PHY-6500 > (enable) set port name 4/5 mail-server910、Switch-PHY-6500 > (enable) set port enable/disable 4/511、Switch-PHY-6500 > (enable) set port duplex 5/1 full/halfSwitch-PHY-6500 > (enable) set port duplex 5/1-24 full/half12、Switch-PHY-6500 > (enable) set port speed 5/1-24 auto/10/100/100013、Switch-PHY-6500 > (enable) set vtp domain pku14、Switch-PHY-6500 > (enable) set vtp mode server/client/transparent/off15、Switch-PHY-6500 > (enable) set vlan 999 name vlan9991617、Switch-PHY-6500 > (enable) clear vlan 99918、Switch-PHY-6500 > (enable) set vlan 999 name v99919、Switch-PHY-6500 > (enable) set vlan 42 5/2020、Switch-PHY-6500 > (enable) set trunk 5/1 on dot1 qPort(s) 1/2 trunk mode set to on2122、Switch-PHY-6500 > (enable) set trunk 5/1 vlan 37-4223、Switch-PHY-6500 > (enable) set spantree enable/disable 324、Switch-PHY-6500 > (enable) set spantree root 1,200-204Switch-PHY-6500 > (enable) set spantree root secondary 1,200-20425、Switch-PHY-6500 > (enable) set spantree priority 819226、Switch-PHY-6500 > (enable) set spantree backbonefast enable27、Switch-PHY-6500 > (enable) set spantree uplinkfast enable28、Switch-PHY-6500 > (enable) set spantree portfast 3/2 enable29、Switch-PHY-6500 > (enable) set spantree portfast bpdu-filter enable路由器配置命令集锦1、进入特权模式、全局配置模式、接口配置模式、虚拟终端配置模式、RIP路由协议配置模式2、配置远程登录密码3、拷贝配置文件到TFTP Server4、拷贝running-config 到TFTP Server5、拷贝bootflash 中的配置文件到TFTP Server6、从TFTP Server 拷贝配置文件到路由器7、将TFTP Server 上的配置文件拷贝到bootflash8、配置路由器的主机名9、配置超级用户口令10、设置系统时钟11、保存配置12、删除配置13、基本检测命令(telnet、ping、trace)14、查看flash、系统时钟、软硬件版本、路由器配置、查看路由表、IP 路由协议的详细信息15、配置接口描述信息16、配置接口带宽17、配置接口的IP地址18、接口的开启与关闭19、不作ARP代理20、配置异步串行接口21、配置高速同步串行接口22、配置POS接口23、loopback 接口的配置24、配置静态路由25、进入RIP配置模式26、设置参与RIP协议的网络地址27、配置RIP的被动接口28、配置RIP的路由过滤29、配置RIP的管理距离30、配置RIP的邻居路由器31、配置单个IP地址参与OSPF 32、网络地址参与OSPF33、定义参与OSPF的子网地址34、配置被动接口(包括路由器和第三层交换机的配置)35、配置路由过滤36、配置管理距离37、配置OSPF引入外部路由的花费值38、配置引入外部路由时缺省的标记值39、配置引入外部路由时缺省的外部路由类型40、配置IP地址池的名称41、配置IP地址池的子网地址和子网掩码42、配置不用于动态分配的IP地址43、配置IP地址池的缺省网关44、配置IP地址池的域名45、配置IP地址池的域名服务器的IP地址46、配置IP地址池的地址租用时间47、取消地址冲突记录日志路由器配置命令集锦1、Router > enablePassword :Router #Router # configure terminalRouter (config) #Router (config) # int f0/12Router (config-if) #Router (config) # line vty 0 15Router (config-line) #Router (config) # router ripRouter (config-router) #2、Router (config) # line vty 0 15Router (config-line) # password 7 zzz3073、Router # write network4、Router # copy running-config tftp:5、Router # copy bootflash : tftp :6、Router # copy tftp : running-config7、Router # copy tftp : bootflash :8、Router (config) #hostname Router-phy9、Router (config) # enable secret phy12310、Router # calendar set 10:24:00 30 march 200911、Router # write memoryRouter # write network tftp12、Router # write erase13、Router > telnet paris/222.34.27.1Router > ping 182.105.130.110Router > trace 137.189.11.73Router > traceroute 14、Router > show flashRouter > sh clockRouter > sh versionRouter # sh configurationRouter # sh ip routeRouter # sh ip protocols15、Router (config-if) # description To-BeiJing Foreign Studies University16、Router (config-if) # bandwidth 2500,00017、Router (config-if) # ip address 202.112.7.249 255.255.255.25218、Router (config-if) # shutdown/no shutdown19、Router (config-if) # duplex full# no ip directed-broadcast# no ip proxy-arp20、Router (config) # interface a1Router (config-if) # ip unnumbered ethernet0Router (config-if) # encapsulation pppRouter (config-if) # async default ip address 202.112.7.129Router (config-if) # async dynamic routingRouter (config-if) # async mode interactiveRouter (config-if) # no shutdownRouter (config-if) # exitRouter (config) # exitRouter (config) #21、Router (config) # interface s1/1 Router (config-if) # description To-shenzhenRouter (config-if) # bandwidth 2048Router (config-if) # ip address 212.112.41.81 255.255.255.252Router (config-if) # encapsulation hdlcRouter (config-if) # no ip directed-broadcastRouter (config-if) # no ip proxy-arp22、Router (config) # interface POS3/0Router (config-if) # description To TianJingDaXueRouter (config-if) # bandwidth 2500,000Router (config-if) # ip address 212.12.37.18 255.255.255.252Router (config-if) # crc 32Router (config-if) # pos framing sdhRouter (config-if) # no ip directed-broadcastRouter (config-if) # pos flag s1 s0 223、Router (config) # int loopback 0Router (config-if) # ip address 192.167.167.6 255.255.255.255Router (config-if) # no ip route-cacheRouter (config-if) # no ip mroute-cache24、Router (config) # ip route 195.65.96.0 255.255.240.0 222.112.37.1(静态路由的配置)25、Router (config) # router rip26、Router (config-router) # network 159.105.0.027、Router (config-router) # passive-interface ethernet 028、Router (config) # access-list 12 deny anyRouter (config) # router ripRouter (config-router) # distribute-list 12 in ethernet029、Router (config-router) # distance 5030、Router (config-router) # neighbor 202.112.7.231、Router (config) # router ospf 63Router (config-router) # network 131.107.25.1 0.0.0.0 area 032、Router (config-router) # network 133.181.0.0 0.0.255.255 area 033、Router (config-router) # area 0 range 212.37.123.0 255.255.255.034、Router (config-router) # passive-interface Ethernet 0Router (config-router) # passive-interface vlan3735、Router (config) # access-list 12 deny anyRouter (config) # router ospf 63Router (config-router) # distribute-list 12 in serial 036、Router (config-router) # distance 1037、Router (config-router) # redistribute metric 10038、Router (config-router) # redistribute tag 1039、Router (config-router) # redistribute connected metric-type 1 subnets40、Router (config) # ip dhcp pool ttt/23441、Router (dhcp-config) # network 201.23.98.0 255.255.255.0Router (dhcp-config) # network 201.23.98.0/2442、Router (config) # ip dhcp excluded-address 201.23.98.2 201.23.98.1043、Router (dhcp-config) # default-router 201.23.98.144、Router (dhcp-config) # domain-name 45、Router (dhcp-config) # dns-server address 212.105.129.27 212.105.129.2646、Router (dhcp-config) # lease 0 5/ # lease infinite47、Router (config) # no ip dhcp conflict logging48、标准访问控制列表(1)Router(config)#access-list 10 permit 211.105.130.0 0.0.0.255………………line vty 0 5(config-line)#access-class 10 in(应用到虚拟接口) Router(config)#access-list 30 deny 10.0.0.0 0.255.255.255……………………………………permit any…………………#interface g0/1#ip access-group 30 in(应用到路由器接口)#show configuration#show access-lists扩展访问控制列表<lt >gt =eq 不等neq…………………#access-list 130 deny udp any any eq 1434……………………………………permit ip any any配置到应用接口同上禁封主机110 deny ip host 202.112.60.230 any…any host 200.112.60.230110 permit ip any any禁封ICMP只允许…………ICMP通过…………………198 permit icmp 162..105.141.0 0.255.255.255 any198 deny icmp any any198 deny ip any any使用ip access-list。

交换机与路由器基本命令

交换机与路由器基本命令

交换机与路由器基本命令交换机部分命令一、交换机五种模式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.VrrpVrrp:虚拟路由网关冗余协议L3-1 (config)#vlan database //创建vlanL3-1 (config)#vlan 10 / vlan 20 / vlan 30 / vlan 40L3-1 (config-vlan)#interface vlan 10 / vlan 20L3-1 (config-if)#no shutdownL3-1 (config-if)#ip add 192.168.10.1 / 192.168.20.1 / 192.168.30.1 / 192.168.40.1 255.255.255.0L3-1 (config-if)#vrrp 1 ip192.168.10.254 / 192.168.20.254 //vrrp配置虚拟ipL3-1 (config-if))#vrrp1priority 254 //配置vrrp的优先级L3-1 (config-if))#vrrp 1 preempt //抢占L3-1 (config-vlan)#interface vlan 30 / vlan 40L3-1 (config-if)#vrrp 2 ip 192.168.30.254 / 192.168.40.254 //vrrp配置虚拟ip /*L3-1 (config-vlan)#vrrp 1 authentication text 1234 //双方认证加密*/L3-2 (config)#vlan database //创建vlanL3-2 (config)#vlan 10 / vlan 20 / vlan 30 / vlan 40L3-2 (config-vlan)#interface vlan 10 / vlan 20 / vlan 30 / vlan 40L3-2 (config-if)#no shutdownL3-2 (config-if)#ip add 192.168.10.1 / 192.168.20.1 / 192.168.30.1 / 192.168.40.1 255.255.255.0L3-2 (config-if)#vrrp 2 ip 192.168.30.254 / 192.168.40.254 //vrrp配置虚拟ipL3-2 (config-if))#vrrp 2 priority 254 //配置vrrp的优先级L3-2 (config-if))#vrrp 2 preempt //抢占L3-2 (config-vlan)#interface vlan 10 / vlan 20L3-2 (config-if)#vrrp 1 ip 192.168.10.254 / 192.168.20.254 //vrrp配置虚拟ipL3-1#show vrrp brief //查看vrrp配置信息HsrpRouter (config)#interface fa0/1 ip 192.168.1.3 255.255.255.0 //进入端口配置ipRouter (config-if)#standby 2 //创建组Router (config-if)#standby 2 ip 192.168.1.254 //组添加ipRouter (config-if)#standby priority 200 //设置优先级,默认优先级100Router (config-if)#standby 2 preempt //抢占Router (config-if)#standby timers 3-10 //虚拟报文时间间隔Router (config-if)#standby 2 tranck fa0/0 //跟踪上行端口Router#show standby brief //查看热备份配置信息2.Mstp:多生成树协议Switch (config)#spanning-tree //启动生成树协议Switch (config)#spanning-tree mode mstp //设置生成树模式是mstpSwitch (config)#vlan 10Switch (config-vlan)#exitSwitch (config)#vlan 20Switch (config-vlan)#exitSwitch (config)#spanning-tree mst 1 priority 4096 //生成树组1的优先级设为4096 Switch (config)#spanning-tree mstconfigwration //进入生成树配置模式Switch (config)#instance 1 vlan 10,20 //把vlan10,20添加到组13.链路聚合L3-1 (config)#interface port-channel 1 //创建组L3-1 (config-if)#no shutdownL3-1(config-if)#switchport mode trunkL3-1(config-if)#interface fa1/13 //进入三层交换机间相连接口L3-1(config-if)#channel-group 1 mode on //添加到组中L3-1 (config-if)#switchport mode trunkL3-1 (config-if)#no shutdownL3-1 (config-if)#interface fa1/14L3-1 (config-if)#channel-group 1 mode onL3-1 (config-if)#switchport mode trunkL3-1 (config-if)#no shutdownL3-2(config)#interface port-channel 1 //创建组L3-2(config-if)#no shutdownL3-2(config-if)#switchport mode trunkL3-2(config-if)#interface fa1/13 //进入三层交换机间相连接口L3-2(config-if)#channel-group 1 mode on //添加到组中L3-2(config-if)#switchport mode trunkL3-2(config-if)#no shutdownL3-2(config-if)#interface fa1/14L3-2(config-if)#channel-group 1 mode onL3-2(config-if)#switchport mode trunkL3-2(config-if)#no shutdown4.VLAN(vtp)●Vtp(truch接口):Switch(config)#Vtpnamezjq //vtp命名zjqSwitch(config)#vtp password 123456 //设置vtp密码Switch(config)#vtp mode server(client) //vtp的模式设置为服务器或者客户端Switch(config)#interface FastEthernet0/1Switch(config)#switchport mode trunk //接口模式设置为trunk●配置vlanSwitch(config)#Vlan databaseSwitch(config)#Vlan 10 name xingzhengbuSwitch(config)#Switchport access vlan 10Switch(config)#Ip address 192.168.80.254 255.255.255.05.Tftp//打开tftp服务器,获取ip地址L2-1>enL2-1#copy startup-configtftp //Address of remote host []?172.16.25.0Destination filename [config.text]?zhangjq.txt6.telnet:远程登录Switch(config)#hostname silence //修改设备名称Switch(config)#intvlan 1Switch(config-if)#ip add 192.168.1.1 255.255.255.0 //设置管理交换机的IP地址Switch(config-if)#no shutdown //启用接口Switch(config)#enable secret 123456 //配置进入特权模式的密码为123456 Switch(config)#line vty 0 15//进入VTY端口,允许16台电脑同时远程登录Switch(config-line)#pass cisoco //设置Telnet的登录密码为ciscoSwitch(config-line)#login //允许Telnet登录7.管理VLAN扩展:1.路由引入(ospf)●静态路由配置(Static):要到达的网段Nwtwork:192.168.3.0/24设置下一跳Next Hop:192.168.1.2Router(config)#ip route 0.0.0.0 0.0.0.0 fa0/1●动态路由RIP:公布自己有的网段192.168.2.0/192.168.3.0OSPF:开放式最短路径协议Router(config)#router ospf 1 //启动OSPF协议,进程号Router(config)#network 192.168.1.0 0.0.0.255 area 0 //公布自己有的网段,划分区域Router(config)#do show iproute //查看路由表修改链路的开销1.Router(config-if)#bandwidth bamdwidth-kbps //修改接口的带宽参数2.Router(config-if)#ipospf cost “加数字”//命令则直接将链路开销设置为特定值并免除了计算过程2.DHCP的配置:动态主机配置协议L3-1(config)#vlan 10 //创建vlanL3-1(config-if)#intvlan 10L3-1(config-if)#ip add 192.168.10.1 255.255.255.0L3-1(config-if)#no shutdownL3-1 (config)#service dhcp //启动dhcpL3-1 (config)#ipdhcp pool <name> //建立地址池L3-1 (config)#network <network-number><mask> //动态分配ip的网段和MAC地址L3-1 (config)#default-router <ip-address> //为dhcp客户设置默认网关L2-1 (config)#interface fa0/0L2-1 (config-if)#sw mode trunkL2-1 (config-if)no shutdownL2-1 (config)#interface fa0/15L2-1 (config-if)#switchport mode accessL2-1 (config-if)#switchport access vlan 10 //绑定vlan 10L2-1 (config-if)no shutdownPC(config)#no ip routing //取消路由功能PC(config)#interface fa0/0PC(config-if)#ip add dhcpPC(config)#default gateway <ip-address>PC#show interface fa0/03.无线路由器AP>ap-mode fatAP>enAP#config tAP(config)#vlan 10AP(config-vlan)#exitAP(config)#service dhcpAP(config)#ipdhcp pool zhangjqAP(dhcp-config)#network 192.168.10.0 255.255.255.0AP(dhcp-config)#dns-server 10.20.5.1AP(dhcp-config)#default-router 192.168.10.254AP(dhcp-config)#interface gigabitEthernet0/1AP(config-if-GigabitEthernet 0/1)#encapsulation dot1Q 10 //封装vlan10AP(config-if-GigabitEthernet 0/1)#interface BVI 10AP(config-if-BVI 6)#ip add 192.168.10.254 255.255.255.0AP(config-if-BVI 6)#exitAP(config)#dot11 wlan10AP(dot11-wlan-config)#vlan10AP(dot11-wlan-config)#broadcast-ssidAP(dot11-wlan-config)#ssidzhangjqAP(dot11-wlan-config)#exitAP(config)#interface dot11radio 1/0AP(config-if-Dot11radio 1/0)#encaosulation dot1Q 10AP(config-if-Dot11radio 1/0)#mac-mode fatAP(config-if-Dot11radio 1/0)#channel 1AP(config-if-Dot11radio 1/0)#wlan-id 1AP(config-if-Dot11radio 1/0)#ip router 0.0.0.0 0.0.0.0 192.168.1.254AP(config)#intwlansec 10AP(config-if-wlansec 10)#security wpa enableAP(config-if-wlansec 10)#security wpa ciphers aes enableAP(config-if-wlansec 10)#4.ACL:访问控制列表标准控制列表:Router(config)#access-list 1 permit 192.168.2.0 0.0.0.255 //创建控制列表允许2网段可以访问,<1-99>标准访问控制列表;<100-199>扩展访问控制列表Router(config)#access-list 1 permit 192.168.1.0 0.0.0.255Router(config)#access-list 1 deny 192.168.0.0 0.0.0.255 //创建控制列表拒绝0网段可以访问,反向子网掩码Router(config)#interface se3/0 //进入se3/0Router(config-if)#ip access-group 1 out //把访问控制列表应用到接口Se3/0扩展控制列表:<才需要填写目标ip>Router(config)#access-list 101 permit ip 192.168.2.0 0.0.0.255 10.0.0.0 0.255.255.255 //创建控制列表允许源ip访问目标ip,能访问web和ping通Router(config)#access-list 101 permit tcp 192.168.1.0 0.0.0.255 10.0.0.0 0.255.255.255 eq www //创建控制列表允许源ip访问目标ip的80端口,能访问web不能ping通Router(config)#access-list 101 permit icmp 192.168.0.0 0.0.0.255 10.0.0.0 0.255.255.255 //创建控制列表允许源ip访问目标ipRouter(config)#interface se3/0Router(config-if)#ip access-group 101 outSe3/0●使用ACL保护路由安全Router(config)#access-list 1 permit 192.168.1.0 0.0.0.255Router(config)#line vty 0 15Router(config)#access-class 1 inRouter(config)#password hanlg5.NAT:地址转换●静态NAT(出口路由配置,私网地址转换成公网地址)Router(config)#ipnat inside source static【静态】私网ip公网(外)ip //内部网转换为外部网地址Router(config)#interface f0/1Router(config-if)#ipnat outside //绑定对外接口Router(config)#interface f0/2Router(config-if)#ipnat inside //绑定对内接口●动态NATRouter>enRouter#config tRouter(config)#access-list 10 permit 10.0.0.0 0.0.0.255Router(config)#ipnat pool zhangjq 131.107.0.1 131.107.0.6 netmask 255.255.255.0 Router(config)#ipnat inside source list 10 pool zhangjqRouter(config)#interface se0/0Router(config-if)#ipnat outsideRouter(config-if)#interface fa0/1Router(config-if)#ipnat insideRouter(config-if)#endRouter(config-if)#show ipnat translations●超载NAT(PAT)Router>enRouter#config tRouter(config)#access-list 10 permit 10.0.0.0 0.0.0.255Router(config)#ipnat pool zhangjq 131.107.0.1 131.107.0.1netmask 255.255.255.0 Router(config)#ipnat inside source list 10 pool zhangjqoverloadRouter(config)#interface se0/0Router(config-if)#ipnat outsideRouter(config-if)#interface fa0/1Router(config-if)#ipnat insideRouter(config-if)#endRouter(config-if)#show ipnat translations6.802.1xL2-1 (config)#aaa new-model //启动aaa服务L2-1 (config)#aaa authentication dot1x default group radius //认证802.1x,启用默认列表default,采用radius认证方式L2-1 (config)#dot1x authentication default //启用default列表应用L2-1 (config)#radius-server host 172.16.32.2 //配置radius服务器地址L2-1 (config)#radius-server key 123456 //设置交换机和服务器之间的密码L2-1 (config)#dot1x auth-mode chap //身份验证的加密方式改为chapL2-1 (config)#interface range fa0/1 - 22 //进入交换机的下行接口L2-1 (config-if)#dot1x port-control auto //在端口启用802.1x绑定vlanL2-1(config)#interface fa0/0L2-1(config)#switchport mode accessL2-1(config)#switchport access vlan10●打错Switch(config)#no ip domain-lookup●配置单臂路由Router(config)#inter fa0/0.10 //创建虚拟接口Router(config-subif)#encapsulation dot1Q 10 //封装(vlan)协议Router(config-subif)#ip address 192.168.1.1 255.255.255.0 //添加网关Router(config-subif)#no shutdown●路由引入Router(config-if)#default-information originate●回环路由(虚构一条路)Router(config)#int loopback 回环路由号Ip route 0.0.0.0 0.0.0.0 loopback 0●交换机端口安全配置Switch (config)#interface fastsernet0/1 //进入端口配置模式Switch (config-if)#speed 10 //设置端口速率为10Mbit/s,{10|100|auto}Switch (config-if)#duplex half //设置端口为半双工,{half|full|auto}Switch (config-if)#no shutdown //启用端口Switch (config-if)#switchport mode access //设置当前端口为access,交换机端口安全功能只能在access接口进行配置Switch (config-if)#switchport port-security //打开当前端口安全功能,默认关闭端口安全功能Switch (config-if)#switchportport-security maximum 10 //设置端口安全地址的最大个数,最大安全地址个数是128个Switch (config-if)#switchport port-security violation shutdown //配置处理违例的方式,默认处理方式为protectSwitch (config-if)#switchport port-security mac-address 0007.EC56.5906 //配置安全地址Switch (config-if)#endSwitch#show port-security interface fastethernet0/1 //查看0/1的端口安全配置信息,<Half-duplex,10Mb/s //已设置为半双工,10Mbit/s>Switch#show port-security //查看所有安全端口的统计信息●光电复用口L3-1 (config)#interface gi0/26L3-1 (config-GigabitEthernet 0/26) #medium-type fiberL3-2 (config)#interface gi0/26L3-2 (configGigabitEthernet 0/26)#medium-type fiber●防火墙设置步骤1.路由模式(安全)下设置2.接口IP地址设置3.路由(默认路由)4.安全策略、安全规则(nat、包过滤、ip映射、端口映射)端口映射:nat的一种,把内网端口转换成外网端口(内网的服务器ip加上端口号映射到外网ip地址)Ip映射:静态natNat:防火墙上做nat,就是要使内网用户可以访问外网QOS(服务质量)路由器的CBWFQ配置Router(config)#class-map http_ftp //创建一个分类表,并进入分类表模式Router(config-cmap)#match protocol httpRouter(config-cmap)#match protocol ftpRouter(config-cmap)#exitRouter(config)#policy-map zhangjq //创建一个策略表,并进入策略表模式Router(config-pmap)#class http_ftp //建立一个分类表,并进入策略分类表模式Router(config-pmap-c)#bandwidth 512Router(config-pmap-c)#exitRouter(config-pmap)#class class-defaultRouter(config-pmap-c)#endRouter(config)#interface fa0/1Router(config-if)#service-policy output zhangjq //在端口上应用一个策略表Router(config-if)#endRouter#show policy-mapIPSec配置R1(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.1 //添加默认路由,设置下一条R1(config)#crypto isakmp policy 11 //设置IKE策略的优先级R1(config-isakmp)#encryption 3des //配置加密方式[des,3des,aes]R1(config-isakmp)#hash md5 //检验完整性,数字签名方法[md5,sha]R1(config-isakmp)#authentiaction pre-share //采用预共享密钥的认证方式R1(config)#crypto isakmp key passwd address 10.1.14.60 //协商的共享密码R1(config)#crypto ipsec transform-set one esp-3des esp-md5-hmac //配置转换集[ike配置参数转换成IPSec]R1(config)#access-list 101 permit ip 172.16.0.0 0.0.255.255 192.168.0.0 0.0.255.255//创建访问控制列表R1(config)#access-list 111 deny ip 192.168.10.0 0.0.0.255 192.168.20.0 0.0.0.255R1(config)#access-list 111 permit ip any anyR1(config)#ip nat inside source list 111 interface fa0/1R1(config)#cryptomap my 10 ipsec-isakmp //创建加密图my,序号10R1(config-crypto-map)#set peer 10.1.14.60 //标识对方路由器IP地址R1(config-crypto-map)#set transform-set one //启用转换集R1(config-crypto-map)#match address 101 //启用ACLR1(config-crypto-map)#interface FastEthernet0/0R1(config-if)#crypto map my //启用映射R1#show crypto isakmp sa //查看配置结果IKE配置配置映射Show crypto isakmpPpp:由被验方发起单向:被验证方:Route0r#config tRouter0(config)#interface Serial0/0/0Router0(config-if)#ip address 192.168.1.1 255.255.255.0 Router0(config-if)#no shutdownRouter0(config-if)#encapsulation pppRouter0(config-if)#ppp pap sent-username r0 password 123456验证方:Router1>enableRouter1#configure terminalRouter1(config)#interface Serial0/0/0Router1(config-if)#ip address 192.168.1.2 255.255.255.0 Router1(config-if)#no shutdownRouter1(config)#username r0 password 0 123456Router1(config-if)#encapsulation ppp双向:Router3>enRouter3#config tRouter3(config)#username r4 password 0 123456Router3(config)#int se2/0Router3(config-if)#encapsulation pppRouter3(config-if)#ppp pap sent-username r3 password 123456Router4>enRouter4#config tRouter4(config)#username r3 password 0 123456Router4(config)#int se3/0Router4(config-if)#encapsulation pppRouter4(config-if)#ppp pap sent-username r4 password 123456Chap(密码要求一致):chap是由验方发起,发送随机数报文查找数据库密码,随机数+密码返回验方单向:被验证方:Router>enableRouter#configure terminalRouter(config)#hostname R1R0(config)#interface Serial0/0/0R0(config-if)#no shutdownR0(config-if)#ip address 192.168.1.1 255.255.255.0R0(config-if)#encapsulation ppp //封装pppR0(config)#username R1 password 0 123456 //建立本地用户组验证方:Router>enableRouter#configure terminalRouter(config)#hostname R1R1(config)#interface Serial0/0/0R1(config-if)#no shutdownR1(config-if)#ip address 192.168.1.2 255.255.255.0R1(config-if)#encapsulation ppp //封装pppR1(config-if)#ppp authentication chapR1(config)#username R0 password 0 123456 //建立本地用户组双向:被验证方:Router>enableRouter#configure terminalRouter(config)#hostname R1R0(config)#interface Serial0/0/0R0(config-if)#no shutdownR0(config-if)#ip address 192.168.1.1 255.255.255.0R0(config-if)#encapsulation pppR1(config-if)#ppp authentication chapR0(config)#username R1 password 0 123456验证方:Router>enableRouter#configure terminalRouter(config)#hostname R1R1(config)#interface Serial0/0/0R1(config-if)#no shutdownR1(config-if)#ip address 192.168.1.2 255.255.255.0R1(config-if)#encapsulation pppR1(config-if)#ppp authentication chapR1(config)#username R0 password 0 123456Ospf ppp模式配置:Router0>enableRouter0#configure terminalRouter0(config)#interface Serial0/0/0Router0(config-if)#encapsulation pppRouter0(config-if)#ip ospf network point-to-point Router0(config-if)#no shutdownRouter0(config-if)#exitRouter0(config)#router ospf 1Router0(config-router)#net 10.1.1.0 0.0.0.255 area 0 Router0(config-router)#endRouter1>enableRouter1#configure terminalRouter1(config)#interface Serial0/0/0Router1(config-if)#no shutdownRouter1(config-if)#encapsulation pppRouter1(config-if)#ip ospf network point-to-point Router1(config-if)#no shutdownRouter1(config-if)#exitRouter1(config)#router ospf 1Router1(config-router)#network 20.1.1.0 0.0.0.255 area 0 Router1(config-router)#endRouter1#Show ip ospf neighbor帧中继Router3>enableRouter3#configure terminalRouter3(config)#interface Serial2/0Router3(config-if)#no shutdownRouter3(config-if)#encapsulation frame-relayRouter3(config-if)#frame-relay lmi-type ciscoRouter3(config-if)#exitRouter3(config)#int s2/0.1 point-to-pointRouter3(config-subif)#ip add 192.168.2.3 255.255.255.0 Router3(config-subif)#frame-relay interface-dlci 302 Router3(config)#int se2/0.2 point-to-pointRouter3(config-subif)#ip add 192.168.3.3 255.255.255.0 Router3(config-subif)#frame-relay interface-dlci 301Router1>enableRouter1#configure terminalRouter1(config)#interface Serial2/0Router1(config-if)#no shutdownRouter1(config-if)#encapsulation frame-relayRouter1(config-if)#frame-relay lmi-type ciscoRouter1(config-if)#exitRouter1(config)#int s2/0.1 point-to-pointRouter1(config-subif)#ip add 192.168.1.1 255.255.255.0 Router1(config-subif)#frame-relay interface-dlci 102 Router1(config)#int se2/0.2 point-to-pointRouter1(config-subif)#ip add 192.168.3.1 255.255.255.0 Router1(config-subif)#frame-relay interface-dlci 103Router2>enableRouter2#configure terminalRouter2(config)#interface Serial2/0Router2(config-if)#no shutdownRouter2(config-if)#encapsulation frame-relayRouter2(config-if)#frame-relay lmi-type ciscoRouter2(config-if)#exitRouter2(config)#int s2/0.1 point-to-pointRouter2(config-subif)#ip add 192.168.1.2 255.255.255.0Router2(config-subif)#frame-relay interface-dlci 201Router2(config)#int se2/0.2 point-to-pointRouter2(config-subif)#ip add 192.168.2.2 255.255.255.0Router2(config-subif)#frame-relay interface-dlci 203Dhcp:DHCP(Dynamic Host Configuration Protocol,动态主机配置协议),基于Client/Server工作模式,DHCP服务器为需要动态获取IP地址的客户端分配IP地址及网关、dns等其它参数开启dhcp服务R1(config)#service dhcp //开启dhcp功能配置dhcp地址池R1(dhcp-config)#network 192.168.1.0 255.255.255.0 //可以分配的地址范围192.168.1.1~192.168.1.254R1(dhcp-config)#dns-server 10.2.50.1 //配置DNSR1(dhcp-config)#default-router 192.168.1.1 //配置网关地址/*R1(config)#ip dhcp excluded-address 192.168.1.1 192.168.1.10//192.168.1.1~192.168.1.10不被dhcp分配*/静态路由就是手工配置的路由,使得数据包能够按照预定的路径传送到指定的目标网络R1(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.2 //目标地址是192.168.2.0/24的数据包,转发给192.168.3.2R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.3.1 //目标地址是192.168.1.0/24的数据包,转发给192.168.3.1R1#show ip route //查看路由R2#show ip route //查看路由RIP(Routing Information Protocol)路由协议采用距离向量算法,是一种距离向量协议。

路由器和交换机基本配置命令

路由器和交换机基本配置命令

路由器和交换机基本配置命令网络1112900系列以上交换机设置IP地址(config)# interface vlan 1 (进入VLAN 1 接口) (config-if)# ip address [IP地址] [掩码](设置IP地址)(config-if)# no shutdown (打开该接口) (config-if)# exit (返回到全局模式) (config)#例:(config)# interface vlan 1(config-if)# ip address 192.168.1.253 255.255.255.0(config-if)# no shutdown(config-if)# exitRouter设置IP地址(config)# interface [接口名](进入接口)(config-if)# ip address [IP地址] [掩码](设置IP地址)(config-if)# no shutdown(打开该接口) (config-if)# exit (返回到全局模式) (config)#例:(config)# interface f0/0(config-if)# ip address 192.168.1.254 255.255.255.0(config-if)# no shutdown(config-if)# exit(config)#定义从用户模式进入特权模式的口令:(config)# enable password [口令](设置明文口令) (config)# enable secret [口令](设置密文口令)例:(config)#enable password 12345(config)#enable secret cisco定义Console接口的口令(config)# line con 0(进入控制接口)(config-line)# password [口令](设置口令)(config-line)# login (设置口令生效)(config-line)# exit(返回到特权模式)例:User Access VerificationPassword:___________ (Console接口的口令)s1>enablePassword:___________ (从用户模式进入特权模式的口令)s1#定义Telnet用户接口的口令(config)# line vty 0 4 (进入vty接口)(config-line)# password [口令](设置口令)(config-line)# login (设置口令生效)(config-line)# exit(返回到特权模式) (config)#[0 4] 是指最多允许5位用户对设备进行Telnet登陆)给设备定义时间、日期、年份:(config)# clock timezone [时区名称] [时区范围](设置时区) # clock set [时间] [日期] [月份(英文表示)] [年份] (设置时间)例:(config)# clock timezone beijing +8(config)# exit# clock set 19:30:00 24 may 2006## show clock19:31:17.059 beijing Wed May 24 2006#(config)# banner motd #(定义启动显示文本)例:(config)# banner motd #Enter TEXT message. End with the character '#'.********************* ** xxxx ** *********************#Router上的指令# show controller [串行接口编号](查看该接口连接的是DTE线缆还是DCE线缆)例:# show controller serial 0/0 ............... ......................V.35 DTE cable ...............# show controller serial 0/0 ............... ......................V.35 DCE cable ...............如果串行接口连接的是DCE线缆,则需要定义时钟> enable# conf t(config)# interface [串行接口编号] (进入串行接口) (config-if)# clock rate 64000(定义时钟频率) (config-if)# exit (返回到全局模式) (config)#例:(config)# interface serial 0/0(config-if)# clock rate 64000(config-if)# exit(config)## show interface [接口号]Serial0/0 is up, line protocol is up(代表该接口可以正常使用)Serial0/0 is up, line protocol is down(两端协议不匹配) HDLC ---------- PPP(串行DCE接口没有设置时钟)Serial0/0 is down, line protocol is down(线缆故障)(对端设备接口没有打开,或对端设备关闭电源)Serial0/0 is administratively down, line protocol is down (人为将接口关闭,通过指令可以打开)# show running-config (查看正在运行的配置文件)# show startup-config (查看启动配置文件)# erase startup-config(清空配置文件)# reload(重新启动)例:#erase startup-configErasing the nvram filesystem will remove all files! Continue? [confirm][OK]Erase of nvram: complete## reload(config)# no ip domain-lookup (关闭域名解析) (config)# ip host [主机名] [主机IP地址] (建立静态映射)例:Switch# conf t(config)# ip host pc1 192.168.1.249(config)# exitMAC地址表初始为空,当有数据帧到达时:首先,将数据帧中的源MAC地址与接收该数据帧的端口建立对应的关系,并将这种关系放置的MAC地址表中。

交换机和路由器常用命令大全

交换机和路由器常用命令大全

交换机和路由器配置命令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、交换机口令设置switch>enable ;进入特权模式switch#config terminal ;进入全局配置模式switch(config)#hostname <hostname> ;设置交换机的主机名switch(config)#enable secret xxx ;设置特权加密口令为xxxswitch(config)#enable password xxx ;设置特权非密口令为xxxswitch(config)#line console 0 ;进控制台口(Rs232)初始化switch(config-line)#line vty 0 4 ;进入虚拟终端virtual ttyswitch(config-line)#login ;允许登录switch(config-line)#password xx ;设置登录口令xxswitch#exit ;返回命令2、交换机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 ;将当前端口1加入VLAN 2 switch(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 <name> ; 设置vtp域名switch(config)#vtp password <word> 设置vtp密码switch(config)#vtp mode serverswitch(config)#vtp mode client3、为交换机设置IP地址switch(config)#interface vlan 1 ;进入vlan 1switch(config-if)#ip address <IP> <mask> ;添加远程登录IPswitch(config)#ip default-gateway <IP> ;添加默认网关路由器基本配置命令1、路由器显示命令router#show run ;显示接口router#show interface ;显示接口router#show ip route ;显示路由router#show cdp neighbors ;看邻居router#reload ;重新启动2、路由器口令设置router>enable ;进入特权模式router#config terminal ;进入全局配置模式router(config)#hostname <hostname> ;设置路由器的主机名router(config)#enable secret xxx ;设置特权加密口令为xxxrouter(config)#enable password xxx ;设置特权非密口令为xxxrouter(config)#line console 0 ;进控制台口(Rs232)初始化router(config-line)#line vty 0 4 ;进入虚拟终端virtual ttyrouter(config-line)#login ;允许登录router(config-line)#password xx ;设置登录口令xxrouter(config)# (Ctrl+z) ; 返回特权模式router#exit ;返回命令3、为接口配置ip地址router(config)#int s0/0 ;进行串Serail接口router(config-if)#no shutdown ;激活接口router(config-if)#clock rate 64000 ;设置时钟router(config-if)#ip address 10.1.1.1 255.255.0.0 ;设置IP地址和子网掩码router(config-if)#int f0/0.1 ; 进入子接口router(config-subif.1)#ip address <ip><netmask> ;为子接口配置ip和子网掩码router#reload ;重启路由器4、静态路由的配置router(config)#ip route 目的网络号子网掩码下一跳或者送出接口5、动态路由(一)rip路由协议的配置router(config)#router rip 启动riprouter(config-router)#version 2 将rip升级为rip2router(config-router)#network xxx 发布直连的网络号router(config-router)#no auto-summary 取消自动汇总(二)ospf路由协议的配置router(config)#router ospf 进程号router(config-router)#network 直连网络号反掩码area 区域号(三)eigrp路由协议的配置router(config)#router eigrp 自治系统号router(config-router)#network xxx 发布直连的网络号router(config-router)#no auto-summary 取消自动汇总6、单臂路由的配置router(config)#interface fa0/0router(config-if)#no shutdownrouter(config-if)#exirouter(config)#interface fa0/0.10 创建子接口router(config-subif)#encapsulation dot1Q 10 规定此接口走VLAN 10的数据包router(config-subif)#ip address 192.168.10.254 255.255.255.0 此地址作为VLAN 10的默认网关7、访问控制列表(一)标准访问控制列表(ACL:1~99、1300~1999)router(config)#access-list ACL号deny|permit host ip 地址router(config)#interface <interface >router(config-if)#ip access-group ACL号in|out例子:router(config)#access-list 28 deny 192.168.3.0 0.0.0.255router(config)#access-list 28 permit anyrouter(config)#interface serial 0/0/0router(config-if)#ip access-group 28 in(二)扩展访问控制列表(ACL:100~199、2000~2699)router(config)#access-list ACL号[permit|deny] [协议] [定义过滤源主机范围] [定义过滤源端口] [定义过滤目的主机访问] [定义过滤目的端口]router(config)#interface <interface >router(config-if)#ip access-group ACL号in|out例子: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 out8、帧中继(一)帧中继三地全互联router(config)#interface <interface>router(config-if)#encapsulation frame-relayrouter(config-if)#frame-relay map ip 对方的ip 自己的DLCI broadcast例子:R1-----R2R1(config)#interface serial 0/0/0R1(config-if)#encapsulation frame-relayR1(config-if)#frame-relay map ip 192.168.4.2 102 broadcastR2(config)#interface ser0/0/0R2(config-if)#encapsulation frame-relayR2(config-if)#frame-relay map ip 192.168.4.1 201 broadcast查看R1#show frame-relay map(二)星型的静态地址映射(点到点的通信)第一步:在中心创建子接口第二步:ip地址规划。

交换机和路由器命令

交换机和路由器命令
Router#:conf t 进入全局模式
Router(config)#int f 端口 进入端口模式
Router(config-if)#:ip address ip+子网掩码 配置IP和子网掩码
Switch(config-if)#:switchport trunk allowed vlan remove vlan-id Trunk中删除VLAN
Switch(vlan)#:exit 退出和保存
全局模式下创建VLAN
Switch(config)#:vlan vlan-id 创建vlanID
Switch(config-vlan)#:name 名字 设置vlan名称
address or name of remote host[] ? 填写FTP服务器IP地址
Destination filename [c2600-i-mz.122-28.bin]? 填写目标文件名
FTP升级或还原路由器镜像
Trunk配置
Switch(config)#:interface {FastEthernet GigabitEthernet} slot/port 进入端口
Switch(config-if)#:switchport trunk encapsulation {isl dot1q negotiate} 选择封装类型
Source filename[]? 填写FTP服务器上路由镜像
Destination filename (IOS文件名) 确认回车
FTP备份路由器镜像
Router(config)#:ip ftp username 用户名 在路由器上配置ftp的用户名
扩展知识:(config)#:username 设备用户名 password 设备密码

交换机、路由器命令大全

交换机、路由器命令大全

锐捷网络配置命令和CISCO 基本一样自己总结的交换机密码1234(config)#enable secret level 1 0 1001234(config)#enable secret level 15 0 100远程登入密码1234(config)#line vty 0 41234(config-line)#password 1001234(config-line)#end交换机管理IP1234(config)#interface vlan 11234(config-if)#ip address 192.168.1.10 255.255.255.0 1234(config-if)#no shutdown修改交换机老化时间1234(config)#mac-address-table aging-time 201234(config)#end添删vlan1234(config)#vlan 8881234(config-vlan)#name a8881234(config)#no vlan 888添加access口1234(config)#interface gigabitEthernet 0/101234(config-if)#switchport mode access1234(config-if)#switchport access vlan 10切换assess trunk1234(config-if)#switchport mode access1234(config-if)#switchport mode trunk指定特定一个native vlan1234(config-if)#switchport trunk native vlan 10配置trunk口的许可vlan列表1234(config-if)#switchport trunk allowed vlan ?add Add VLANs to the current listall All VLANsexcept All VLANs except the followingremove Remove VLANs from the current list速成树协议1234(config)#spanning-tree1234(config)#spanning-tree mode rstp/stp配置网关:switch(config)#ip default-gateway 192.168.1.254交换机基本配置-常见查看命令查看CPU利用率show cpu查看交换机时钟show clock查看交换机日志show logging查看交换机动态学习到的MAC地址表show mac-address-table dynamic查看当前交换机运行的配置文件show running-config查看交换机硬件、软件信息show version查看交换机的arp表show arp显示接口详细信息的命令show interfaces gigabitEthernet 4/1 counters接口配置Switch(config)#interface gigabitethernet 0/1把接口工作模式改为光口。

思科华为全系列交换机路由器常用命令

思科华为全系列交换机路由器常用命令

思科华为全系列交换机路由器常用命令交换机/路由器配置综合复习交换机/路由器常用命令汇总本课内容交换机常用命令2交换机常用命令交换机常用命令31.交换机常用命令·>Enable进入特权模式·#E某it返回上一级操作模式·#End返回到特权模式·#writememory或copyrunning-configtartup-config保存配置文件·#delflah:config.te某t删除配置文件(交换机及1700系列路由器)·#delflah:vlan.dat删除Vlan配置信息(交换机)·(config)#hotnamewitchA配置设备名称4为witchA1.交换机常用命令·(config)#enableecretlevel10tar配置远程登陆密码为tar·(config)#enableecretlevel150tar配置特权密码为tar·Level1为普通用户级别,可选为1~15,15为最高权限级别;0表示密码不加密·(config)#enableerviceweb-erver开启交换机WEB管理功能·Service可选以下:web-erver(WEB管理)、telnet-erver(远程登陆)等51.交换机常用命令查看信息·#howrunning-config查看当前生效的配置信息·#howinterfacefatethernet0/3查看F0/3端口信息·#howinterfaceerial1/2查看S1/2端口信息·#howinterface查看所有端口信息·#howipinterfacebrief以简洁方式汇总查看所有端口信息·#howipinterface查看所有端口信息·#howverion查看版本信息61.交换机常用命令查看信息·#howmac-addre-table查看交换机当前MAC地址表信息·#howrunning-config查看当前生效的配置信息·#howvlan查看所有VLAN信息·#howvlanid10查看某一VLAN(如VLAN10)的信息·#howinterfacefatethernet0/1witchport查看某一端口模式(如F0/1)·#howaggregateport1ummary查看聚合端7口AG1的信息1.交换机常用命令查看信息·#howpanning-tree查看生成树配置信息·#howpanning-treeinterfacefatethernet0/1查看该端口的生成树状态·#howport-ecurity查看交换机的端口安全配置信息·#howport-ecurityaddre查看地址安全绑定配置信息·#howipacce-litlitname查看名为litname的列表的配置信息8·#howacce-lit1.交换机常用命令端口的基本配置·(config)#Interfacefatethernet0/3进入F0/3的端口配置模式·(config)#interfacerangefa0/1-2,0/5,0/7-9进入F0/1、F0/2、F0/5、F0/7、F0/8、F0/9的端口配置模式·(config-if)#peed10配置端口速率为10M,可选10,100,auto91.交换机常用命令端口的基本配置·(config-if)#duple某full配置端口为全双工模式,可选full(全双工),half(半双式),auto(自适应)·(config-if)#nohutdown开启该端口·(config-if)#witchportaccevlan10将该端口划入VLAN10中,用于VLAN·(config-if)#witchportmodetrunk将该端口设为trunk模式,可选模式为acce,trunk·(config-if)#port-group1将该端口划入聚合端口AG1中,用于聚合端口101.交换机常用命令聚合端口的创建·(config)#interfaceaggregateport1创建聚合接口AG1·(config-if)#witchportmodetrunk配置并保证AG1为trunk模式·(config)#intf0/23-24·(config-if-range)#port-group1将端口(端口组)划入聚合端口AG1中111.交换机常用命令生成树·(config)#panning-tree开启生成树协议·(config)#panning-treemodetp指定生成树类型为tp可选模式tp,rtp,mtp·(config)#panning-treepriority4096设置交换机的优先级为4096,优先级值小为高。

路由器和交换机命令大全

路由器和交换机命令大全

路由器和交换机命令大全不论是路由器也好,还是交换机也好,终归都是要依靠命令进行设备控制,因此你是否知道全部的命令呢?何不抓紧时间补全自己所缺失的命令,以便更好的进行工作开展。

「基础配置」进入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)#switchportmode 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和优先级越大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 inside source 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 交换机的命令行模式: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以上是交换机和路由器常用命令的大全以及配置实例。

交换机路由器命令

交换机路由器命令

交换机路由器命令1、系统配置命令1.1 基本配置命令- 设定主机名称命令:hostname [名称]- 设定启动文件位置命令:boot system [文件名]1.2 接口配置命令- 进入接口配置模式命令:interface [接口编号]- 设定IP地质命令:ip address [IP地质]1.3 路由配置命令- 设定默认路由命令:ip route 0:0:0:0 0:0:0:0 [下一跳IP地质]- 设置静态路由命令:ip route [目的网络地质] [目的子网掩码] [下一跳IP地质]1.4 网络服务设置命令- 设置DNS服务器命令:ip name-server [DNS服务器IP地质]2、VLAN配置命令2.1 创建VLAN命令- 进入全局配置模式命令:vlan database- 创建VLAN命令:vlan [VLAN编号]2.2 接口VLAN设置命令- 进入接口VLAN模式命令:interface vlan [VLAN编号]- 设定IP地质命令:ip address [IP地质]3、交换机配置命令3.1 端口设置命令- 进入端口配置模式命令:interface [端口编号]- 设置接口类型命令:switchport mode [access/trunk] - 设置接口所属VLAN命令:switchport access vlan [VLAN编号]3.2 链路聚合命令- 创建聚合组命令:interface port-channel [组号]- 将端口加入聚合组命令:channel-group [组号] mode [active/passive]3.3 STP配置命令- 进入全局配置模式命令:spanning-tree mode [STP 模式]- 设定优先级命令:spanning-tree priority [优先级]4、路由器配置命令4.1 接口配置命令- 进入接口配置模式命令:interface [接口编号]- 设定IP地质命令:ip address [IP地质]4.2 OSPF配置命令- 进入全局配置模式命令:router ospf [进程ID]- 添加网络命令:network [网络地质] [反掩码] area [区域ID]附件:1、附件1:交换机路由器配置示例文件法律名词及注释:- IP地质:Internet Protocol Address,互联网协议地质,用于标识网络中的设备的唯一地质。

交换机路由器常用命令

交换机路由器常用命令

交换机路由器常用命令交换机和路由器是网络中非常重要的设备,熟练掌握它们的常用命令对于网络管理和故障排除至关重要。

下面为您介绍一些交换机和路由器常用的命令。

一、交换机常用命令1、`enable` 命令这个命令用于进入特权模式。

在特权模式下,可以执行更多高级的配置和管理操作。

2、`configure terminal` 命令输入此命令后,可以进入全局配置模式,对交换机的整体参数进行设置。

3、`interface` 命令通过`interface` 加上接口类型和编号,例如`interface ethernet0/1` ,可以进入特定接口的配置模式,对该接口的参数进行详细配置。

4、`vlan` 命令`vlan` 相关的命令用于创建、删除和配置 VLAN(虚拟局域网)。

比如`vlan 10` 创建 VLAN 10 ,`name VLAN10` 为 VLAN 10 命名。

5、`show vlan` 命令用于查看交换机上已创建的VLAN 信息,包括VLAN 编号、名称、端口成员等。

6、`show interfaces` 命令此命令可以查看交换机各个接口的状态、速率、双工模式等详细信息。

7、`port trunk allowpass vlan` 命令在配置 trunk 链路时,使用该命令允许特定的 VLAN 通过 trunk 链路。

8、`spanningtree` 命令用于配置生成树协议,防止网络环路。

例如`spanningtree moderstp` 可以设置生成树的模式为快速生成树。

二、路由器常用命令1、`enable` 命令同样用于进入特权模式。

2、`configure terminal` 命令进入全局配置模式。

3、`interface` 命令例如`interface fastethernet 0/0` ,进入特定的接口配置模式。

4、`ip address` 命令为接口配置 IP 地址,如`ip address 19216811 2552552550` 。

路由器和交换机命令大全

路由器和交换机命令大全

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

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

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

一、路由器命令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:进入指定接口的配置模式。

H3C交换机、路由器常用配置命令大全

H3C交换机、路由器常用配置命令大全

H3C交流机设置装备摆设敕令大全【2 】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.路由器.交流机设置装备摆设时不能失落电,连通测试前必定要检讨收集的连通性,不要犯最低级的错误.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###########################################################################H3C华为交流机端口绑定根本设置装备摆设2008-01-22 13:401,端口 MACa)AM敕令应用特别的AM User-bind敕令,来完成MAC地址与端口之间的绑定.例如:[SwitchA]am user-bind mac-address 00e0-fc22-f8d3 interface Ethernet 0/1设置装备摆设解释:因为应用了端口参数,则会以端口为参照物,即此时端口E0/1只许可PC1上彀,而应用其他未绑定的MAC地址的PC机则无法上彀.但是PC1应用该MAC地址可以在其他端口上彀.b)mac-address敕令应用mac-address static敕令,来完成MAC地址与端口之间的绑定.例如:[SwitchA]mac-address static 00e0-fc22-f8d3 interface Ethernet 0/1 vlan 1[SwitchA]mac-address max-mac-count 0设置装备摆设解释:因为应用了端口进修功效,故静态绑定mac后,需再设置该端口mac进修数为0,使其他PC接入此端口后其mac地址无法被进修.2,IP MACa)AM敕令应用特别的AM User-bind敕令,来完成IP地址与MAC地址之间的绑定.例如:[SwitchA]am user-bind ip-address 10.1.1.2 mac-address 00e0-fc22-f8d3设置装备摆设解释:以上设置装备摆设完成对PC机的IP地址和MAC地址的全局绑定,即与绑定的IP地址或者MAC地址不同的PC机,在任何端口都无法上彀.支撑型号:S3026E/EF/C/G/T.S3026C-PWR.E026/E026T.S3050C.E050.S3526E/C/EF.S5012T/G.S5024Gb)arp敕令应用特别的arp static敕令,来完成IP地址与MAC地址之间的绑定.例如:[SwitchA]arp static 10.1.1.2 00e0-fc22-f8d3设置装备摆设解释:以上设置装备摆设完成对PC机的IP地址和MAC地址的全局绑定. 3,端口 IP MAC应用特别的AM User-bind敕令,来完成IP.MAC地址与端口之间的绑定.例如:[SwitchA]am user-bind ip-address 10.1.1.2 mac-address 00e0-fc22-f8d3 interface Ethernet 0/1设置装备摆设解释:可以完成将PC1的IP地址.MAC地址与端口E0/1之间的绑定功效.因为应用了端口参数,则会以端口为参照物,即此时端口E0/1只允许PC1上彀,而应用其他未绑定的IP地址.MAC地址的PC机则无法上彀.但是PC1应用该IP 地址和MAC地址可以在其他端口上彀.###############################################################[S2016-E1-Ethernet0/1]mac-address max-mac-count 0;进入到端口,用敕令mac max-mac-count 0(端口mac进修数设为0)[S2016-E1]mac static 0000-9999-8888 int e0/1 vlan 10;将0000-9999-8888绑定到e0/1端口上,此时只有绑定mac的pc可以经由过程此口上彀,同时E0/1属于vlan 10就如许,ok了,不过上面两个敕令次序不能弄反,除非端口下没有接pc#################################################################dis vlan 显示vlanname text 指定当前vlan的名称undo name 撤消[h3c] vlan 2[h3c-vlan2]name test vlandis users 显示用户dis startup 显示启动设置装备摆设文件的信息dis user-interface 显示用户界面的相干信息dis web users 显示web用户的相干信息.header login 设置装备摆设登陆验证是显示信息header shellundo headerlock 锁住当前用户界面acl 拜访掌握列表 acl number inbound/outbound[h3c]user-interface vty 0 4[h3c-vty0-4] acl 2000 inboundshutdown:封闭vlan接口undo shutdown 打开vlan接口封闭vlan1 接口[h3c] interface vlan-interface 1[h3c-vlan-interface] shutdownvlan vlan-id 界说vlanundo valn vlan-iddisplay ip routing-tabledisplay ip routing-table protocol staticdisplay ip routing-table statisticsdisplay ip routing-table verbose 查看路由表的全体具体信息interface vlan-interface vlan-id 进入valnmanagement-vlan vlan-id 界说治理vlan号reset ip routing-table statistics protocol all 消除所有路由协定的路由信息.display garp statistics interface GigabitEthernet 1/0/1 显示以太网端口上的garp统计信息display voice vlan status 查看语音vlan状况[h3c-GigabitEthernet1/0/1] broadcast-suppression 20 许可接收的最大广播流量为该端口授输才能的20%.超出部分丢弃.[h3c-GigabitEthernet1/0/1] broadcast-suppression pps 1000 每秒许可接收的最大广播数据包为1000传输才能的20%.超出部分丢弃.display interface GigabitEthernet1/0/1 查看端口信息display brief interface GigabitEthernet1/0/1 查看端口扼要设置装备摆设信息display loopback-detection 用来测试环路测试是否开启display transceiver-information interface GigabitEthernet1/0/50 显示光口相干信息duplex auto/full/half[h3c]interface GigabitEthernet1/0/1[h3c-GigabitEthernet1/0/1]duplux auto 设置端口双工属性为自协商port link-type access/hybrid/trunk 默以为accessport trunk permit vlan all 将trunk扣参加所有vlan中reset counters interface GigabitEthernet1/0/1 清晰端口的统计信息speed auto 10/100/1000display port-security 查看端口安全设置装备摆设信息am user-bind mac-addr 00e0-fc00-5101 ip-addr 10.153.1.2 interface GigabitEthernet1/0/1 端口ip 绑定display arp 显示arpdisplay am user-bind 显示端口绑定的设置装备摆设信息display mac-address 显示交流机进修到的mac地址display stp 显示生成树状况与统计信息[h3c-GigabitEthernet1/0/1]stp instance 0 cost 200 设置生成树实例0上路径开销为200stp cost 设置当前端口在指定生成树实例上路径开销.instance-id 为0-16 0表cist 取值规模1-200000< h3c> display system-guard ip-record 显示防进击记载信息.system-guard enable 启用体系防进击功效display icmp statistics icmp流量统计display ip socketdisplay ip statisticsdisplay acl allacl number acl-number match-order auto/configacl-number (2000-2999 是根本acl 3000-3999是高等acl为治理员预留的编号)rule deny/permit protocal拜访掌握[h3c] acl number 3000[h3c-acl-adv-3000]rule permit tcp source 129.9.0.0 0.0.255.255 destination 202.38.160.0 0.0.255.255 destination-port eq 80 (界说高等acl 3000,许可129.0.0/16网段的主机向202.38.160/24网段主机拜访端口80)rule permit source 211.100.255.0 0.255.255.255rule deny cos 3 souce 00de-bbef-adse ffff-ffff-fff dest 0011-4301-9912 ffff-ffff-ffff(制止mac地址00de-bbef-adse发送到mac地址0011-4301-9912且802.1p优先级为3的报文经由过程)display qos-interface GigabitEthernet1/0/1 traffic-limit 查看端口上流量端口速度限制line-rate inbound/outbound target-rateinbound:对端口吸收报文进行速度限制outbound: 对端口发送报文进行速度限制target-rate 对报文限制速度,单位kbps 千兆口inbound规模1-1000000 outbound规模20-1000000undo line-rate撤消限速.[h3c]interface GigabitEthernet1/0/1[h3c-GigabitEthernet1/0/1]line-rate outbound 128 限制出去速度为128kbpsdisplay arp | include 77display arp count 盘算arp表的记载数display ndp 显示交流机端口的具体设置装备摆设信息.display ntdp device-list verbose 收集装备具体信息display lockdisplay users display cpu display memory display fan display device display power。

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