當前位置:才華齋>計算機>網路技術>

思科交換機配置命令大全

網路技術 閱讀(1.68W)

美國思科公司,憑藉它的IOS,Cisco公司在多協議路由器市場上處於絕對領先的地位。目前,在Internet中,有近80%的路由器來自Cisco。下面給大家介紹思科交換機配置命令大全,一起來了解一下吧!

思科交換機配置命令大全
  思科交換機配置命令大全

 一、基本配置命令

switch> 使用者模式

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 配置交換機埠 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)#duplex 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:

把“”檔案改名為“”: switch: rename flash: flash:

執行 boot: switch: boot

交換機進入是否進入配置的對話,執行 no :

進入特權模式察看 flash 裡的檔案: show flash :

把“”檔案改名為“”: switch: rename flash: flash:

把 “ ” 拷 入 系 統 的 “ running-configure ”: copy flash: 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

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 主機的 ip 必須和交換機埠的地址在同一網路

netmask

gate-way 閘道器地址是交換機埠地址

執行:

telnet

進入 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 module/port] [detail]

在基於 CLI 的交換機上啟用和瀏覽 CDP 資訊:

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

為了檢視 Cisco 鄰接裝置的 CDP 通告資訊:

switch(enable) show cdp neighbors[module/port] [vlan|duplex|capabilities|detail]

5.基於 IOS 的交換機的埠描述:

switch(config-if)# description description-string

基於 CLI 的交換機的埠描述:

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

6.在基於 IOS 的交換機上設定埠速度:

switch(config-if)# speed{10|100|auto}

在基於 CLI 的交換機上設定埠速度:

switch(enable) set port speed moudle/number {10|100|auto}

switch(enable) set port speed moudle/number {4|16|auto}

7.在基於 IOS 的交換機上設定乙太網的鏈路模式:

switch(config-if)# duplex {auto|full|half}

在基於 CLI 的交換機上設定乙太網的鏈路模式:

switch(enable) set port duplex module/number {full|half}

8.在基於 IOS 的交換機上配置靜態 VLAN:

switch# vlan database

switch(vlan)# vlan vlan-num name vla

switch(vlan)# exit

switch# configure teriminal

switch(config)# interface interface module/number

switch(config-if)# switchport mode access

switch(config-if)# switchport access vlan vlan-num

switch(config-if)# end

在基於 CLI 的交換機上配置靜態 VLAN:

switch(enable) set vlan vlan-num [name name]

switch(enable) set vlan vlan-num mod-num/port-list

9. 在基於 IOS 的交換機上配置 VLAN 中繼線:

switch(config)# interface interface mod/port

switch(config-if)# switchport mode trunk

switch(config-if)# switchport trunk encapsulation {isl|dotlq}

switch(config-if)# switchport trunk allowed vlan remove vlan-list

switch(config-if)# switchport trunk allowed vlan add vlan-list

在基於 CLI 的交換機上配置 VLAN 中繼線:

switch(enable) set trunk module/port [on|off|desirable|auto|nonegotiate]

Vlan-range [isl|dotlq|dotl0|lane|negotiate]

10.在基於 IOS 的交換機上配置 VTP 管理域:

switch# vlan database

switch(vlan)# vtp domain domain-name

在基於 CLI 的交換機上配置 VTP 管理域:

switch(enable) set vtp [domain domain-name]

11.在基於 IOS 的交換機上配置 VTP 模式:

switch# vlan database

switch(vlan)# vtp domain domain-name

switch(vlan)# vtp {sever|cilent|transparent}

switch(vlan)# vtp password password

在基於 CLI 的交換機上配置 VTP 模式:

switch(enable) set vtp [domain domain-name] [mode{ sever|cilent|transparent }][password

password]

12. 在基於 IOS 的交換機上配置 VTP 版本:

switch# vlan database

switch(vlan)# vtp v2-mode

在基於 CLI 的交換機上配置 VTP 版本:

switch(enable) set vtp v2 enable

13. 在基於 IOS 的交換機上啟動 VTP 剪裁:

switch# vlan database

switch(vlan)# vtp pruning

在基於 CL I 的交換機上啟動 VTP 剪裁:

switch(enable) set vtp pruning enable

14.在基於 IOS 的交換機上配置以太通道:

switch(config-if)# port group group-number [distribution {source|destination}]

在基於 CLI 的交換機上配置以太通道:

switch(enable) set port channel moudle/port-range mode{on|off|desirable|auto}

15.在基於 IOS 的交換機上調整根路徑成本:

switch(config-if)# spanning-tree [vlan vlan-list] cost cost

在基於 CLI 的交換機上調整根路徑成本:

