跳至主要內容

Cisco IOS常用指令

記錄一些設定或華佗杯用過的指令

Putty 用 Serial 連 COM
===================================================================
switch>
switch>enable                                           ##啟用
switch#
switch(config)#hostname 名稱             ##設置設備名稱
switch(config)#enable secret 密碼       ##進入enable啟用密碼(secret為單向加密)
switch#show running-config                 ##顯示命令配置情況

Telnet 連線
===================================================================
switch#configure terminal
switch(config)#line console 0             ##設定console連線 只有一個
switch(config)#line vty 0 4               ##設定vty連線 範圍0~4  即同時可以五個登入  若沒設定則拒絕登入
switch(config-line)#password 密碼     ##設定該連線密碼(password為未加密 存於組態檔 = show running-config)
switch(config-line)#login          ##啟用密碼設置  頭處加上no取消

switch(config-line)#login local          ##啟用帳號密碼設置  頭處加上no取消
switch(config-line)#username 帳號 password 密碼  ##設定該連線帳號與密碼(username無法tab)
switch(config-line)#exit

switch(config)#service password-encryption ##組態檔的所有明文密碼加密 包括日後新增的(忘了就麻煩囉)頭處加上no取消

SSH 連線
===================================================================
1
前置作業,設定hostname和domain-name
switch(config)# hostname < hostname >
switch(config)# ip domain-name < domainname >
2
產生ssh用的金鑰
switch(config)# crypto key generate rsa
ps:請設定768bit以符合ssh ver2最小需求
啟用認證
switch(config)# aaa new-model
設定帳密
switch(config)# username < username > password < password >
3
設定vty使用ssh
switch(config)# line vty 0 4
switch(config-line)# transport input SSH

ps:
其他ssh相關設定
switch(config)# ip ssh time-out < 1-120 >
switch(config)# ip ssh authentication-retries < 1-5 >
switch#show ip ssh

Vlan 設置
===================================================================
switch#vlan database
switch(vlan)#vlan 編號 name 命名               ##新增vlan
switch(vlan)#exit
switch(config)#interface vlan 編號                               ##進入vlan介面
switch(config-if)# ip address IP位置 遮罩                              ##為該vlan設置IP
switch(config-if)#exit
switch#show vlan brief                ##顯示目前vlan配置內容
switch#configure terminal                 ##進入全域配置模式
switch(config)#interface f0/編號              ##進入某interface介面
switch(config)#interface range f0/編號-編號         ##範圍設定介面
switch(config-if)#switchport mode access或trunk  ##設定該vlan模式
switch(config-if)#switchport access vlan 編號       ##設定該vlan歸屬
switch(config-if)#no shutdown                 ##啟動該連接阜
switch(config-if)#exit

description 該介面描述 show run可見

VTP 設置
===================================================================
switch(config)#vtp domain domain_name        ##設定vtp domain
switch(config)#vtp password domain_name        ##設定vtp 密碼
switch(config)#vtp mode client            ##設定vtp mode為客戶端 學習vlan

STP 設置
===================================================================
SwitchC(config)#spanning-tree vlan 20 root primary        ##設定vlan 20為主要根橋接器 secondary次要
SwitchC(config)#spanning-tree mode rapid-pvst        ##設定RSTP 加快收斂速度
SwitchC(config-if-range)#spanning-tree portfast        ##若連接埠為終端設備 可設為portfast 無須STP溝通

CDP 設置
===================================================================
CustRT(config)#cdp run        ##啟動cdp
CustRT#show cdp neighbors detail        ##顯示鄰近設備詳細資料

OSPF
===================================================================
CustRT(config)#router ospf PROCESS_ID        ##啟用OSPF
CustRT(config-router)#router-id 10.0.0.4
CustRT(config-router)network IP_ADDR WILDMASK area AREA_NUM

EIGRP 設置
===================================================================
RouterB(config)#router eigrp AS_num        ##設定AS編號
RouterB(config-router)#no auto-summary        ##設定不連續網路 classless
RouterB(config-router)#network network_domain [wildmask]         ##預設classful calssless加上wildmask
RouterB(config-router)#variance 變異值        ##設定非對等附載平衡

DHCP 設置
===================================================================
switch#show ip interface brief                                   ##顯示各連接阜狀態
switch(config-if)#ip dhcp pool 名稱                                ##設定dhcp名稱
switch(dhcp-config)#network 192.168.100.0 255.255.255.0  ##設置要分配的區段
switch(dhcp-config)#default-router 192.168.100.1            ##自動取得Gateway
switch(dhcp-config)#dns-server 192.168.100.1            ##自動取得DNS server
switch(config)#ip dhcp excluded-address 頭IP位置 尾IP位置        ##排除分配的位置  避免分配到Gateway 可輸入區段
switch#write                      ##寫入設定檔
switch#show ip dhcp binding                   ##顯示dhcp分配狀況
switch#(config-if)ip helper-address IP_ADDR        ##轉送UTP服務封包(Ex. DHCP)

