Cisco 2960交換機配置
1、 Cisco工作模式分類及作用
#用戶模式僅答應基本的監測命令,在這種模式下不能改變路由器的配置。
Switch> #用戶模式
#允許用戶執行所有的測試、查看、保存等命令,這種模式下不能進行路由器配置的修改,一般此模式建議設置密碼保護。
Switch>enable #進入特權模式
Switch#
#允許用戶配置路由器。
Switch#configure terminal #進入全局模式
Switch(config)#
#允許用戶配置fastEthernet 0/1接口。
Switch(config)#interface fastEthernet 0/1 #進入配置fa 0/1接口模式
Switch(config-if)#
2、 基本操作
#全局模式下修改交換機名稱
Switch(config)#hostname test01(交換機名稱)
#全局模式下設置登陸特權加密密碼
Switch(config)#enable secret 123456
#全局模式下設置登陸特權非加密密碼
Switch(config)#enable password 123456
#特權模式下查看Vlan信息
Switch#show vlan
#特權模式下查看端口信息
Switch#show interfaces fa0/1
#特權模式下查看交換機系統版本、型號、開機時間等等
Switch#show version
3、 設置交換機時間
標注:普通思科交換機一般不帶電池保存時間,交換機重啟后時鍾都會恢復到初始化時間,建議配置NTP服務。
#特權模式下顯示交換機時間
Switch#show clock
#特權模式下修改交換機時間
Switch#clock set 17:42:00 22 Mar 2017
4、 配置Vlan
#特權模式下進入Vlan子模式
Switch#vlan database
#創建vlan並命名為test01
Switch(vlan)#vlan 10 name test01
#退出Vlan配置模式
Switch(vlan)#exit
#返回到特權模式下查看Vlan創建情況
Switch#show vlan
4、刪除Vlan
#特權模式下進入Vlan子模式
Switch#vlan database
#刪除已創建好的Vlan
Switch(vlan)#no vlan 10
#返回到特權模式下查看指定的Vlan創建情況
Switch#show vlan id 10
5、 將端口划入指定的Vlan
#全局模式下進入fa/01端口模式
Switch(config)#interface fastEthernet 0/1
#將fa0/1端口划分到Vlan 10
Switch(config-if)#switchport access vlan 10
#fa0/1設置成靜態Vlan訪問模式
Switch(config-if)#switchport mode access
#激活fa0/1接口
Switch(config-if)#no shutdown
#全局模式下進入fa/02端口到fa0/10端口模式
Switch(config)#interface range fastEthernet 0/2-10
#將入fa/02端口到fa0/10端口划分到Vlan10
Switch(config-if-range)#switchport access vlan 10
# fa/02端口到fa0/10端口設置成靜態Vlan訪問模式
Switch(config-if-range)#switchport mode access
# 激活fa/02端口到fa0/10端口
Switch(config-if-range)#no shutdown
#返回到特權模式下查看指定的Vlan創建情況
Switch#show vlan id 10
#特權模式下保存配置
Switch#write
6、將端口划出指定的Vlan
#全局模式下進入fa/01端口模式
Switch(config)#interface fastEthernet 0/1
#將fa0/1端口從Vlan 10划出(把fa0/1端口從Vlan10刪除)
Switch(config-if)#no switchport access vlan 10
#全局模式下進入fa/02端口到fa0/10端口模式
Switch(config)#interface range fastEthernet 0/2-10
#把fa0/2端口和fa/10從Vlan 10划出(把fa0/1端口從Vlan10刪除)
Switch(config-if-range)#no switchport access vlan 10
#特權模式下保存配置
Switch#write
7、 設置交換機端口工作模式
標注:思科交換機端口三種工作模式
access 一個access端口只能屬於一個Vlan,也只能轉發這個Vlan數據,主要用於接入終端設備、如PC、服務器、打印服務器等
trunk 一個trunk端口屬於多個Vlan,能轉發多個Vlan數據,主要用於連接其它交換機、以便在線路上承載多個Vlan
dynamic 動態可取模式,主動對端協商,也就是通常的Trunk模式優先。在可以和對端協商成trunk模式時使用trunk模式,不行則改為access模式。
#全局模式下進入fa/01模式
Switch(config)#interface fastEthernet 0/1
#查看交換機支持哪些端口工作模式
Switch(config-if)#switchport mode ?
access Set trunking mode to ACCESS unconditionally
dynamic Set trunking mode to dynamically negotiate access or trunk mode
trunk Set trunking mode to TRUNK unconditionally
#將fa0/1端口設置成Access模式
Switch(config-if)#switchport mode access
#將fa0/1端口設置成Trunk模式
Switch(config-if)#switchport mode dynamic
#將fa0/1端口設置成Trunk模式
Switch(config-if)#switchport mode trunk
#特權模式下查看端口工作模式
Switch#show interfaces fastEthernet 0/1 switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: down
#特權模式下保存配置
Switch#write
8、 雙工模式設置
#全局模式下進入fa0/1端口
Switch(config)#interface fastEthernet 0/1
#自行選擇,full全雙工模式、half半雙工模式、auto自動選擇模式
Switch(config-if)#duplex full
#查看fa0/1端口雙工模式
Switch#show interfaces fastEthernet 0/1
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Full-duplex, 100Mb/s
#保存配置
Switch#write
9、配置Vlan的IP地址及網關
#全局模式下進入指定vlan 10
Switch(config)#interface vlan 10
#配置vlan 10的IP地址及子網掩碼
Switch(config-if)#ip address 192.168.10.1 255.255.255.0
#全局模式下設置交換機所連域的域名test.com
Switch(config)#ip domain-name test.com
#激活端口
Switch(config-if)#no shutdown
#全局模式下設置網關地址
Switch(config)#ip default-gateway 192.168.10.254
#特權模式下查看vlan及接口狀態
Switch#show ip interface brief
#特權模式下查看交換機網關地址
Switch#show running-config
#特權模式下保存配置
Switch#write
10、配置telnet遠程登錄
#全局模式下設置登陸特權加密密碼,telnet遠程登錄需要先設置特權登錄密碼
Switch(config)#enable secret 123456
#全局模式下進入虛擬線程配置模式, 0到4意思是最多同時允許0,1,2,3,4的5個用戶遠程telnet登錄
Switch(config)#line vty 0 4
#設置登錄口令(遠程telnet登錄交換機密碼)
Switch(config-line)#password 654321
#設置遠程telnet需要口令驗證
Switch(config-line)#login
#特權模式下查看telnet配置情況
Switch#show running-config
line vty 0 4
password 654321
login
#特權模式下保存配置
Switch#write
11、恢復交換機出廠設置
#特權模式下執行出廠恢復設置,彈出提示按回車鍵確認
Switch#write erase
#特權模式下重啟交換機,彈出提示按回車鍵確認
Switch#reload
12、使用IPSG綁定IP地址(Port/IP/MAC三者綁定)
#在特權模式下查看Port/IP/MAC綁定情況
Switch# show ip source binding
#在特權模式下查看192.168.10.10 的Port/IP/MAC綁定情況
Switch# show ip source binding | include 192.168.10.10
#特殊模式下查看192.168.10.10 的IP地址對應的物理地址與所屬於VLAN
Switch# show arp | include 192.168.10.10
#特殊模式下查看448a.5b00.12a1 的MAC地址對應的端口
Switch#show mac address-table | include 448a.5b00.12a1
#全局模式下綁定IP地址(Port/IP/MAC三者綁定)
Switch(config)# ip source binding 448a.5b00.12a1 vlan 192.168.10.10 interface GI0/12
13、交換機配置trunk端口 (trunk允許多個Vlan通過,access只允許一個Vlan通過)
標注:三層交換機與二層交換機設置級連,三層交換端口默認dyna auto,dyna auto端口能同步下級交換機端口工作模式trunk,
三層交換機會自動適應成trunk,所以,只要配置二層交換機端口為trunk即可。
#全局模式下進入fa0/24端口進行配置
Switch(config)#interface fastEthernet 0/24
#設置trunk口,允許多個 Vlan通過,一般接到三層交換機上的trunk口
Switch(config-if)#switchport mode trunk
#激活端口
Switch(config-if)#no shutdown
#特權模式下保存配置
Switch#write
#查看fa0/24接口否配置成trunk
Switch#show interfaces fastEthernet 0/24 switchport
Name: Fa0/24
Switchport: Enabled
Administrative Mode: trunk