switch(enable) set spantree portcost moudle/port cost

switch(enable) set spantree portvlancost moudle/port [cost cost][vlan-list]

16.在基於 IOS 的交換機上調整埠 ID:

switch(config-if)# spanning-tree[vlan vlan-list]port-priority port-priority

在基於 CLI 的交換機上調整埠 ID:

switch(enable) set spantree portpri {mldule/port}priority

switch(enable) set spantree portvlanpri {module/port}priority [vlans]

17. 在基於 IOS 的交換機上修改 STP 時鐘:

switch(config)# spanning-tree [vlan vlan-list] hello-time seconds

switch(config)# spanning-tree [vlan vlan-list] forward-time seconds

` switch(config)# spanning-tree [vlan vlan-list] max-age seconds

在基於 CLI 的交換機上修改 STP 時鐘:

switch(enable) set spantree hello interval[vlan]

switch(enable) set spantree fwddelay delay [vlan]

switch(enable) set spantree maxage agingtiame[vlan]

18. 在基於 IOS 的交換機埠上啟用或禁用 Port Fast 特徵:

switch(config-if)#spanning-tree portfast

在基於 CLI 的交換機埠上啟用或禁用 Port Fast 特徵:

switch(enable) set spantree portfast {module/port}{enable|disable}

19. 在基於 IOS 的交換機埠上啟用或禁用 UplinkFast 特徵:

switch(config)# spanning-tree uplinkfast [max-update-rate pkts-per-second]

在基於 CLI 的交換機埠上啟用或禁用 UplinkFast 特徵:

switch(enable) set spantree uplinkfast {enable|disable}[rate update-rate] [all-protocols off|on]

20. 為了將交換機配置成一個叢集的命令交換機,首先要給管理介面分配一個 IP 地址,然後使

用下列命令: switch(config)# cluster enable cluster-name

21. 為了從一條中繼鏈路上刪除 VLAN,可使用下列命令:

switch(enable) clear trunk module/port vlan-range

22. 用 show vtp domain 顯示管理域的 VTP 引數.

23. 用 show vtp statistics 顯示管理域的 VTP 引數.

24. 在 Catalyst 交換機上定義 TrBRF 的命令如下:

switch(enable) set vlan vlan-name [name name] type trbrf bridge bridge-num[stp {ieee|ibm}]

25. 在 Catalyst 交換機上定義 TrCRF 的命令如下:

switch (enable) set vlan vlan-num [name name] type trcrf

{ring hex-ring-num|decring decimal-ring-num} parent vlan-num

26. 在建立好 TrBRF VLAN 之後,就可以給它分配交換機埠.對於乙太網交換,可以採用如

下命令給 VLAN 分配埠:

switch(enable) set vlan vlan-num mod-num/port-num

27. 命令 show spantree 顯示一個交換機埠的 STP 狀態.

28. 配置一個 ELAN 的 LES 和 BUS,可以使用下列命令:

ATM (config)# interface atm nt multioint

ATM(config-subif)# lane serber-bus ethernet elan-name

29. 配置 LECS:

ATM(config)# lane database database-name

ATM(lane-config-databade)# name elan1-name server-atm-address les1-nsap-address

ATM(lane-config-databade)# name elan2-name server-atm-address les2-nsap-address

ATM(lane-config-databade)# name …

30. 建立完資料庫後,必須在主介面上啟動 LECS.命令如下:

ATM(config)# interface atm number

ATM(config-if)# lane config database database-name

ATM(config-if)# lane config auto-config-atm-address

31. 將每個 LEC 配置到一個不同的 ATM 子介面上.命令如下:

ATM(config)# interface atm nt multipoint

ATM(config)# lane client ethernet vlan-num elan-num

32. 用 show lane server 顯示 LES 的狀態.

33. 用 show lane bus 顯示 bus 的狀態.

34. 用 show lane database 顯示 LECS 資料庫可內容.

35. 用 show lane client 顯示 LEC 的狀態.

36. 用 show module 顯示已安裝的模組列表.

37. 用物理介面建立與 VLAN 的連線:

router# configure terminal

router(config)# interface media module/port

router(config-if)# description description-string

router(config-if)# ip address ip-addr subnet-mask

router(config-if)# no shutdown

38. 用中繼鏈路來建立與 VLAN 的連線:

router(config)# interface module/nterface

router(config-ig)# encapsulation[isl|dotlq] vlan-number

router(config-if)# ip address ip-address subnet-mask

39. 用 LANE 來建立與 VLAN 的連線:

router(config)# interface atm module/port

router(config-if)# no ip address

router(config-if)# atm pvc 1 0 5 qsaal

router(config-if)# atm pvc 2 0 16 ilni

router(config-if)# interface atm module/nterface multipoint

router(config-if)# ip address ip-address subnet-mask

router(config-if)# lane client ethernet elan-num

router(config-if)# interface atm module/nterface multipoint

router(config-if)# ip address ip-address subnet-name

router(config-if)# lane client ethernet elan-name

router(config-if)# …

40. 為了在路由處理器上進行動態路由配置,可以用下列 IOS 命令來進行:

router(config)# ip routing

router(config)# router ip-routing-protocol

router(config-router)# network ip-network-number

router(config-router)# network ip-network-number

41. 配置預設路由:

switch(enable) set ip route default gateway

42. 為一個路由處理器分配 VLANID,可在介面模式下使用下列命令:

router(config)# interface interface number

router(config-if)# mls rp vlan-id vlan-id-num

43. 在路由處理器啟用 MLSP:

router(config)# mls rp ip

44. 為了把一個外接的路由處理器介面和交換機安置在同一個 VTP 域中:

router(config)# interface interface number

router(config-if)# mls rp vtp-domain domain-name

45. 檢視指定的 VTP 域的資訊:

router# show mls rp vtp-domain vtp domain name

46. 要確定 RSM 或路由器上的管理介面,可以在介面模式下輸入下列命令:

router(config-if)#mls rp management-interface

47. 要檢驗 MLS-RP 的配置情況:

router# show mls rp

48. 檢驗特定介面上的 MLS 配置:

router# show mls rp interface interface number

49. 為了在 MLS-SE 上設定流掩碼而又不想在任一個路由處理器介面上設定訪問列表:

set mls flow [destination|destination-source|full]

50. 為使 MLS 和輸入訪問列表可以相容,可以在全域性模式下使用下列命令:

router(config)# mls rp ip input-acl

51. 當某個交換機的第 3 層交換失效時,可在交換機的特權模式下輸入下列命令:

switch(enable) set mls enable

52. 若想改變老化時間的值,可在特權模式下輸入以下命令:

switch(enable) set mls agingtime agingtime

53. 設定快速老化:

switch(enable) set mls agingtime fast fastagingtime pkt_threshold

54. 確定那些 MLS-RP 和 MLS-SE 參與了 MLS,可先顯示交換機引用列表中的內容再確定:

switch(enable) show mls include

55. 顯示 MLS 快取記憶體記錄:

switch(enable) show mls entry

56. 用命令 show in arp 顯示 ARP 快取記憶體區的內容。

57. 要把路由器配置為 HSRP 備份組的成員,可以在介面配置模式下使用下面的命令:

router(config-if)# standby group-number ip ip-address

58. 為了使一個路由器重新恢復轉發路由器的'角色,在介面配置模式下:

router(config-if)# standy group-number preempt

59. 訪問時間和保持時間引數是可配置的:

router(config-if)# standy group-number timers hellotime holdtime

60. 配置 HSRP 跟蹤:

router(config-if)# standy group-number track type-number interface-priority

61. 要顯示 HSRP 路由器的狀態:

router# show standby type-number group brief

62. 用命令 show ip igmp 確定當選的查詢器。

63. 啟動 IP 組播路由選擇:

router(config)# ip muticast-routing

64. 啟動介面上的 PIM:

dalllasr1>(config-if)# ip pim {dense-mode|sparse-mode|sparse-dense-mode}

65. 啟動稀疏-稠密模式下的 PIM:

router# ip multicast-routing

router# interface type number

router# ip pim sparse-dense-mode

66. 核實 PIM 的配置:

dallasr1># show ip pim interface[type number] [count]

67. 顯示 PIM 鄰居:

dallasr1># show ip neighbor type number

68. 為了配置 RP 的地址,命令如下:

dallasr1># ip pim rp-address ip-address [group-access-list-number][override]

69. 選擇一個預設的 RP:

dallasr1># ip pim rp-address

通告 RP 和它所服務的組範圍:

dallasr1># ip pim send-rp-announce type number scope ttl group-list access-list-number

為管理範圍組通告 RP 的地址:

dallasr1># ip pim send-rp-announce ethernet0 scope 16 group-list1

dallasr1># access-list 1 permit

設定一個 RP 映像代理:

dallasr1># ip pim send-rp-discovery scope ttl

核實組到 RP 的映像:

dallasr1># show ip pim rp mapping

dallasr1># show ip pim rp [group-name|group-address] [mapping]

70. 在路由器介面上用命令 ip multicast ttl-threshold ttl-value 設定 TTL 閥值:

dallasr1>(config-if)# ip multicast ttl-threshold ttl-value

71. 用 show ip pim neighbor 顯示 PIM 鄰居表。

72. 顯示組播通訊路由表中的各條記錄:

dallasr1>show ip mroute [group-name|group-address][scoure][summary][count][active kbps]

73. 要記錄一個路由器接受和傳送的全部 IP 組播包:

dallasr1> #debug ip mpacket [detail] [access-list][group]

74. 要在 CISCO 路由器上配置 CGMP:

dallasr1>(config-if)# ip cgmp

75.配置一個組播路由器,使之加入某一個特定的組播組:

dallasr1>(config-if)# ip igmp join-group group-address

76. 關閉 CGMP:

dallasr1>(config-if)# no ip cgmp

77. 啟動交換機上的 CGMP:

dallasr1>(enable) set cgmp enable

78. 核實 Catalyst 交換機上 CGMP 的配置情況:

catalystla1>(enable) show config

set prompt catalystla1>

set interface sc0

set cgmp enable

79. CGMP 離開的設定:

Dallas_SW(enable) set cgmp leave

80. 在 Cisco 裝置上修改控制埠密碼:

R1(config)# line console 0

R1(config-line)# login

R1(config-line)# password Lisbon

R1(config)# enable password Lilbao

R1(config)# login local

R1(config)# username student password cisco

81. 在 Cisco 裝置上設定控制檯及 vty 埠的會話超時:

R1(config)# line console 0

R1(config-line)# exec-timeout 5 10

R1(config)# line vty 0 4

R1(config-line)# exec-timeout 5 2

82. 在 Cisco 裝置上設定特權級:

R1(config)# privilege configure level 3 username

R1(config)# privilege configure level 3 copy run start

R1(config)# privilege configure level 3 ping

R1(config)# privilege configure level 3 show run

R1(config)# enable secret level 3 cisco

83. 使用命令 privilege 可定義在該特權級下使用的命令:

router(config)# privilege mode level level command

84. 設定使用者特權級:

router(config)# enable secret level 3 dallas

router(config)# enable secret san-fran

router(config)# username student password cisco

85. 標誌設定與顯示:

R1(config)# banner motd ‘unauthorized access will be prosecuted!’

86. 設定 vty 訪問:

R1(config)# access-list 1 permit

R1(config)# line vty 0 4

R1(config)# access-class 1 in

87. 配置 HTTP 訪問:

Router3(config)# access-list 1 permit

Router3(config)# ip http sever

Router3(config)# ip http access-class 1

Router3(config)# ip http authentication local

Router3(config)# username student password cisco

88. 要啟用 HTTP 訪問,請鍵入以下命令:

switch(config)# ip http sever

89. 在基於 set 命令的交換機上用 setCL1 啟動和核實埠安全:

switch(enable) set port security mod_num/port_num…enable mac address

switch(enable) show port mod_num/port_num

在基於 CiscoIOS 命令的交換機上啟動和核實埠安全:

switch(config-if)# port secure [mac-mac-count maximum-MAC-count]

switch# show mac-address-table security [type module/port]

90. 用命令 access-list 在標準通訊量過濾表中建立一條記錄:

Router(config)# access-list access-list-number {permit|deny} source-address [source-address]

91. 用命令 access-list 在擴充套件通訊量過濾表中建立一條記錄:

Router(config)# access-list access-list-number {permit|deny{protocol|protocol-keyword}}{source

source-wildcard|any}{destination destination-wildcard|any}[protocol-specific options][log]

92. 對於帶內路由更新,配置路由更新的最基本的命令格式是:

R1(config-router)#distribute-list access-list-number|name in [type number]

93. 對於帶外路由更新,配置路由更新的最基本的命令格式是:

R1(config-router)#distribute-list access-list-number|name out [interface-name] routing-process|

autonomous-system-number

94. set snmp 命令選項:

set snmp community {read-only|ready-write|read-write-all}[community_string]

95. set snmp trap 命令格式如下:

set snmp trap {enable|disable}

[all|moudle|classis|bridge|repeater| auth|vtp|ippermit|vmps|config|entity|stpx]

set snmp trap rvcr_addr rcvr_community

96. 啟用 SNMP chassis 陷阱:

Console>(enable) set snmp trap enable chassis

97. 啟用所有 SNMP chassis 陷阱:

Console>(enable) set snmp trap enable

98. 禁用 SNMP chassis 陷阱:

Console>(enable) set snmp trap disable chassis

99. 給 SNMP 陷阱接收表加一條記錄:

Console>(enable) set snmp trap public

100. show snmp 輸出結果。

101. 命令 set snmp rmon enable 的輸出結果。

102. 顯示 SPAN 資訊:

Consile> show spanCISCO 交換機配置命令大全