导航:首页 > 程序命令 > 思科交换机命令行教程

思科交换机命令行教程

发布时间:2022-11-20 21:56:31

㈠ CISCO交换机配置VLAN的具体命令

交换机支持的命令:


交换机基本状态:
switch: ;ROM状态, 路由器是rommon>
hostname> ;用户模式
hostname# ;特权模式
hostname(config)# ;全局配置模式
hostname(config-if)# ;接口状态

㈡ 交换机的基本命令是什么

“Switch>”

㈢ Cisco交换机VLAN与TRUNK链路配置命令

你还在为Cisco交换机VLAN与TRUNK链路配置命令而烦恼么?不用担心,接下来是我为大家收集的Cisco交换机VLAN与TRUNK链路配置命令,欢迎大家阅读:
Cisco交换机VLAN与TRUNK链路配置命令的方法
在2950系列交换机上配置VLAN

(1)使用vlan database命令进入VLAN配置模式

C2950A#vlan database

(2)创建VLAN

C2950A(vlan)#vlan 2

(3)划分VLAN(将交换机的2-14,23端口划入VLAN 2)

C2950(config)#interface range f0/2-14

C2950(config-if-range)#switchport mode access

C2950(config-if-range)#switchport access vlan 2

C2950(config)#interface f0/3

C2950(config-if)#switchport mode access

C2950(config-if)#switchport access vlan 2

(4)查看vlan信息

C2950#show vlan

(5) 删除配置(删除VLAN 100下的端口)

C2950(config)#interface range f0/2-14

C2950(config-if-range)#no switchport access vlan 2

配置Trunk的过程:

(1) 选择需要的接口,进入接口配置模式

Switch(config)# interface f0/24

(2) 在接口配置模式下直接配置中继

Switch (config-if)#switchport mode trunk

(3) 添加VLAN(VID)

Switch (config-if)#switchport trunk allowed vlan all

看了“Cisco交换机VLAN与TRUNK链路配置命令”还想看:

1. 思科交换机配置命令教程

2. 2015年网络工程师学习笔记:交换机及其配置

3. cisco交换机怎么配置vlan与trunk

4. 思科交换机配置教程详解

5. 交换机如何配置vlan及turnk口

6. h3c交换机配置命令详细解释

7. 华为交换机配置的命令有哪些

㈣ 思科交换机常用命令汇总1-以太网和vlan

1. 以太网

1. 接口MTU和ip MTU

Switch(config-if)#mtu 1500

Switch(config-if)#ip mtu 1500

Switch#sh int s1/0

Switch#sh ip int s1/0

2. 管理MAC表

48位,点分十六进制表示

Switch#show mac address-table

Switch#clear mac address-table

Switch(config)#mac address-table static aaaa.bbbb.cccc vlan 10 interface e0/0

2. 二层交换

1. Protected port

Switch(config-if)#switchport protected

2. Native Vlan

Switch(config-if)#switchport trunk native vlan 10

Switch(config)#vlan dot1q tag native

配置对native vlan也打标签

Vlan范围:(dot1q)

3. Trunk配置

ISL:支持1-1005个vlan编号

DOT1Q:支持1-4094个vlan编号

Switch(config-if)#switchport mode access

将接口设置为access模式

Switch(config-if)#switchport trunk encapsulation {dot1q | ISL | negotiate }

Switch(config-if)#switchport mode {auto | desirable |trunk}

Switch#show interface f0/8 switchport

将接口设置为DTP动态协商,可auto或desirable

Switch(config-if)#switchport nonegotiate

将接口设置为nonegotiate,不发送DTP帧,如果配置为非协商,那么必须手工配置接口模式为access或trunk

Switch(config-if)#switchport mode dynamic [auto | desirable]

配置接口为协商模式

Switch#show interface trunk 查看trunk状态

Switch#show interfaces fa0/0 switchport 查看接口二层trunk信息

Switch(config-if)#switchport trunk allowed vlan {WORD | add | all | except | none | remove}

Switch1(config-if)#switchport trunk allowed vlan ?

WORD VLAN IDs of the allowed VLANs when this port is in trunking mode

add add VLANs to the current list

all all VLANs

except all VLANs except the following

none no VLANs

remove remove VLANs from the current list

Switch(config-if)#switchport trunk allowed vlan remove 20

Switch#show interface f0/8 switchport

查看接口trunk/vlan/private-vlan信息

