CISCO交換機有什麼基本配置命令呢?下面yjbys小編為大家分享最新思科交換機配置命令大全,希望對大家學習思科認證有所幫助!
CISCO交換機基本配置:Console埠連線
使用者模式hostname# ;
特權模式hostname(config)# ;
全域性配置模式hostname(config-if)# ;
交換機口令設定:
switch>enable ;進入特權模式
switch#config terminal ;進入全域性配置模式
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#exit ;返回命令
交換機VLAN建立,刪除,埠屬性的設定,配置trunk埠,將某埠加入vlan中,配置VTP:
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)#duplex ? 檢視duplex的子命令
switch(config)#duplex full 設定該埠為全雙工(auto/half)
switch(config)#description TO_PC1 這是該埠描述為TO_PC1
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 ;設定IP地址
switch(config)#ip default-gateway ;設定預設閘道器
switch(config)#ip domain-name 設定域名
switch(config)#ip name-server 設定域名伺服器
switch(config)#mac-address-table? 檢視mac-address-table的子命令
switch(config)#mac-address-table aging-time 100 設定超時時間為100ms
switch(config)#mac-address-table permanent f0/3 加入永久地址在f0/3埠
switch(config)#mac-address-table restricted static f0/6 f0/7 加入靜態地址目標埠f0/6源埠f0/7
switch(config)#end
switch#show mac-address-table 檢視整個MAC地址表
switch#clear mac-address-table restricted static 清除限制性靜態地址
交換機顯示命令:
switch#write ;儲存配置資訊
switch#show vtp ;檢視vtp配置資訊
switch#show run ;檢視當前配置資訊
switch#show vlan ;檢視vlan配置資訊
switch#show interface ;檢視埠資訊
switch#show int f0/0 ;檢視指定埠資訊
switch#show int f0/0 status;檢視指定埠狀態
switch#dir flash: ;檢視快閃記憶體
(1)模式轉換命令
使用者模式----特權模式,使用命令"enable"
特權模式----全域性配置模式,使用命令"config t"
全域性配置模式----介面模式,使用命令"interface+介面型別+介面號"
全域性配置模式----線控模式,使用命令"line+介面型別+介面號"
注:
使用者模式:檢視初始化的資訊.
特權模式:檢視所有資訊、除錯、儲存配置資訊
全域性模式:配置所有資訊、針對整個路由器或交換機的所有介面
介面模式:針對某一個介面的配置
線控模式:對路由器進行控制的.介面配置
(2)配置命令
show running config 顯示所有的配置
show versin 顯示版本號和暫存器值
shut down 關閉介面
no shutdown 開啟介面
ip add +ip地址 配置IP地址
secondary+IP地址 為介面配置第二個IP地址
show interface+介面型別+介面號 檢視介面管理性
show controllers interface 檢視介面是否有DCE電纜
show history 檢視歷史記錄
show terminal 檢視終端記錄大小
hostname+主機名 配置路由器或交換機的標識
config memory 修改儲存在NVRAM中的啟動配置
exec timeout 0 0 設定控制檯會話超時為0
service password-encryptin 手工加密所有密碼
enable password +密碼 配置明文密碼
ena sec +密碼 配置密文密碼
line vty 0 4/15 進入telnet介面
password +密碼 配置telnet密碼
line aux 0 進入AUX介面
password +密碼 配置密碼
line con 0 進入CON介面
password +密碼 配置密碼
bandwidth+數字 配置頻寬
no ip address 刪除已配置的IP地址
show startup config 檢視NVRAM中的配置資訊
copy run-config atartup config 儲存資訊到NVRAM
write 儲存資訊到NVRAM
erase startup-config 清除NVRAM中的配置資訊
show ip interface brief 檢視介面的謫要資訊
banner motd # +資訊 + # 配置路由器或交換機的描素資訊
description+資訊 配置介面聽描素資訊
vlan database 進入VLAN資料庫模式
vlan +vlan號+ 名稱 建立VLAN
switchport access vlan +vlan號 為VLAN為配介面
interface vlan +vlan號 進入VLAN介面模式
ip add +ip地址 為VLAN配置管理IP地址
vtp+service/tracsparent/client 配置SW的VTP工作模式
vtp +domain+域名 配置SW的VTP域名
vtp +password +密碼 配置SW的密碼
switchport mode trunk 啟用中繼
no vlan +vlan號 刪除VLAN
show spamming-tree vlan +vlan號 檢視VLA怕生成樹議
2. 路由器配置命令
ip route+非直連網段+子網掩碼+下一跳地址 配置靜態/預設路由
show ip route 檢視路由表
show protocols 顯示出所有的被動路由協議和介面上哪些協議被設定
show ip protocols 顯示了被配置在路由器上的路由選擇協議,同時給出了在路由選擇協議中使用的定時器等資訊
router rip 啟用RIP協議
network +直連網段 釋出直連網段
interface lookback 0 啟用邏輯介面
passive-interface +介面型別+介面號 配置介面為被動模式
debug ip +協議 動態檢視路由更新資訊
undebug all 關閉所有DEBUG資訊
router eigrp +as號 啟用EIGRP路由協議
network +網段+子網掩碼 釋出直連網段
show ip eigrp neighbors 檢視鄰居表
show ip eigrp topology 檢視拓撲表
show ip eigrp traffic 檢視傳送包數量
router ospf +process-ID 啟用OSPF協議
network+直連網段+area+區域號 釋出直連網段
show ip ospf 顯示OSPF的程序號和ROUTER-ID
encapsulation+封裝格式 更改封裝格式
no ip admain-lookup 關閉路由器的域名查詢
ip routing 在三層交換機上啟用路由功能
show user 檢視SW的線上使用者
clear line +線路號 清除線路
3. 三層交換機配置命令
配置一組二層埠
configure terminal 進入配置狀態
nterface range {port-range} 進入組配置狀態
配置三層埠
configure terminal 進入配置狀態
interface {{fastethernet | gigabitethernet} interface-id} | {vlan vlan-id} | {port-
channel port-channel-number} 進入埠配置狀態
no switchport 把物理埠變成三層口
ip address ip_address subnet_mask 配置IP地址和掩碼
no shutdown 啟用埠
例:
Switch(config)# interface gigabitethernet0/2
Switch(config-if)# no switchport
Switch(config-if)# ip address
Switch(config-if)# no shutdown
配置VLAN
configure terminal 進入配置狀態
vlan vlan-id 輸入一個VLAN號, 然後進入vlan配態,可以輸入一個新的VLAN號或舊的來進行修改
。
name vlan-name 可選)輸入一個VLAN名,如果沒有配置VLAN名,預設的名字是VLAN號前面用0填滿
的4位數,如VLAN0004是VLAN4的預設名字
mtu mtu-size (可選) 改變MTU大小
例
Switch# configure terminal
Switch(config)# vlan 20
Switch(config-vlan)# name test20
Switch(config-vlan)# end
或
Switch# vlan database
Switch(vlan)# vlan 20 name test20
Switch(vlan)# exit
將埠分配給一個VLAN
configure terminal 進入配置狀態
interface interface-id 進入要分配的埠
switchport mode access 定義二層口
switchport access vlan vlan-id 把埠分配給某一VLAN
例
Switch# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)# interface fastethernet0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 2
Switch(config-if)# end
Switch#
配置VLAN trunk
configure terminal 進入配置狀態
interface interface-Id 進入埠配置狀態
switchport trunk encapsulation {isl | dot1q | negotiate}配置trunk封裝ISL 或 802.1Q 或自動協商