cisco制造的路由器设备、交换机和其他设备承载了全世界80%的互联网通信,成为硅谷中新经济的传奇,那么你了解Cisco常用的路由器交换机配置命令吗?下面是我整理的一些关于Cisco常用的路由器交换机配置命令的相关资料,供你参考。 Cisco常用的路由器支持的命令: 路由器显示命令: 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 ;设置子接口IP router(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 ;开机配置存到tftp router#copy tftp flash: ;下传文件到flash router#copy tftp startup-config ;下载配置文件 ROM状态: Ctrl+Break ;进入ROM监控状态 rommon>confreg 0x2142 ;跳过配置文件 rommon>confreg 0x2102 ;恢复配置文件 rommon>reset ;重新引导 rommon>copy xmodem: flash: ;从console传输文件 rommon>IP_ADDRESS=10.65.1.2 ;设置路由器IP rommon>IP_SUBNET_MASK=255.255.0.0 ;设置路由器掩码 rommon>TFTP_SERVER=10.65.1.1 ;指定TFTP服务器IP rommon>TFTP_FILE=c2600.bin ;指定下载的文件 rommon>tftpdnld ;从tftp下载 rommon>dir flash: ;查看闪存内容 rommon>boot ;引导IOS 静态路由: ip route ;命令格式 router(config)#ip route 2.0.0.0 255.0.0.0 1.1.1.2 ;静态路由举例 router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2 ;默认路由举例 动态路由: router(config)#ip routing ;启动路由转发 router(config)#router rip ;启动RIP路由协议。
router(config-router)#network ;设置发布路由 router(config-router)#negihbor ;点对点帧中继用。
帧中继命令: 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 ;设置为DCE router(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|deny router(config)#interface ;default:deny any router(config-if)#ip access-group in|out ;defaultut 例1: router(config)#access-list 4 permit 10.8.1.1 router(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 any router(config)#int f0/0 router(config-if)#ip access-group 4 in 扩展访问控制列表: access-list permit|deny icmp [type] access-list permit|deny tcp [port] 例3: router(config)#access-list 101 deny icmp any 10.64.0.2 0.0.0.0 echo router(config)#access-list 101 permit ip any any router(config)#int s0/0 router(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 80 router(config)#access-list 102 permit ip any any router(config)#interface s0/1 router(config-if)#ip access-group 102 out 删除访问控制例表: router(config)#no access-list 102 router(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] [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 80 Router(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 p1 Router(config)#ip nat inside destination list 2 pool p2 Router(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 rotary Router#show ip nat translation rotary 参数是轮流的意思,地址池中的IP轮流与NAT分配的地址匹配。 overload参数用于PAT 将内部IP映射到一个公网IP不同的端口上。 外部网关协议配置 routerA(config)#router bgp 100 routerA(config-router)#network 19.0.0.0 routerA(config-router)#neighbor 8.1.1.2 remote-as 200 配置PPP验证: RouterA(config)#username password RouterA(config)#int s0 RouterA(config-if)#ppp authentication {chap|pap} 3.PIX防火墙命令 Pix525(config)#nameif ethernet0 outside security0 ;命名接口和级别 Pix525(config)#interface ethernet0 auto ;设置接口方式 Pix525(config)#interface ethernet1 100full ;设置接口方式 Pix525(config)#interface ethernet1 100full shutdown Pix525(config)#ip address inside 192.168.0.1 255.255.255.0 Pix525(config)#ip address outside 133.0.0.1 255.255.255.252 Pix525(config)#global (if_name) natid ip-ip ;定义公网IP区间 Pix525(config)#global (outside) 1 7.0.0.1-7.0.0.15 ;例句 Pix525(config)#global (outside) 1 133.0.0.1 ;例句 Pix525(config)#no global (outside) 1 133.0.0.1 ;去掉设置 Pix525(config)#nat (if_name) nat_id local_ip [netmark] Pix525(config)#nat (inside) 1 0 0 内网所有主机(0代表0.0.0.0)可以访问global 1指定的外网。 Pix525(config)#nat (inside) 1 172.16.5.0 255.255.0.0 内网172.16.5.0/16网段的主机可以访问global 1指定的外网。
Pix525(config)#route if_name 0 0 gateway_ip [metric] ;命令格式 Pix525(config)#route outside 0 0 133.0.0.1 1 ;例句 Pix525(config)#route inside 10.1.0.0 255.255.0.0 10.8.0.1 1 ;例句 Pix525(config)#static (inside, outside) 133.0.0.1 192.168.0.8 表示内部ip地址192.168.0.8,访问外部时被翻译成133.0.0.1全局地址。 Pix525(config)#static (dmz, outside) 133.0.0.1 172.16.0.8 中间区域ip地址172.16.0.8,访问外部时被翻译成133.0.0.1全局地址。
思科交换机常用的100个命令
思科交换机常用的100个命令 在思科交换机上的命令有哪些?哪些命令最实用,你知道吗?下面我为大家分享最常用的思科交换机基本命令,希望能帮助到大家! 1:进入特权模式enable switch> enable switch# 2:进入全局配置模式configure terminal switch> enable switch#c onfigure terminal switch(conf)# 3:交换机命名hostname aptech2950 以aptech2950 为例 switch> enable switch#c onfigure terminal switch(conf)#hostname aptch-2950 aptech2950(conf)# 4:配置使能口令enable password cisco 以cisco 为例 switch> enable switch#c onfigure terminal switch(conf)#hostname aptch2950 aptech2950(conf)# enable password cisco 5:配置使能密码enable secret ciscolab 以cicsolab 为例 switch> enable switch#c onfigure terminal switch(conf)#hostname aptch2950 aptech2950(conf)# enable secret ciscolab 6:设置虚拟局域网vlan 1 interface vlan 1 switch> enable switch#c onfigure terminal switch(conf)#hostname aptch2950 aptech2950(conf)# interface vlan 1 aptech2950(conf-if)#ip address 192.168.1.1 255.255.255.0 配置交换机端口ip 和子网掩 码 aptech2950(conf-if)#no shut 是配置处于运行中 aptech2950(conf-if)#exit aptech2950(conf)#ip default-gateway 192.168.254 设置网关地址 7:进入交换机某一端口interface fastehernet 0/17 以17 端口为例 switch> enable switch#c onfigure terminal switch(conf)#hostname aptch2950 aptech2950(conf)# interface fastehernet 0/17 aptech2950(conf-if)# 8:查看命令show switch> enable switch# 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> enable switch# erase startup-configure switch# reload 10:双工模式设置 switch> enable switch#c onfigure terminal switch2950(conf)#hostname aptch-2950 aptech2950(conf)# interface fastehernet 0/17 以17 端口为例 aptech2950(conf-if)#duplex full/half/auto 有full , half, auto 三个可选 项 11:cdp 相关命令 switch> enable switch# show cdp 查看设备的cdp 全局配置信息 show cdp interface fastethernet 0/17 查看17 端口的cdp 配置信息 show cdp traffic 查看有关cdp 包的统计信息 show cdp nerghbors 列出与设备相连的cisco 设备 12:csico2950 的密码恢复 拔下交换机电源线。 用手按着交换机的MODE 键,插上电源线 在switch:后执行flash_ini 命令:switch: flash_ini 查看flash 中的文件: switch: dir flash: 把“config.text”文件改名为“config.old”: switch: rename flash: config.text flash: config.old 执行boot: switch: boot 交换机进入是否进入配置的对话,执行no : 进入特权模式察看flash 里的文件: show flash : 把“config.old”文件改名为“config.text”: switch: rename flash: config.old flash: config.text 把“ config.text ” 拷入系统的“ running-configure ”: copy flash: config.text system : running-configure 把配置模式重新设置密码存盘,密码恢复成功。
cisco交换机安全配置设定命令
cisco交换机安全配置设定命令大全 思科交换机的安全怎么设置,下面为大家分交换机安全设置的配置命令,希望对同学们学习思科交换机有所帮助! 一、交换机访问控制安全配置 1、对交换机特权模式设置密码尽量采用加密和md5 hash方式 switch(config)#enable secret 5 pass_string 其中 0 Specifies an UNENCRYPTED password will follow 5 Specifies an ENCRYPTED secret will follow 建议不要采用enable password pass_sting密码,破解及其容易! 2、设置对交换机明文密码自动进行加密隐藏 switch(config)#service password-encryption 3、为提高交换机管理的灵活性,建议权限分级管理并建立多用户 switch(config)#enable secret level 7 5 pass_string7 /7级用户进入特权模式的密码 switch(config)#enable secret 5 pass_string15 /15级用户进入特权模式的密码 switch(config)#username userA privilege 7 secret 5 pass_userA switch(config)#username userB privilege 15 secret 5 pass_userB /为7级,15级用户设置用户名和密码,Cisco privilege level分为0-15级,级别越高权限越大 switch(config)#privilege exec level 7 commands /为7级用户设置可执行的命令,其中commands可以根据分配给用户的权限自行定义 4、本地console口访问安全配置 switch(config)#line console 0 switch(config-line)#exec-timeout 5 0 /设置不执行命令操作的超时时间,单位为分钟和秒 switch(config-line)#logging synchronous /强制对弹出的干扰日志信息进行回车换行,使用户输入的命令连续可见 设置登录console口进行密码验证 方式(1):本地认证 switch(config-line)#password 7 pass_sting /设置加密密码 switch(config-line)#login /启用登录验证 方式(2):本地AAA认证 switch(config)#aaa new-model /启用AAA认证 switch(config)#aaa authentication login console-in group acsserver local enable /设置认证列表console-in优先依次为ACS Server,local用户名和密码,enable特权密码 switch(config)#line console 0 switch(config-line)# login authentication console-in /调用authentication设置的console-in列表 5、远程vty访问控制安全配置 switch(config)#access-list 18 permit host x.x.x.x /设置标准访问控制列表定义可远程访问的PC主机 switch(config)#aaa authentication login vty-in group acsserver local enable /设置认证列表vty-in, 优先依次为ACS Server,local用户名和密码,enable特权密码 switch(config)#aaa authorization commands 7 vty-in group acsserver local if-authenticated /为7级用户定义vty-in授权列表,优先依次为ACS Server,local授权 switch(config)#aaa authorization commands 15 vty-in group acsserver local if-authenticated /为15级用户定义vty-in授权列表,优先依次为ACS Server,local授权 switch(config)#line vty 0 15 switch(config-line)#access-class 18 in /在线路模式下调用前面定义的标准ACL 18 switch(config-line)#exec-timeout 5 0 /设置不执行命令操作的超时时间,单位为分钟和秒 switch(config-line)#authorization commands 7 vty-in /调用设置的授权列表vty-in switch(config-line)#authorization commands 15 vty-in switch(config-line)#logging synchronous /强制对弹出的干扰日志信息进行回车换行,使用户输入的命令连续可见 switch(config-line)#login authentication vty-in /调用authentication设置的vty-in列表 switch(config-line)#transport input ssh /有Telnet协议不安全,仅允许通过ssh协议进行远程登录管理 6、AAA安全配置 switch(config)#aaa group server tacacs+ acsserver /设置AAA服务器组名 switch(config-sg-tacacs+)#server x.x.x.x /设置AAA服务器组成员服务器ip switch(config-sg-tacacs+)#server x.x.x.x switch(config-sg-tacacs+)#exit switch(config)# tacacs-server key paa_string /设置同tacacs-server服务器通信的密钥 二、交换机网络服务安全配置 禁用不需要的各种服务协议 switch(config)#no service pad switch(config)#no service finger switch(config)#no service tcp-small-servers switch(config)#no service udp-small-servers switch(config)#no service config switch(config)#no service ftp switch(config)#no ip http server switch(config)#no ip http secure-server /关闭http,https远程web管理服务,默认cisco交换机是启用的 三、交换机防攻击安全加固配置 MAC Flooding(泛洪)和Spoofing(欺骗)攻击 预防方法:有效配置交换机port-security STP攻击 预防方法:有效配置root guard,bpduguard,bpdufilter VLAN,DTP攻击 预防方法:设置专用的native vlan;不要的接口shut或将端口模式改为access DHCP攻击 预防方法:设置dhcp snooping ARP攻击 预防方法:在启用dhcp snooping功能下配置DAI和port-security在级联上层交换机的trunk下 switch(config)#int gi x/x/x switch(config-if)#sw mode trunk switch(config-if)#sw trunk encaps dot1q switch(config-if)#sw trunk allowed vlan x-x switch(config-if)#spanning-tree guard loop /启用环路保护功能,启用loop guard时自动关闭root guard 接终端用户的端口上设定 switch(config)#int gi x/x/x switch(config-if)#spanning-tree portfast /在STP中交换机端口有5个状态:disable、blocking、listening、learning、forwarding,只有处于forwarding状态的端口才可以发送数据。但需经过从blocking-->listening 15s,listening-->learning 15s,learning-->forwarding 20s 共计50s的时间,启用portfast后将直接从blocking-->forwarding状态,这样大大缩短了等待的时间。
说明:portfast仅适用于连接终端或服务器的交换机端口,不能在连接交换机的端口上使用! switch(config-if)#spanning-tree guard root /当一端口启用了root guard功能后,当它收到了一个比根网桥优先值更优的.BPDU包,则它会立即阻塞该端口,使之不能形成环路等情况。
这个端口特性是动态的,当没有收到更优的包时,则此端口又会自己变成转发状态了。
标签: 思科交换机配置命令重启清空了