4. VTP

1. VTP配置

Switch1(config)#vtp domain cisco

Switch1(config)#vtp mode {server | client |transparent}

Switch1(config)#vtp password 123456

Switch1#sh vtp password

2. VTP pruning

Switch1#sh vtp status

3. 查看trunk及allowed vlan状态

Switch1#sh int trunk

4. VTP pruning

Switch2(config)#vtp pruning

开启VTP修剪

Switch1#sh vtp status

查看VTP状态

5. 私有VLAN(PVLAN)

1. 创建主VLAN:

Vlan 100

Private-vlan primary

2. 创建辅助VLAN

Vlan 101

Private-vlan community

Vlan 102

Private-vlan ioslate

3. 配置主VLAN,将二层辅助VLAN关联到主VLAN

Vlan 100

Private-vlan association 101,102

4. 将辅助VLAN映射到主VLAN的SVI接口,从而允许PVLAN入口流量的三层交换。

Interface vlan 100

Private-vlan mapping add 101,102

5. 配置接口

Interface f0/1

Switchport mode private-vlan host

Switchport private-vlan host-association 100 101 //关联主VLAN和辅助VLAN到接口

Interface f0/2

Switchport mode private-vlan host

Switchport mode private-vlan host-association 100 102

主机接口配置

Interface f0/3

Switchport mode private-vlan promiscuous

Switchport private-vlan mapping add 100 101 //将端口映射到PLAN

混杂端口配置

6. 查看及验证

Show pvlan mapping

PLAN配置示例

Sw(config)#vtp transparent

Sw(config)#vlan 201

Sw(config-vlan)#private-vlan isolated

Sw(config)#vlan 202

Sw(config-vlan)#private-vlan community

Sw(config)#vlan 100

Sw(config-vlan)#private-vlan primary

Sw(config-vlan)#private-vlan association 201,202

!

Sw(config)#interface fa0/24

Sw(config-if)#switchport mode private-vlan promiscuous

Sw(config-if)#switchport mode private-vlan mapping 100 201,202

Sw(config)#interface range fa 0/1 - 2

Sw(config-if)#switchport mode private-vlan host

Sw(config-if)#switchport private-vlan host-association 100 202

Sw(config)#interface range fa 0/3 - 4

Sw(config-if)#switchport mode private-vlan host

Sw(config-if)#switchport private-vlan host-association 100 201

㈤ 思科交换机常用的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)#plex 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 ”: flash: config.text system :

running-configure

把配置模式重新设置密码存盘,密码恢复成功。

13:交换机telnet 远程登录设置:

switch>en

switch#c onfigure terminal

switch(conf)#hostname aptech-2950

aptech2950(conf)#enable password cisco 以cisco 为特权模式密码

aptech2950(conf)#interface fastethernet 0/1 以17 端口为telnet 远程登录端口

aptech2950(conf-if)#ip address 192.168.1.1 255.255.255.0

aptech2950(conf-if)#no shut

aptech2950(conf-if)#exit

aptech2950(conf)line vty 0 4 设置0-4 个用户可以telnet 远程登陆

aptech2950(conf-line)#login

aptech2950(conf-line)#password edge 以edge 为远程登录的用户密码

主机设置:

ip 192.168.1.2 主机的ip 必须和交换机端口的地址在同一网络



netmask 255.255.255.0

gate-way 192.168.1.1 网关地址是交换机端口地址

运行:

telnet 192.168.1.1

进入telnet 远程登录界面

password : edge

aptech2950>en

password: cisco

aptech#

14:交换机配置的重新载入和保存

设置完成交换机的配置后:

aptech2950(conf)#reload

是否保存(y/n) y: 保存设置信息n:不保存设置信息

1.在基于IOS 的.交换机上设置主机名/系统名:

switch(config)# hostname hostname

在基于CLI 的交换机上设置主机名/系统名:

switch(enable) set system name name-string

2.在基于IOS 的交换机上设置登录口令:

switch(config)# enable password level 1 password

在基于CLI 的交换机上设置登录口令:

switch(enable) set password

switch(enable) set enalbepass

3.在基于IOS 的交换机上设置远程访问:

switch(config)# interface vlan 1

switch(config-if)# ip address ip-address netmask

switch(config-if)# ip default-gateway ip-address

在基于CLI 的交换机上设置远程访问:

switch(enable) set interface sc0 ip-address netmask broadcast-address

