CISCO 設備管理
以前用不到,現在偶爾用到。所以,一定要寫紀錄
目前使用設備(型號:WS-C2960X-48TS-LL、韌體:C2960X-UNIVERSALK9-M)
cisco switch 建立帳號
1. 登入 switch
2. 進入設定介面 configure terminal
3. 建立帳號 username [帳號] secret [0 5 8 9] [密碼]
4. 設定帳號權限 username [帳號] privilege 0-15 (15為admin)
5. 寫入flash rom:copy running-config startup-config
註:0 5 8 9 (0 UNENCRYPTED、5 MD5、8 PBKDF2、9 SCRYPT)
1. 登入 switch
2. 進入設定介面 configure terminal
3. 建立帳號 username [帳號] password [0 6 7] [密碼] <= 明碼(但看來是一串數字 = =)
4. 設定帳號權限 username [帳號] privilege 0-15 (15為admin)
5. 寫入flash rom:copy running-config startup-config
註:0 6 7(0 UNENCRYPTED、6 ENCRYPTED、7 HIDDEN)
註1:privilege level 1 ==> read only,privilege level 15 ==> root
註2:3、4 可以併成一行 username [帳號] privilege 15 password [密碼]
註3:3、4 可以改成一行 username [帳號] privilege 15 secret [密碼] <= 加密密碼
----------------------------------------------------------------------------------------------------------
cisco switch 刪除帳號
1. 登入 switch
2. 進入設定介面 configure terminal
3. no username [帳號]
出現確認刪除說明,enter 完成
4. 寫入flash rom:copy running-config startup-config
----------------------------------------------------------------------------------------------------------
cisco switch 修改密碼
1. 登入 switch
2. 進入設定介面 configure terminal
3. 變更帳號:username [帳號] password [密碼]
4. 寫入flash rom:copy running-config startup-config
註:修改使用者密碼必需先確認使用者密碼建立方式,是使用 password 建立或是使用 secret 建立,兩種方式只能二選一
1. 登入 switch
2. 進入設定介面 configure terminal
3. 變更密碼:username [帳號] secret [密碼]
4. 寫入flash rom:write memory
cisco switch 設定 link-flap 次數
link-flap
是 cisco switch 的安全機制,它會限制每一個連接埠連接的次數,預設為 10 秒 5 次,不過,這個限制會造成 MAC
網卡進入休眠再啟動時發生 err-disabled,造成該 port 中斷,MAC 使用者無法連線的問題,改為 10 秒 10
次,就不會發生這樣的問題了
查看 link-flap 次數
show errdisable flap-values
預設值為 10秒 5次
修改 link-flap 次數
config terminal
errdisable flap-setting cause link-flap max-flaps 10 time 10
改為 10秒 10次
參考資料:官方說明
http://www.cisco.com/c/en/us/support/docs/lan-switching/spanning-tree-protocol/69980-errdisable-recovery.html
cisco switch 設定備份(手動備份)
1. 架設 TFTP server(可以使用tftpd32這類軟體於本機中架設)
2. 登入 switch(進入特權模式#)
3. copy startup-config tftp 進入互動模式
要求打入 TFTP 主機
要求打入 備份檔名(可用預設名稱)
4. TFTP server 收到檔案
註:本機防火牆需開放 UDP 69
cisco switch 設定備份(自動備份)
Gavin 大使用的是 FTP 進行備份,towns 使用的是 TFTP 備份,不過設定方式類似
1. 啟動 TFTP server
註:每個環境的 TFTP server 不同,記得確認是否正常啟動
2. 建立自動備份
2.1. 進入特權模式
>enable
#
2.2. 進入 config 模式
#configure terminal
(config)#
2.3. 進入 archive 模式
(config)#archive
(config-archive)#
2.4. 打入 TFTP 路徑及檔案名稱
(config-archive)#path tftp://1.2.3.4/$h-$t
$h 主機名稱
$t 時間 MM-DD-hh-mm-ss-num <== 可以不打,使用預設值
2.5. 設定備分頻率
(config-archive)#time-period 1440
註:1440分鐘
2.6. 存檔
(config-archive)#end
#
2.7. 手動測試
#archive config
archive
log config
logging enable
notify syslog contenttype plaintext
hidekeys
path tftp://1.2.3.4/$h-$t
time-period 1440
參考資料:Gavin 大的文章 -- 詳細指令及說明
https://gavint.tian.yam.com/posts/161812320
VLAN 管理
建立Vlan
1. 進入特權模式
2. configure terminal 進入設定模式
3. vlan 170
4. end
5. show vlan 確認是否新增
刪除Vlan
1. 進入特權模式
2. configure terminal 進入設定模式
3. no vlan 170
4. end
5. show vlan 確認是否刪除
interface 加入指定 VLAN
1. 進入特權模式
2. configure terminal => 進入設定模式
3. interface GigabitEthernet 0/35 => 進入0/35 GigabitEthernet
4. switchport access vlan 123 => 將 0/35 port 加入 vlan 123
5. switchport mode access => 設定 port 為 access
5. end 退出設定模式
6. show vlan 確認是否加入
註1:第 3 點的 GigabitEthernet 0/35 是依設備的,因為 switch 上有可能有多種 interface,應依需求選擇
註2:更換 VLAN 只需要修改第 4 點,就可以轉換了
註3:必需要將 port 設定為 access 否則會不通
--------------------------------------------------------------------------------
指定範圍 port 加入特定 Vlan
3. interface range gigabitEthernet 0/15 - 20
ACL 加入指定的 interface VLAN
1. 進入特權模式
2. configure terminal => 進入設定模式
3. interface vlan 100 => 進入 vlan 100 介面
4. ip address [IP] [netmask]
5. ip access-group [ACL ID]
6. exit
7. sh run <= 查看 interface vlan 100 是否建立了
常用指令語法
show run <== 檢查目前系統設定狀能
show interfaces status <== 檢查每一個實體介面目前狀態
show clock <== 查看目前系統時間
show interfaces description <== 列出個介面完整的描述
router 更新韌體(CISCO 1921)
更新流程
1. 取得韌體
到google 打入設備型號 韌體就可以到到官方網頁取得打星號的韌體(IOS Software)
網址:
2. 登入設備確認目前韌體版號
login router amd "show version"
3. 確認 flash rom 中的韌體版號
dir
4. 透過 TFTP 將穩定版本的韌體送到 router 的 flash 中
copy tftp://**.**.**.**/c1900-universalk9-mz.SPA.155-3.M7.bin flash:
5. 到特權模式,將開機選為 c1900-universalk9-mz.SPA.155-3.M7.bin
router(config)#boot system flash:c1900-universalk9-mz.SPA.155-3.M7.bin
6. 確認設定
sh run
註:在CISCO router上,這個方式應該是通用的
技術指導:steve
確認專線是否正常運作(CISCO 1921)
通常使用 CISCO 1921 這個設備,就是為了使用傳統專線(V.35)轉 RJ45 使用,多了設備就要多個監控,說明關於 interface 監控指令
檢查 ip 層 Serial 0/0/0 介面是否正常
show ip interface Serial 0/0/0
Serial0/0/0 is up, line protocol is up <== 回應的第一行
這一行的重點就是 1. 介面是否正常、2. 協定是否正常
如果發生 protocol is down 這表示協定異常,通常表示 A 端與 B 端線路不通,這個情形必需通知 IDC 業者處理,towns 也發生過 protocol 一下 up 一下 down 的情形,這表示線路不穩,也得通知 IDC 業者處理
如果發生 Serial0/0/0 is down,查看 1. running-config 中 Serial0/0/0 是否下了 shutdown、2. 線路是否被拔除、3. 設備異常
設定 vty(Virtual terminal)
vty 就是指虛擬通道,一般來說在設定好 router 後,就要設定 vty,不然就無法使用遠端登入了,這個虛擬通道有 0-1370 個
產生 vty,並同時使用 telnet 及 ssh,並建立 telnet 密碼
1. 進入特權模式
2. configure terminal 進入設定模式
3. (config)#line vty 0 4
4. (config-line)#transport input telnet ssh
5. (config-line)#password 7 ********
6. ^z
7. copy running-config startuup-config
刪除 telnet 登入及登入密碼
1. 進入特權模式
2. configure terminal 進入設定模式
3. (config)#line vty 0 4
4. (config-line)#transport input ssh
5. (config-line)#no password
6. ^z
7. copy running-config startuup-config
參考資料:
steve 大口述
小必大文章 -- [筆記]Cisco基本指令-啟用SSH
https://david50.pixnet.net/blog/post/45217866-%5B%E7%AD%86%E8%A8%98%5Dcisco%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4-%E5%95%9F%E7%94%A8ssh
重設 cisco switch
1. erase startup-config => reload
2. write erase => reload
3. 長按 mode 直到 console 出現一串字 => flash_init
參考資料:Cisco
https://www.cisco.com/c/en/us/support/docs/switches/catalyst-2900-xl-series-switches/24328-156.html#reset_switch
http://notthenetwork.me/blog/2013/05/28/reset-a-cisco-2960-switch-to-factory-default-settings/
啟用 SSH 登入功能
在安全性的需求上,需要開放 SSH 登入
1. 新增domain name
(config)#ip domain name abc.com.tw
2. 啟動ssh-server並產生RSA-KEY
(config)#crypto key generate rsa
3. 新增帳號及給予權限0-15 (15最高)並設定密碼
(config)#username test privilege 15 password 9999999
4. 登入管理模式,輸入「line vty 0 4」,代表要設定0到4的介面。同時連線介面最高為5
(config)#line vty 0 4
5. 僅開放 ssh 存取
(config-line)#transport input ssh
6. 使用local驗證資料庫
(config-line)#login local
(config-line)#^Z
7. 將明碼的password加密
service password-encryption
yi 大手寫
switch log 寫入遠端 log server 設定
(config)#logging host [IP]
官方文件詳細寫了 8 個步驟
時間設定
# clock set 17:49:00 10 dec 2018 <= 設定系統時間為 2018年12月10日17:49分
(config)#clock timezone TW +8 <= 設定系統時區為 台北 +8
(config)#ntp server 192.168.1.1 <= 設定時間伺服器為 192.168.1.1
註1:有些版本的 IOS 無法使用 clock timezone TW +8,必需使用 clock timezone NST 8 0。如 Cisco IOS XE Software, Version 16.09.01 版本
註2:National Standard Time,縮寫:NST,亦被稱為臺灣標準時間、臺北時間或中原標準時間
參考資料:
James 大的文件
http://www.james-tw.com/cisco/cisco-switch-base-setting
wiki
https://zh.wikipedia.org/wiki/%E5%9C%8B%E5%AE%B6%E6%A8%99%E6%BA%96%E6%99%82%E9%96%93
cisco
https://www.cisco.com/c/m/en_us/techdoc/dc/reference/cli/nxos/commands/fund/clock-timezone.html
ComputerNetworkingNotes 大大文章 -- 非常詳細的說明如何設定 NTP
https://www.computernetworkingnotes.com/ccna-study-guide/how-to-configure-ntp-in-cisco-router.html
讓 Log 資訊中帶登入成功、登入失敗資訊
除了 cciesec大的回應,還有一個值也可以加入,就是 logging userinfo
參考資料:官方討論 - cciesec2011 回應
https://community.cisco.com/t5/policy-and-access/how-to-log-success-and-failed-login-attempt-details-to-router/td-p/1424821
監控指定 port
cisco 有一個功能就是可以由另一個 port 監控指定的 port,towns 的 switch 是 2960,韌體版本 c2960x-universalk9-mz.152-2.E3,使用以下方式設定
設定方式
switch> enable
switch# conf t
config# monitor session 1 source interface Fa0/21
config# monitor session 1 destination interface Fa0/22
參考資料:
光大的 blog
https://blog.xuite.net/j62u6/kazma/165450090-%E8%A8%AD%E5%AE%9ACisco+switch+Port+Mirror
關閉 switch(router)SSH 弱加密
弱掃出現了 aes128-cbc、aes192-cbc、aes256-cbc、hmac-sha1-96 強度不足,以下是設定方式
選擇要使用的加密方式
11(config)#ip ssh server algorithm encryption aes128-ctr aes256-ctr
11(config)#ip ssh server algorithm mac hmac-sha1
檢查是否已設定
11#show ip ssh
在 Encryption Algorithm、MAC Algorithm 會出現已選擇的項目
寫入開機啟動檔
11#copy running-config startup-config
參考資料:
steve 口述
cisco 社群討論
https://community.cisco.com/t5/vpn-and-anyconnect/disabling-ssh-cbc-cipher-on-cisco-routers-switches/td-p/2606358
透過 switch 檢查 IP 是走哪個 Port
show ip arp 1.2.3.4
Protocol Address Age (min) Hardware Addr Type Interface
Internet 1.2.3.4 74 aaaa.bbbb.cccc ARPA default
show mac address-table | include aaaa.bbbb.cccc
defualt aaaa.bbbb.cccc DYNAMIC Gi0/16
參考資料:
Steve 大口述
取得操作紀錄
show archive log config all
註:如果有匯出 log,操作紀錄也會在裡面
jason 大大口述
snmp 設定(switch)
(config)#snmp-server group [groupname] v3 priv match exact
(config)#snmp-server user [username] [groupname] v3 auth SHA [sha passwd] priv aes 128 [aes passwd]
(config)#snmp-server host 1.1.1.1 version 3 priv [aes passwd]
測試:
snmpwalk -v3 -l authPriv -u [username] -a SHA -A [sha passwd] -x AES -X [aes passwd] 1.1.1.1
檢查:
#show snmp
#show snmp group
#show snmp user
參考資料:
steve大口述
官方文件 -- Configuring Simple Network Management Protocol
https://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst9300/software/release/16-6/configuration_guide/nmgmt/b_166_nmgmt_9300_cg/b_166_nmgmt_9300_cg_chapter_010.html
ACL
在 CISCO 的規則中, ACL 預設為 Deny All,所以,如果建立一條空白的 ACL 規則並套後用,會造成中斷,必需於該規則下再建立一條 allow all 規則
範例:
access-list 150 504 permit tcp host 192.168.56.152 host 192.168.20.23 eq 443
參考資料:
steve 大口述
官方說明
https://www.cisco.com/c/en/us/support/docs/ip/access-lists/26448-ACLsamples.html
snmp 設定(1921 router)
towns 是看了 tedauction 大的問題及設定方式才成功的,做完以下三個動作 snmp v3 就啟動了,看了官方文件,反而無法啟動
1. snmp-server view ALL-ACCESS iso included <== router 預設下並沒有預設存取任何 MIB,所以需設定 view
2. snmp-server group myGroup v3 priv read ALL-ACCESS <== 建立讀取群組
3. snmp-server user myUser myGroup v3 auth sha ******* priv aes 128 ****** <== 建立讀取帳號
註1:刪除 snmp-server 帳號
(config)#no snmp-server user myUser myGruop v3
註2:使用 aes 256 時,會發生,Timeout: No Response 的情形
參考資料
官方文件
https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/snmp/configuration/xe-3se/3850/snmp-xe-3se-3850-book/nm-snmp-snmpv3.html?dtid=osscdc000283
v2設定
https://www.cisco.com/c/en/us/support/docs/ip/simple-network-management-protocol-snmp/7282-12.html
官方討論串 -- tedauction 提問
https://community.cisco.com/t5/switching/cisco-snmpv3-1921-router/td-p/3312449
查看 port-channel bondle 的情形
show etherchannel summary
可以看到每一個 port-channel 綁定那些 Port
查看介面狀態
show ip interface brief
千兆乙太網路介面轉換器(英語:Gigabit Interface Converter,簡稱GBIC)
GBIC已經有小型化的版本,是小封裝可插拔收發器(Small Form-factor Pluggable,縮寫SFP)
這個如果使用副廠的,會出現相容性問題,需要注意
以前的 cisco 的韌體是有強制擋副廠的 gbic 不過,後來已經全部開放了,不過,仍有些時候會有問題,所以當遇到這樣的問題(gbic 抓到了,設定完成後,卻 ping 不到)時,可以先考慮是否要先更換韌體試試
查看建立的 tunnel 是否使用 site to site vpn 及查看加密方式
sh run 查看 crypto ipsec transform-set 及 crypto isakmp policy 兩個設定值
sh crypto isakmp policy 查看 encryption algorithm: 可以看到加密演算法
參考資料:steve 大口述
ACL 設定流程
新增
登入 > config terminal > ip access-list extended [ACL Number] > [seq-number] permit icmp any any
刪除
登入 > config terminal > ip access-list extended [ACL Number] > no [seq-number] permit icmp any any
注意1:設定方式與 A10 不同點在於 3,A10不需要登入該 extended,cisco 是需要的
注意2:登入該 extended 中,設定指令就不需要再下 access-list 123 .........
注意3:ACL 預設為全擋,所以,只要一增加一個 extended,並有套用在 interface上,就一定要先加上 permit ip any any ,避免錯誤設定時,造成網路斷線
注意4:如果使用 no access-list 123 10 permit tcp host 1.2.3.4 host 1.2.4.4 eq 3389 這樣的方式,而沒進到指定的extended,將會將整個 123 刪除
LACP(Link Aggregation Control Protocol)
將兩個 Physical Ethernet Port(兩個實體網路孔)綁成一個的協定,也有稱為 Port Channel
LACP 建置流程
1. 建立 port channel
登入 > config terminal > interface po3 > 設定 mode,switchport mode access > 加入 Vlan(選用),switchport access vlan 123
註1:switchport mode 必需與 綁入的 mode 一致
註2:如果有指定 Vlan,也必需加入
2. 加入 port
登入
> config terminal > interface gi1/0/3 > 設定 mode,switchport
mode access > 加入 Vlan(選用),switchport access vlan 123 > 加入虛擬 port
po3,並設定為 active,channel-group 3 mode active
登入 > config terminal > interface gi2/0/3 > 設定 mode,switchport mode access > 加入 Vlan(選用),switchport access vlan 123 > 加入虛擬 port po3,並設定為 active,channel-group 3 mode active
註:設定完成後,建議將 port 下 shutdown、no shutdown 一次,因為 towns 有發生預先設定好接完線,protocol 卻出現 down 的情形
3. 檢查設定狀態
1. 檢查 Port 狀態
show interface gi1/0/3
正常應該要看到 interface 及 protocol 都是 up 的狀態
2. 檢查 虛擬 port 狀態
show etherchannel summary
正常要看到 Po3(SU)、gi1/0/3(P)、gi2/0/3(P)
註:因為 towns 設定為 AA,所以會出現 PP 的情形,如果設定為 AP 方式,就會出現 PH
3. 檢查 vlan(選用)
show vlan
正常要看到 vlan123 為 active 且放入的 Po 應為 Po3
4. 實際線路測試
實際將線路拔成單條測試
參考資料:
Jan ho大的文章
https://www.jannet.hk/etherchannel-pagp-lacp-zh-hant/
關於 ACL 的 matches
不是每一條 ACL 都會有 matches 這個數字,為什麼這樣子,不能每一條都有嗎?A10 每一條都有 hits 數呢!
看完了
Jon大及官方文件後,可以大約知道,如果是 hardware ACL Support,就不會計數,software ACL Support
就可能會可以看到計數,不過在很多的規則中就是有些規則會出現,如 permit icmp 的有出現,deny ip 的有出現、有加 log
的有出現,其他就沒了,奇怪了 = =,towns 還不是很懂。
參考資料:
cisco 討論 -- Jon 大的回應
https://community.cisco.com/t5/switching/acl-not-showing-matches/td-p/997343
官方說明
https://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst6500/ios/12-2SXF/native/configuration/guide/swcg/acl.html#wp1033602
Cisco Discovery Protocol
這個協定可以找出使用 cisco 設備互連的設備
show cdp neighbors
其他資料:
網管人 胡先生 -- 親自操作徹底了解Cisco IOS
http://www.netadmin.com.tw/article_content.aspx?sn=1205070002&jump=1
david 大的文章 -- Cisco Switch Vlan 基礎設定教學
https://www.hkitblog.com/?p=11113
挨踢人 -- Cisco switch 還原成預設值步驟
https://chaomengyang.wordpress.com/2011/08/10/cisco-switch-%E9%82%84%E5%8E%9F%E6%88%90%E9%A0%90%E8%A8%AD%E5%80%BC%E6%AD%A5%E9%A9%9F/
James 大 -- Cisco Switch基本設定
http://www.james-tw.com/cisco/cisco-switch-base-setting
Jumperman 大 -- log 設定格式
http://easonlu.blogspot.com/2008/05/ciscolog.html
EdisonChang 大的文章 -- cisco 3750G stack 設定
https://coolking1206.pixnet.net/blog/post/57616767
留言
張貼留言