ACL 設置
===================================================================
RouterB(config)#ip access-list extend ACL_NUM
RouterB(config)#PRI_NUM deny IP_NET WILDMASK        ##設定ACL permit or deny
RouterB(config-subif)#ip access-group ACL_NUM { in | out }        ##ACL套用連接埠

NAT 設置
===================================================================
HQRouter(config)#interface fastEthernet 0/0
HQRouter(config-if)#ip nat { outside | inside }        ##設定內外部介面(重要)
HQRouter(config)#ip nat inside source static tcp LOCAL_ADDR PORT_NUM GOBAL_ADDR PORT_NUM    ##設定靜態nat(一對一)
HQRouter(config)#ip nat pool POOL_NAME START_IP END_IP netmask NETMASK        ##設定nat pool
HQRouter(config)#ip nat inside source list ACL_NUM pool POOL_NAME    ##設定動態NAT(多對多)
HQRouter(config)#ip nat inside source list ACL_NUM { interface INFAC_NAME | pool POOL_NAME } overload    ##設定PAT(一對多)

PPP 設置
===================================================================
Router(config-if)#encapsulation ppp        ##設定封裝方式為PPP
RouterA(config-if)#ppp authentication chap    ##使用ppp認證

Frame-relay 設置
===================================================================
Router(config-if)#encapsulation frame-relay        ##設定封裝方式為frame-relay
Router(config-if)#frame-relay map ip DEST_IP DLCI_NUM [broadcast [cisco|ietf]]

Port-Channel 設置
===================================================================
Switch(config)#interface range fa0/1–2
Switch(config-if-range)#channel-group 1 mode active    ##active = Enable LACP unconditionally
Switch(config-if-range)#switchport trunk encapsulation dot1q
Switch(config-if-range)#switchport mode trunk
Switch(config-if-range)#switchport nonegotiate        ##不送DTP
Switch(config)#interface port-channel 1
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport nonegotiate        ##不送DTP

Switch#show etherchannel summary            ##顯示如下代表完成
1      Po1(SU)           LACP   Fa0/1(P) Fa0/2(P)

時間設定
===================================================================
Switch(config)#ntp server NTP_Server_IP         ##利用NTP Server做校時
Switch(config)#clock timezone TW 8
Switch#clock set hh:mm:ss DD nameofMM YYYY    ##設定時間

Port Mirror
===================================================================
monitor session 2 source interface 來源連接埠
monitor session 1 destination interface 目的連接埠
目的連接埠將只可接收來源mirror 不可發送

Achive 備份config
===================================================================

Switch(config)#archive         ##進入archive模式
Switch(config-archive)#path tftp://192.168.1.1/$h.$t         ##儲存路徑 $h hostname $t time
Switch(config-archive)#write-memory         ##write時會觸發備份
Switch(config-archive)#time-period 1440        ##定期備份  單位分鐘

其餘設定
===================================================================
HQRouter#copy running-config tftp:        ##備份設定檔至tftp server
RouterB(config-if)#encapsulation        ##設定封裝方式
Switch(config-if)#switchport port-security        ##啟用port-security 要把port mode換成非dynamic
Switch(config-if)#switchport port-security mac-address sticky        ##動態記錄port對應mac
Switch(config-if)#switchport port-security violation {protect|restrict|shutdown}    #只限定紀錄 | 不允許且記錄 | 關閉port
Switch(config)#ip default-gateway IP_ADDR        ##預設閘道
Switch(config-line)#exec-timeout Minutes        ##設定在登入後幾分鐘後自動登出
Switch(config)#no ip domain-lookup            ##禁用Domain Search

Switch#clear ssh hosts    ##清除know_hosts

Switch(config)#boot system FILENAME        ##指定開機用的韌體 若有多個用 ;  區隔

強置中斷動作 Ctrl + Shift + 6
===================================================================
wildmask 算法

條件ip-address     4組 32個bits => xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx
旗標wildcard-mask  4組 32個bits => yyyyyyyy.yyyyyyyy.yyyyyyyy.yyyyyyyy
*** 被檢查的IP-Address 4組 32個bits  (y=0,表示要與x相同 / y=1,表示不需要與x相同) 所有符合條件 ***

===================================================================
http://www.cisco.com/c/en/us/support/docs/routers/10000-series-routers/50421-config-register-use.html
鮑率計算(bit number是二進位的bit位置 HEX是轉十六進位的值)

一般來說會有這幾個值
Boots the first system image in onboard Flash memory (EPROM).
Break disabled
Console line speed參考下面

分類:Cisco

1 則留言

  1. Hi there I am so excited I found your web site, I really found
    you by error, while I was searching on Digg for something else, Anyways I am here
    now and would just like to say thanks a lot for a fantastic post and a all round exciting blog (I also love the theme/design), I don’t have time to browse it all at the minute but I have book-marked it and also added your RSS
    feeds, so when I have time I will be back to read a lot more, Please
    do keep up the excellent work.

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料

由 Compete Themes 設計的 Author 佈景主題