思科常用命令_VLAN、单臂路由、静态和默认路由、DHCP、ACL、远程访问、VTP、STP、检验默认交换机配置、检查交换机的 Cisco IOS 版本信息

双斜杠后面的文字是解释说明前面的命令用途(有些太长的命令直接Tab)
Switch> enable //进入特权模式
Switch# configure terminal //进入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname S1 //给交换机重命名

S1(config)# service password-encryption //配置密码加密
S1(config)# enable secret class //指定class作为特权EXEC模式访问的使能加密口令,口令为class
S1(config)# no ip domain-lookup //防止没必要的DNS查找
S1(config)# banner motd # //配置MOTD标语
Enter Text message. End with the character ‘#’.
Unauthorized access is strictly prohibited. # //自己输入的内容,前面motd跟着什么内容,结尾的时候也要跟什么内容

S1 (config)#line console 0 //进入控制台线路
S1 (config-line)#password cisco //为控制台线路设置口令
S1(config-line)#login //启用认证
S1(config-line)# logging synchronous //日志同步
S1(config-line)#exec-timeout 10 30 //输入超时时间

S1 (config)#line vty 0 4 //进入vty线路
S1 (config-line)#password cisco
S1 (config-line)#login
S1(config-line)# logging synchronous
S1(config-line)#exec-timeout 10

S1 (config)#interface fa0/22 //进入端口
S1 (config-if)#description Connect to SW2 //描述(根据题目要求,看看该端口与谁连接)
S1 (config-if)#duplex full/half //设置全/半双工(二选一)
S1 (config-if)#mdix auto //设置自动MDIX
S1 (config-if)#exit
S1(config)#

配置VLAN

S1(config)#vlan 99 //创建vlan
S1(config-vlan)#name Floor1 //给vlan命名
S1(config-vlan)#exit
S1(config)# interface range fa0/1-10 //进入接口
S1(config-if)#switchport trunk encapsulation dot1q //三层交换机配置中继端口需要先封装协议
S1(config-if-range)#switchport mode access(trunk) //配置端口模式
S1(config-if)#switchport access(trunk native) vlan 10 //将接口加到vlan里

单臂路由:

R0(config)#interface g0/1.99 //进入虚拟子接口
R0(config-subif)#encapsulation dot1q 99 (native) //将该虚拟子接口与VLAN 99绑定,(并指定该VLAN为本征VLAN)
R0(config-subif)#ip address 192.168.99.254 255.255.255.0 //配置IP地址

S1(config)# interface vlan 99 //配置虚拟vlan
S1(config-if)# ip address 192.168.1.1 255.255.255.0 //配置IP地址
S1(config-if)# no shutdown //开启接口
S1(config-if)# exit
S1(config)#ip default-gateway 192.168.1.254 //配置默认网关

S1(config)#interface range fa0/1-21 //进入所有已用接口
S1(config-if-range)#switchport mode access //配置端口模式
S1(config-if-range)#switchport port-security //开启端口安全
S1(config-if-range)#switchport port-secruity maximum 1 //最大安全MAC地址
S1(config-if-range)#switchport port-secruity violation shutdown //违规模式
S1(config-if-range)#switchport port-security mac-address sticky //安全MAC地址获取方式
S1(config-if-range)#exit
S1(config)#interface range fa0/2-21,fa0/24 //进入所有未使用端口
S1(config-if-range)#shutdown //关闭端口

配置静态和默认路由

S1(config)#ip route 目的网段 子网掩码 下一跳IP //配置静态路由
S1(config)#ip route 0.0.0.0 0.0.0.0 下一跳IP或下一跳的接口 //配置默认路由

配置DHCP

R1(config)#ip dhcp pool VLAN10 //建立名称为VLAN10的DHCP地址池
R1(dhcp-

你可能感兴趣的:(计算机网络技术,网络,交换机,路由器,思科)