Cisco交换机的部分命令解析
一、交换机五种模式
Swith>                                    (用户模式)
Swith#                                     (特权模式)
Swith(config)#                           (全局配置模式)
Swith(config-if)#                            (接口模式)
Swith(config-line)#                        (线模式)
二、交换机模式切换
Swith>enable                              //切换到特权
Swith#config t                             //切换到全局配置模式
Swith(config)# interface f0/1                 //进入接口f0/0
Swith(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 0
Swith(config-line)#login
Swith(config-line)#password console123   //设置console密码为telnet123
3、启用telnet密码
Swith(config)#line vty 0 15   //最多有0~15人可以telnet访问swith,合计16
Swith(config-line)#login
Swith(config-line)#password telnet123 //设置telnet密码为telnet123
注:要想真正生效telnet还要设置特权密码
交换机命名hostname BENETSW01
Swith(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   //交换机名称服务器的域名查询
六、创建、删除、查看VLAN
Switch#vlan database       //进入vlan数据库配置模式
Switch(vlan)#vlan 2        //创建VLAN2命名为vlan0002,也可以使用vlan2 name sales
VLAN 2 added:
Name: VLAN0002
Switch(vlan)#exit                 //退出时应用生效
Swith(vlan)#no vlan 2               //删除vlan2
Switch(config)# interface f0/1
Switch(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 2
Switch# show vlan brief        //查看所有VLAN的摘要信息
Switch# show vlan id vlan-id        //查看指定VLAN的信息
七、开启并查看trunk
Swith(config)#interface f0/24
Swith(config-if)#swith mode trunk //将f0/24端口设置为trunk
Switch#show interfacef0/24   switchport //查看f0/24的接口状态
八、从Trunk中添加、删除Vlan
Switch (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.1
Router(config-subif)# encapsolution dot1q 1 //子接口封装dot1q 针对的是VLAN1
Router(config-subif)# ip address  192.168.1.1 255.255.255.0 //设置VLAN的网关地址
Router(config)# interface f0/0.2
Router(config-subif)# encapsolution dot1q 2//子接口封装dot1q针对的是vlan2
Router(config-subif)# ip address192.168.2.1 255.255.255.0//设置vlan2的网关的地址
 
 
 
Cisco路由器的部分命令解析
一、路由器的模式
l         用户模式:Router>                 //用户模式
l         特权模式:Router#                 //特权模式
l         全局配置模式:Router(config)#       //配置模式
l         接口配置模式:Router(config-if)#     //接口模式
l         子接口配置模式:Router(config)#interface fa0/0.1 //进入子接口
                      Router(config-subif)# //子接口状态
l         Line模式:Router(config-line)#       //进行线模式
l         路由模式: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接口
四、密码配置
配置控制台密码
teacher(config)#line console 0
teacher((config_line)#login
teacher((config_line)#password cisco
teacher(config)#enable password cisco//配置特权模式密码
teacher(config)#enable secret 1234//配置加密保存的密码
teacher(config)#service password-encryption//对所有密码加密
五、配置路由器的banner信息
teacher(config)#banner motd $This is Aptech companys Router! Please dont change the
configuration without permission! $
六、配置路由器接口的描述信息
teacher(config)#interface fastethernet 0/0
teacher(config_if)#description
connecting the companys intranet!
七、配置控制台
配置控制台会话时间
teacher(config)#line console 0
teacher(config_line)#exec-timeout 0 0
配置控制台输出日志同步
teacher(config)#line console 0
teacher(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/0
RouterA(config-if)#ip address 192.168.1.1 255.255.255.0
RouterA(config-if)#no shutdown
RouterA(config)#interface f0/1
RouterA(config-if)#ip address 10.0.0.2 255.0.0.0
RouterA(config-if)#no shutdown
RouterA(config)#router rip
RouterA(config-router)#network 10.0.0.0
RouterA(config-router)#network 192.168.1.0
十、路由器密码恢复
进入ROM Monitor模式
修改配置寄存器的值,启动时绕过startup-config文件:
rommon1>confreg 0x2142
rommon2>reset
startup-config覆盖running-config
Router#copy startup-config running-config
修改密码:
Router(config)#enable password cisco
修改配置寄存器的值:
Router(config)#config-register 0x2102