switch(enable) set interface sc0 vlan

switch(enable) set ip route default gateway

4.在基于IOS 的交换机上启用和浏览CDP 信息:

switch(config-if)# cdp enable

switch(config-if)# no cdp enable

为了查看Cisco 邻接设备的CDP 通告信息:

switch# show cdp interface [type modle/port]

switch# show cdp neighbors [type mole/port] [detail]

在基于CLI 的交换机上启用和浏览CDP 信息:

switch(enable) set cdp {enable|disable} mole/port

为了查看Cisco 邻接设备的CDP 通告信息:

switch(enable) show cdp neighbors[mole/port] [vlan|plex|capabilities|detail]

5.基于IOS 的交换机的端口描述:

switch(config-if)# description description-string

基于CLI 的交换机的端口描述:

switch(enable)set port name mole/number description-string

6.在基于IOS 的交换机上设置端口速度:

㈥ 思科交换机的配置保存命令

1、首先打开思科交换CLI,从特权模式进入全局配置模式,如下图所示。

㈦ 10个常见cisco交换机的操作命令,并介绍其作用

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 ;设置登录口令xxswitch#exit ;返回命令

交换机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 ;当前端口加入vlan 2switch(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 ;设置发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 1switch(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 ;设置登录口令xxrouter(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 ;设置第二个IProuter(config-if)#int f0/0.1 ;进入子接口router(config-subif.1)#ip address ;设置子接口IProuter(config-subif.1)#encapsulation dot1q ;绑定vlan中继协议router(config)#config-register 0x2142 ;跳过配置文件router(config)#config-register 0x2102 ;正常使用配置文件router#reload ;重新引导

路由器文件操作:

router# running-config startup-config ;保存配置router# running-config tftp ;保存配置到tftprouter# startup-config tftp ;开机配置存到tftprouter# tftp flash: ;下传文件到flashrouter# tftp startup-config;下载配置文件ROM状态:

Ctrl+Break ;进入ROM监控状态

rommon>confreg 0x2142 ;跳过配置文件

rommon>confreg 0x2102 ;恢复配置文件

rommon>reset ;重新引导

rommon> 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 ;点对点帧中继用。

㈧ 思科的简单交换机命令 能借鉴一下吗

非我抢答,有无赖盗用了我的帐号,抱歉。
CISCO交换机基本配置:Console端口连接
用户模式hostname> ;
特权模式hostname(config)# ;
全局配置模式hostname(config-if)# ;
交换机口令设置:
switch>enable ;进入特权模式
switch#config;进入全局配置模式
switch(config)#hostname csico ;设置交换机的主机名
switch(config)#enable secret csico1 ;设置特权加密口令
switch(config)#enable password csico8 ;设置特权非密口令
switch(config)#line console 0 ;进入控制台口
switch(config-line)#line vty 0 4 ;进入虚拟终端
switch(config-line)#login ;虚拟终端允许登录
switch(config-line)#password csico6 ;设置虚拟终端登录口令csico6
switch#write 保存配置设置
switch# running-config startup-config 保存配置设置,与write一样
switch#exit ;返回命令
配置终端过一会时间就会由全局配置模式自动改为用户模式,将超时设置为永不超时
switch#conf t
switch(config)#line con 0
switch(config-line)#exec-timeout 0
---------------------------------------------------------------------------------
交换机显示命令:
switch#write ;保存配置信息
switch#show vtp ;查看vtp配置信息
switch#show run ;查看当前配置信息
switch#show vlan ;查看vlan配置信息
switch#show vlan name vlan2
switch#show interface ;查看端口信息
switch#show int f0/0 ;查看指定端口信息
switch#show int f0/0 status;查看指定端口状态
switch#show interface status
switch#dir flash: ;查看闪存
switch#show running-config
switch(config)#do show running-config 显示存储在内存中的当前正确配置文件。
show startup-configuration:显示存储在非易失性存储器(NVRAM)的配置文件。
show users:显示所有连接到路由器的用户。
show hosts:显示主机名和地址信息。
switch(config)#do show interface
switch(config-if)#do show int f0/21
switch#show arp
switch#show mac-address-table
------------------------------------------------------------------------------
2960交换机上配置,配置IP及网关
switch#conf t
switch(config)#interface vlan1 进入vlan 1特殊接口配置模式
switch(config-if)#ip address 192.168.1.1 255.255.255.0 设置交换机的管理IP地址
switch(config)#ip default-gateway 192.168.1.1 设置交换机的网关地址
switch(config)#ip domain-name pctc.com.cn 设置交换机所连域的域名
switch(config)#no ip domain-name
switch#ip name-server 218.87.18.230 设置交换机所连域的域名服务器IP
switch#show int vlan 1 查看交换机的VLAN 1特殊接口配置信息
switch#show run 查看交换机的当前运行配置等全部信息
--------------------------------------------------------------------------------
交换机VLAN创建,删除,端口属性的设置,配置trunk端口,将某端口加入vlan中,配置VTP:
switch(config)#vlan 2
switch#vlan database ;进入VLAN设置
switch(vlan)#vlan 2 ;建VLAN 2
switch(vlan)#vlan 3 name vlan3 ;建VLAN 3并命名为vlan3
switch(vlan)#no vlan 2 ;删vlan 2
switch(config)#int f0/1 ;进入端口1
switch(config)#speed ? 查看speed命令的子命令
switch(config)#speed 100 设置该端口速率为100mb/s (10/auto)
switch(config-if)#do show int f0/21 显示21口配置信息
switch(config-if)#shut ;shutdown 关闭当前端口
switch(config-if)#no shut ;no shutdown 开启当前端口
switch(config)#plex ? 查看plex的子命令
switch(config)#plex full 设置该端口为全双工(auto/half)
switch(config)#description TO_PC1 这是该端口描述为TO_PC1
switch(config)#interface f0/21
switch(config-if)#switchport access vlan 2 ;当前端口加入vlan 2
switch(config-if)#switchport mode trunk ;设置为trunk模式(access模式)
switch(config-if)#switchport trunk allowed vlan 1,2 ;设置允许的vlan
switch(config-if)#switchport trunk encap dot1q ;设置vlan 中继
switch(config)#vtp domain vtpserver ;设置vtp域名相同
switch(config)#vtp password ;设置发vtp密码
switch(config)#vtp server ;设置vtp服务器模式
switch(config)#vtp client ;设置vtp客户机模式
---------------------------------------------------------------------------------------
交换机设置IP地址,默认网关,域名,域名服务器,配置和查看MAC地址表:
switch(config)#interface vlan 1 ;进入vlan 1
switch(config-if)#ip address 192.168.1.1 255.255.255.0 ;设置IP地址
switch(config)#ip default-gateway 192.168.1.6 ;设置默认网关
switch(config)#ip domain-name cisco.com 设置域名
switch(config)#ip name-server 192.168.1.18 设置域名服务器
switch(config)#mac-address-table? 查看mac-address-table的子命令
switch(config)#mac-address-table aging-time 100 设置超时时间为100ms
switch(config)#mac-address-table permanent 0000.0c01.bbcc f0/3 加入永久地址在f0/3端口
switch(config)#mac-address-table restricted static 0000.0c02.bbcc f0/6 f0/7 加入静态地址目标端口f0/6源端口f0/7
switch(config)#end
switch#show mac-address-table 查看整个MAC地址表
switch#clear mac-address-table restricted static 清除限制性静态地址
-----------------------------------------------------------------------------------
交换机端口加入vlan
将多个端口加入到VLAN2
switch(config)#interface range fa 0/17-24
switch(config-if-range)#switchport access vlan 2
单个端口加入VLAN
switch(config)#interface f0/1
switch(config-if-range)#switchport access vlan 2
--------------------------------------------------------------------------------
交换机的端口和MAC地址表的设置
2960交换机配置端口属性
switch#conf t
switch#interface ethernet 0/1
进入第1个端口
switch#description switch-e0/1-pc1
给端口写入注释信息
switch#plex auto/full/full-flow-control/half
设置端口的工作模式
switch#port secure
启用端口安全性
switch#port secure max-mac-count 1
设置该端口允许对应的MAC地址数(默认132个)
switch#sh mac-address-table security
查看端口安全性
2912交换机配置端口属性
switch#conf t
进入全局配置模式
switch#interface fastethernet 0/1
进入第1个端口
switch#description switch-f0/1-pc1
给端口写入注释信息
switch#plex auto/full/half
设置端口的工作模式
switch#port security
启用端口安全性
switch#port security max-mac-count 1
设置该端口允许对应的MAC地址数(默认132个)
switch#end
返回特权模式
switch#sh port security
查看端口安全性
配置和查看MAC地址表
1924交换机配置MAC地址表
switch#mac-address-table aging-time 600
设置动态地址超时时间
switch#mac-address-table permanent 0000.0cdd.5a4d e0/3
定义永久MAC地址(绑定MAC地址)
switch#mac-address-table restricted static 0000.0cdd.aaed e0/6 e0/7
定义受限MAC地址
switch#address-violation disable/ignore/suspend
定义地址安全违规
switch#show mac-address-table
查看上述配置
switch#clear mac-addr restric static
清除受限MAC地址表项
2912交换机配置MAC地址表
switch#mac-address-table aging-time 700
设置动态地址超时时间
switch#mac-address-table static 0000.0cdd.5a4d e0/3
定义永久MAC地址(绑定MAC地址)
switch#mac-address-table secure 00d0.f80d.3333 f0/3 vlan 1
定义受限MAC地址
switch#port security action shutdown/trap
定义地址安全违规
switch#show port security
查看上述配置
配置VTP、VLAN、VLAN Trunk和STP
配置VTP
switch#conf t
switch#vtp server
定义VTP的工作模式
switch#vtp domain cisco
定义VTP的域名
switch#trunk on
启用干道
switch#vtp domain cisco
加入VTP域
switch#vtp client
定义VTP的工作模式
switch#trunk on
启用干道
switch#show trunk b
switch#show trunk b allowed-vlans
查看干道信息
配置VLAN
switch#vlan 10 dept1
switch#vlan 20 dept2
switch#vlan 30 dept3
switch#vlan 40 dept4
定义所需VLAN
switch#show vlan
查看VLAN信息
switch#show vlan
switch#show vtp
查看VTP的信息
switch#int e0/1
switch#vlan-membership static 10
switch#int e0/2
switch#vlan-membership static 20
switch#int e0/3
switch#vlan-membership static 30
switch#int e0/4
switch#vlan-membership static 40
把接口划入各自VLAN
配置spanning tree
switch#spantree 1
启用生成树协议
switch#sh spantree 1
查看生成树信息
switch#no spantree 1
关闭生成树协议
switch#sh spantree 1
查看生成树信息
交换机上屏蔽个别MAC地址方法
configure terminal
interface gigabitEthernet 0/20
switchport
sw mode acc
sw port-sec
sw port-sec mac-add [macaddress]
sw port-sec max 1
sw port-sec violation restrict

㈨ 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,bpguard,bpfilter

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包,则它会立即阻塞该端口,使之不能形成环路等情况。这个端口特性是动态的,当没有收到更优的包时,则此端口又会自己变成转发状态了。

switch(config-if)#spanning-tree bpfilter enable

/当启用bpfilter功能时,该端口将丢弃所有的bp包,可能影响网络拓扑的稳定性并造成网络环路

switch(config-if)#spanning-tree bpguard enable

/当启用bpguard功能的交换机端口接收到bp时,会立即将该端口置为error-disabled状态而无法转发数据,进而避免了网络环路!

注意:同时启用bpguard与bpfilter时,bpfilter优先级较高,bpguard将失效!

广播、组播风暴控制设定

switch(config-if)#storm-control broadcast level 10 /设定广播的阀值为10%

switch(config-if)#storm-control multicast level 10 /设定组播的阀值为10%

switch(config-if)#storm-control action shutdown / Shutdown this interface

if a storm occurs

or switch(config-if)#storm-control action trap / Send SNMP trap if a storm

阅读全文

与思科交换机命令行教程相关的资料

热点内容
程序员秃顶搞笑相遇 浏览:4
IBM手机app商店叫什么名字 浏览:832
jpeg压缩质量 浏览:774
云服务器评测对比 浏览:143
java日期转string 浏览:219
openfire源码编译 浏览:897
在线小工具箱引流网站源码 浏览:335
非科班程序员自学 浏览:799
压缩泡沫鞋底底材 浏览:219
程序员职场第一课2正确的沟通 浏览:679
遇到不合法app应该怎么办 浏览:90
汇编程序编译后的文件 浏览:77
大智慧均线源码 浏览:373
单片机排阻的作用 浏览:215
滴滴金融app被下架如何还款 浏览:212
jpg转换成pdf免费软件 浏览:743
范里安pdf 浏览:445
伪造pdf 浏览:77
能删除android文件夹吗 浏览:446
LINUX使用V2ray 浏览:797