㈠ 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