设为首页 收藏本站
查看: 838|回复: 0

[经验分享] Cisco的基础命令

[复制链接]

尚未签到

发表于 2018-7-12 13:20:47 | 显示全部楼层 |阅读模式
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 2
  switch(vlan)#no vlan 2 ;删vlan 2
  switch(config)#int f0/1 ;进入端口1
  switch(config-if)#switchport access vlan 2 ;当前端口加入vlan 2
  switch(config-if)#switchport mode trunk ;设置为干线
  switch(config-if)#switchport trunk allowed vlan 1,2 ;设置允许的vlan
  switch(config-if)#switchport trunk encap dot1q ;设置vlan 中继
  switch(config)#vtp domain ;设置发vtp域名
  switch(config)#vtp password ;设置发vtp密码
  switch(config)#vtp mode server ;设置发vtp模式
  switch(config)#vtp mode client ;设置发vtp模式
  交换机设置IP地址:
  switch(config)#interface vlan 1 ;进入vlan 1
  switch(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 ;设置子接口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 ;点对点帧中继用。2)配置命令
  show running config 显示所有的配置
  show versin 显示版本号和寄存器值
  shut down 关闭接口
  no shutdown 打开接口
  ip add +ip地址 配置IP地址
  secondary+IP地址 为接口配置第二个IP地址
  show interface+接口类型+接口号 查看接口管理性
  show controllers interface 查看接口是否有DCE电缆
  show history 查看历史记录
  show terminal 查看终端记录大小
  hostname+主机名 配置路由器或交换机的标识
  config memory 修改保存在NVRAM中的启动配置
  exec timeout 0 0 设置控制台会话超时为0
  service password-encryptin 手工加密所有密码
  enable password +密码 配置明文密码
  ena sec +密码 配置密文密码
  line vty 0 4/15 进入telnet接口
  password +密码 配置telnet密码
  line aux 0 进入AUX接口
  password +密码 配置密码
  line con 0 进入CON接口
  password +密码 配置密码
  bandwidth+数字 配置带宽
  no ip address 删除已配置的IP地址
  show startup config 查看NVRAM中的配置信息
  copy run-config atartup config 保存信息到NVRAM
  write 保存信息到NVRAM
  erase startup-config 清除NVRAM中的配置信息
  show ip interface brief 查看接口的谪要信息
  banner motd # +信息 + # 配置路由器或交换机的描素信息
  description+信息 配置接口听描素信息
  vlan database 进入VLAN数据库模式
  vlan +vlan号+ 名称 创建VLAN
  switchport access vlan +vlan号 为VLAN为配接口
  interface vlan +vlan号 进入VLAN接口模式
  ip add +ip地址 为VLAN配置管理IP地址
  vtp+service/tracsparent/client 配置SW的VTP工作模式
  vtp +domain+域名 配置SW的VTP域名
  vtp +password +密码 配置SW的密码
  switchport mode trunk 启用中继
  no vlan +vlan号 删除VLAN
  show spamming-tree vlan +vlan号 查看VLA怕生成树议
  2.路由器配置命令
  ip route+非直连网段+子网掩码+下一跳地址 配置静态/默认路由
  show ip route 查看路由表
  router rip 激活RIP协议
  network +直连网段 发布直连网段
  interface lookback 0 激活逻辑接口
  passive-interface +接口类型+接口号 配置接口为被动模式
  debug ip +协议 动态查看路由更新信息
  undebug all 关闭所有DEBUG信息
  router eigrp +as号 激活EIGRP路由协议
  network +网段+子网掩码 发布直连网段
  show ip eigrp neighbors 查看邻居表
  show ip eigrp topology 查看拓扑表
  show ip eigrp traffic 查看发送包数量
  router ospf +process-ID 激活OSPF协议
  network+直连网段+area+区域号 发布直连网段
  show ip ospf 显示OSPF的进程号和ROUTER-ID
  encapsulation+封装格式 更改封装格式
  no ip admain-lookup 关闭路由器的域名查找
  ip routing 在三层交换机上启用路由功能
  show user 查看SW的在线用户
  clear line +线路号 清除线路
  3.三层交换机配置命令
  配置一组二层端口
  configure terminal 进入配置状态
  nterface range {port-range} 进入组配置状态
  配置三层端口
  configure terminal 进入配置状态
  interface {{fastethernet | gigabitethernet} interface-id} | {vlan vlan-id} | {port-channel port-channel-number} 进入端口配置状态
  no switchport 把物理端口变成三层口
  ip address ip_address subnet_mask 配置IP地址和掩码
  no shutdown 激活端口
  例:
  Switch(config)# interface gigabitethernet0/2
  Switch(config-if)# no switchport
  Switch(config-if)# ip address 192.20.135.21 255.255.255.0
  Switch(config-if)# no shutdown
  配置VLAN
  configure terminal 进入配置状态
  vlan vlan-id 输入一个VLAN号, 然后进入vlan配态,可以输入一个新的VLAN号或旧的来进行修改。
  name vlan-name 可选)输入一个VLAN名,如果没有配置VLAN名,缺省的名字是VLAN号前面用0填满的4位数,如VLAN0004是VLAN4的缺省名字
  mtu mtu-size (可选) 改变MTU大小
  例
  Switch# configure terminal
  Switch(config)# vlan 20
  Switch(config-vlan)# name test20
  Switch(config-vlan)# end
  或
  Switch# vlan database
  Switch(vlan)# vlan 20 name test20
  Switch(vlan)# exit
  将端口分配给一个VLAN
  configure terminal 进入配置状态
  interface interface-id 进入要分配的端口
  switchport mode access 定义二层口
  switchport access vlan vlan-id 把端口分配给某一VLAN
  例
  Switch# configure terminal
  Enter configuration commands, one per line. End with CNTL/Z.
  Switch(config)# interface fastethernet0/1
  Switch(config-if)# switchport mode access
  Switch(config-if)# switchport access vlan 2
  Switch(config-if)# end
  Switch#

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-536528-1-1.html 上篇帖子: Cisco正式停止MARS产品的销售 下篇帖子: Cisco4506 灌入K9版本IOS之后产生的问题与解决方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表