admin@Juniper# rename interfaces ge-0/0/7 to ge-0/0/5 [edit] admin@Juniper# show |compare [edit interfaces] + ge-0/0/5 { + unit 0 { + family ethernet-switching { + interface-mode access; + vlan { + members internal; + } + } + } + } - ge-0/0/7 { - unit 0 { - family ethernet-switching { - interface-mode access; - vlan { - members internal; - } - } - } - } [edit] admin@Juniper#
工具 7: replace pattern(替換字符串)
相比 rename,replace pattern 的功能更為強(qiáng)大,他可以替換整個(gè) JUNOS 配置里面的參數(shù)。假設(shè) ge-0/0/7 被某一個(gè) routing-instance (VRF)調(diào)用,在執(zhí)行 replace pattern ge-0/0/7 with ge-0/0/5 以后,接口配置和 routing-instance 配置都會(huì)同時(shí)改變。這在大批量修改某一個(gè)參數(shù)的時(shí)候尤其方便。
在此案例中,ge-0/0/7 僅有接口配置,并未被其他協(xié)議等調(diào)用。所以 show | compare 僅僅替換接口相關(guān)參數(shù)。
admin@Juniper# replace pattern ge-0/0/7 with ge-0/0/5
替換完成后,使用前面講到的 show | compare 查看結(jié)果,方法如下:
admin@Juniper# show |compare [edit interfaces] + ge-0/0/5 { + unit 0 { + family ethernet-switching { + interface-mode access; + vlan { + members internal; + } + } + } + } - ge-0/0/7 { - unit 0 { - family ethernet-switching { - interface-mode access; - vlan { - members internal; - } - } - } - } [edit]
可以看出,運(yùn)用此工具后,所有的 ge-0/07 都被替換成了 ge-0/0/5。
工具 8: copy (復(fù)制某一個(gè)變量到其他變量)
如果這個(gè)時(shí)候,服務(wù)器部門(mén)又發(fā)郵件告知你,索性把ge-0/0/5和ge-0/0/7都配置了吧,很簡(jiǎn)單,我們把ge-0/0/7的配置復(fù)制到ge-0/0/5就行了。
下面我們以ge-0/0/7為模板復(fù)制配置到ge-0/0/5。
admin@Juniper# copy interfaces ge-0/0/7 to ge-0/0/5 [edit] admin@Juniper# show |compare [edit interfaces] + ge-0/0/5 { + unit 0 { + family ethernet-switching { + interface-mode access; + vlan { + members internal; + } + } + } + } [edit] admin@Juniper#
完成以上的預(yù)配置之后我們需要讓其生效。正如我之前提到過(guò),Juniper 的配置是需要 commit 提交以后才能生效的,但是為了避免提交配置以后,出現(xiàn)意外情況導(dǎo)致工程師丟失與路由器的管理連接,JUNOS 引入了自動(dòng)倒回功能。
工具9: commit confirm xxx comment “xxx” (提交配置,若沒(méi)有工程師確認(rèn),系統(tǒng)會(huì)在xx分鐘之內(nèi)倒回,并附上配置備注)
這是 JUNOS 最讓人愛(ài)不釋手的一個(gè)功能。先看例子:使用 commit confirm comment 來(lái)提交配置
admin@Juniper# commit confirmed 2 comment "add new interfaces as well as vlan configuration" commit confirmed will be automatically rolled back in 2 minutes unless confirmed commit complete # commit confirmed will be rolled back in 2 minutes [edit] admin@Juniper#
如上所示,confirm 2 是告知路由器,兩分鐘之內(nèi)如果工程師沒(méi)有確認(rèn)此配置,那么之前配置的內(nèi)容將被刪除并還原回配置之前的狀態(tài)。如果在 confirm 之后不加數(shù)字,默認(rèn)是 10 分鐘。最低可以設(shè)置一分鐘。
更貼心的是,你還可以使用 comment 關(guān)鍵字添加備注,這樣大大方便了后續(xù)核查的時(shí)候了解每次操作的大概內(nèi)容。以上面的配置為例,通過(guò)備注可以知道此次配置內(nèi)容為新增兩個(gè)接口和一個(gè) vlan。
下面再來(lái)演示一下 Juniper 設(shè)備在 2 分鐘后無(wú)人確認(rèn)配置的情況下,自動(dòng)倒回的輸出:
[edit] Broadcast Message from root@Juniper (no tty) at 17:35 NZST... Commit was not confirmed; automatic rollback complete. [edit] admin@Juniper#
那么在 commit 之后,一切工作正常,我如何避免配置被自動(dòng)倒回呢?
我們只需要在倒回時(shí)間超時(shí)之前再做一個(gè)核查配置的 commit check 就行了。如下所示:
# commit confirmed will be rolled back in 2 minute [edit] admin@Juniper# commit check configuration check succeeds [edit] admin@Juniper#
是不是很貼心?
割接中
因?yàn)橛星捌诘念A(yù)配置,割接就顯得很輕松了。我們只需要?jiǎng)h除 disable 以及 deactivate 的命令行就完成了。這里會(huì)用到如下工具:
工具 10: activate(激活忽略的預(yù)配置)
通過(guò)刪除之前的disable 配置,并activate之前的deactivate的配置,就可以激活之前加載的所有預(yù)配置。
admin@Juniper# load set terminal [Type ^D at a new line to end input] delete interfaces ge-0/0/6 disable delete interfaces ge-0/0/7 disable activate interfaces irb unit 5 family inet address192.168.1.1/24 load complete [edit]
用 show | compare 確認(rèn)激活行為:
admin@Juniper# show |compare [edit interfacesge-0/0/6] - disable; [edit interfacesge-0/0/7] - disable; [edit interfaces irbunit 5 family inet] ! active: address 192.168.1.1/24 { ... }
工具 11: commit at(定點(diǎn)提交配置)
激活配置以后,同樣我們也需要向 JUNOS 提交配置,相比之前的 commit confirm,這次我們換一個(gè)方法,使用 commitat。如下所示,它會(huì)告知路由器,請(qǐng)?jiān)谕砩?10 點(diǎn)整的時(shí)候提交這個(gè)配置。(你可以根據(jù)自己的時(shí)間修改,但是需要比當(dāng)前時(shí)間晚。)
admin@Juniper# commitcomment "cut over the vlan and ge-0/0/5,ge-0/0/6" at 22:00 configuration checksucceeds commit at will beexecuted at 2017-09-14 22:00:00 NZST The configuration hasbeen changed but not committed Exiting configurationmode
如上所示,系統(tǒng)提示配置會(huì)在晚上10點(diǎn)被執(zhí)行。
需要說(shuō)明的是,為了給大家展現(xiàn)各個(gè)工具的使用方法,特地挑選了一個(gè)及其簡(jiǎn)單的案例。但是帶來(lái)的副作用就是沒(méi)有完全體現(xiàn)出預(yù)先加載割接配置的優(yōu)勢(shì)。但是試想一下如果此次割接需要大量的配置,例如大量的 VRF 配置,大量的 BGP 鄰居配置以及接口配置等。通過(guò)在割接前加載所有配置并 deactivate 掉,割接時(shí)只需要少量命令行來(lái) activate 激活預(yù)配置,從而大大簡(jiǎn)化了割接的步驟和復(fù)雜度,進(jìn)而減小了犯錯(cuò)誤的可能性。
割接完成
割接完成以后,最重要的就是核查網(wǎng)絡(luò)運(yùn)行情況,確認(rèn)提交的配置是否按照預(yù)期運(yùn)行,并且沒(méi)有引入任何其他網(wǎng)絡(luò)故障。為了達(dá)到這樣的目的,我們可以采用以下介紹的工具:
工具11: monitor interface(設(shè)備接口流量監(jiān)控)
完成接口配置以后,我們需要核查接口是否有流量。如果用傳統(tǒng)的 show interface xxx 看到的都是靜態(tài)數(shù)據(jù),那有沒(méi)有更好的方法?例如動(dòng)態(tài)地觀測(cè)數(shù)據(jù)。
借助 monitor interface,我們就可以輕松實(shí)現(xiàn)這個(gè)功能,如下實(shí)例:
admin@Juniper>monitor interface ge-0/0/5 Interface: ge-0/0/5,Enabled, Link is Up Encapsulation:Ethernet, Speed: 1000mbps Trafficstatistics: Current delta <以下為接口實(shí)時(shí)動(dòng)態(tài)輸入輸出流量,每秒都在刷新,我只截取了某一秒的輸出內(nèi)容> Input bytes: 17411220 (200 bps) [52] Output bytes: 24971481 (947704 bps) [438150] Input packets: 324059 (0 pps) [1] Output packets: 319355 (789 pps) [2921] Errorstatistics: Input errors: 0 [0] Input drops: 0 [0] Input framing errors: 0 [0] Policed discards: 0 [0] L3 incompletes: 0 [0] L2 channel errors: 232 [0] L2 mismatch timeouts: 0 [0] Carrier transitions: 1 [0] Output errors: 0 [0] Output drops: 0 [0] Aged packets: 0 [0] <為了便于閱讀,此處省略了其他無(wú)關(guān)的輸出內(nèi)容>
此命令是每秒鐘都在刷新,如果大家有條件可以在設(shè)備上嘗試一下,博客上無(wú)法動(dòng)態(tài)展現(xiàn)給大家。
工具 12: monitor traffic interface (cli 層面的tcpdump 數(shù)據(jù)抓包)
有些時(shí)候配置了路由協(xié)議,但是發(fā)現(xiàn)其沒(méi)有正常工作,在開(kāi)啟 debug 模式之前,我們還有一個(gè)最簡(jiǎn)單的辦法來(lái)排錯(cuò),那就是抓包。
想到抓包,大家是不是第一印象就是做鏡像端口,然后把 PC 接入設(shè)備用 Wireshark 抓取。
在 Juniper 設(shè)備上,如果你只是想抓取到達(dá)路由器本身的流量,例如像上面所述的路由協(xié)議排查,我們可以很簡(jiǎn)單地在命令行模式下抓取到達(dá)路由器的數(shù)據(jù)包。
下面演示一個(gè)命令行模式下用 monitor trafficinterface 的抓包:
admin@Juniper>monitor traffic interface ge-1/1/4.100 no-resolve verbose outputsuppressed, use <detail> or <extensive> for full protocol decode Address resolution isOFF. Listening onge-1/1/4.100, capture size 96 bytes s00:46:38.271636 In IP 1.2.3.4.179 > 1.2.3.5.61855: P662902184:662902203(19) ack 2900796289 win 16384 <nop,nop,timestamp3271803181 643396392>: BGP, length: 19 00:46:38.371433 Out IPtruncated-ip - 2 bytes missing! 1.2.3.5.61855 > 1.2.3.4.179: . ack 19 win16384 <nop,nop,timestamp 643418995[|tcp]> 00:46:38.724938 OutIS-IS, L2 Lan IIH, src-id 0011.0000.0001, lan-id 0011.0000.0001.03, prio 64,length 47 00:46:39.174455 OutES-IS, ISH, length 26 00:46:41.199436 OutIS-IS, L2 Lan IIH, src-id 0011.0000.0001, lan-id 0011.0000.0001.03, prio 64,length 47 00:46:42.161045 In IS-IS, L2 Lan IIH, src-id 0011.0000.0254,lan-id 0011.0000.0001.03, prio 64, length 47 00:46:42.481016 OutIS-IS, L2 CSNP, src-id 0011.0000.0001.00, length 47 00:46:43.797914 OutIS-IS, L2 Lan IIH, src-id 0011.0000.0001, lan-id 0011.0000.0001.03, prio 64,length 47 00:46:43.864907 Out IPtruncated-ip - 21 bytes missing! 1.2.3.5.61855 > 1.2.3.4.179: P 1:20(19) ack19 win 16384 <nop,nop,timestamp 643424488[|tcp]> 00:46:43.964852 In IP 1.2.3.4.179 > 1.2.3.5.61855: . ack20 win 16384 <nop,nop,timestamp 3271808875 643424488> 00:46:46.147386 OutIS-IS, L2 Lan IIH, src-id 0011.0000.0001, lan-id 0011.0000.0001.03, prio 64,length 47 00:46:48.400363 OutIS-IS, L2 Lan IIH, src-id 0011.0000.0001, lan-id 0011.0000.0001.03, prio 64,length 47 00:46:49.340934 In IS-IS, L2 Lan IIH, src-id 0011.0000.0254,lan-id 0011.0000.0001.03, prio 64, length 47 ^C 15 packets received byfilter 0 packets dropped bykernel
從上面輸出可以看出,兩臺(tái)路由器之間有 BGP 通信流量,同時(shí)還有 IS-IS IGP 路由協(xié)議流量。
當(dāng)然,monitor traffic interface 還有更多選項(xiàng)。例如 extensive 可以看到更多的數(shù)據(jù)包內(nèi)容,通過(guò) match 可以像 tcpdump 一樣,設(shè)定源、目標(biāo)地址,端口等信息來(lái)過(guò)濾數(shù)據(jù)包。
工具 13: show interface terse | refresh xxx (定期自動(dòng)刷新)
此工具是用于定時(shí)自動(dòng)刷新某些顯示的命令行內(nèi)容。打個(gè)比方,有時(shí)候我們難免遇到需要同遠(yuǎn)端聯(lián)調(diào)設(shè)備端口。在完成相應(yīng)配置后,雙方需要確認(rèn)接口是否 up。一般方法是按向上的方向鍵調(diào)出命令不斷手工刷新?tīng)顟B(tài),其實(shí)更簡(jiǎn)單的辦法就是使用 refresh。
Refresh 可以用于任何狀態(tài)顯示的自動(dòng)定期刷新,例如定期接口狀態(tài),定期刷新 OSPF,ISIS,BGP 鄰居狀態(tài)等。
如下案例,設(shè)定路由器每 1 秒鐘自動(dòng)刷新一次接口狀態(tài)。
admin@Juniper> showinterfaces terse ge-0/0/2 | refresh 1 | no-more ---(refreshed at2017-09-14 22:00:55 NZST)--- Interface Admin Link Proto Local Remote ge-0/0/2 up up ge-0/0/2.10 up up ge-0/0/2.32767 up up ---(refreshed at2017-09-14 22:00:56 NZST)--- Interface Admin Link Proto Local Remote ge-0/0/2 up up ge-0/0/2.10 up up ge-0/0/2.32767 up up ---(refreshed at2017-09-14 22:00:58 NZST)--- Interface Admin Link Proto Local Remote ge-0/0/2 up up ge-0/0/2.10 up up ge-0/0/2.32767 up up ---(refreshed at2017-09-14 22:00:59 NZST)--- Interface Admin Link Proto Local Remote ge-0/0/2 up up ge-0/0/2.10 up up ge-0/0/2.32767 up up ---(refreshed at2017-09-14 22:01:00 NZST)--- Interface Admin Link Proto Local Remote ge-0/0/2 up up ge-0/0/2.10 up up ge-0/0/2.32767 up up ---(refreshed at2017-09-14 22:01:01 NZST)--- Interface Admin Link Proto Local Remote ge-0/0/2 up up ge-0/0/2.10 up up ge-0/0/2.32767 up up
### 割接結(jié)束 ####
以上就是在使用 Juniper 設(shè)備過(guò)程中常用的運(yùn)維技巧和方法,相信有了這么多工具和思路的幫助下,對(duì)于大家的日常工作相比原來(lái)是否就不那么恐慌了。至少可以對(duì)自己的配置胸有成竹,自信的敲下 commit 的回車(chē)鍵了!
說(shuō)到應(yīng)急響應(yīng),都是根據(jù)已知的問(wèn)題來(lái)進(jìn)行應(yīng)急處理的。全面的應(yīng)急響應(yīng)無(wú)法在第一時(shí)間確定,從而進(jìn)行已知的事件處理,是作為第一步的開(kāi)始。
那么在第一時(shí)間確認(rèn)安全事件,根據(jù)安全事件是否需要斷網(wǎng)。進(jìn)行數(shù)據(jù)方盒處理,啟用網(wǎng)絡(luò)數(shù)據(jù)分解裝載轉(zhuǎn)輸,在一定時(shí)間內(nèi),保留有價(jià)值的鏡頭(不是攝像頭)。從而更好的了解整個(gè)安全事件還原處理。
1.進(jìn)程/用戶/端口/密碼/日志/啟動(dòng)項(xiàng)/服務(wù)項(xiàng)/計(jì)劃任務(wù)/注冊(cè)表/其他
0.01 tasklist命令
tasklist 查看本機(jī)進(jìn)程 這里主要看的就是一個(gè)內(nèi)存的使用率
0.02 PID找到程序進(jìn)程 我們可以根據(jù)PID找到異常進(jìn)程 關(guān)閉或者找到絕對(duì)路徑
C:\Users\Administrator>wmic process where processid=68 get processid,executablepath,name
ExecutablePath Name ProcessId
C:\Windows\system32\cmd.exe cmd.exe 68
68就是PID數(shù)字
也可以查看端口知曉PID
C:\Users\Administrator>netstat -nao | findstr 443
最后一列就是PID
0.03 殺死進(jìn)程
可以直接狙擊進(jìn)程
C:\Users\Administrator>taskkill /PID 6464 /F
或者
ntsd -c q -p 6464
wmic process where name="cmd.exe" delete
wmic process where processid=6464 call terminate
殺死進(jìn)程的方法有很多
0.04 找到可疑進(jìn)程 可以進(jìn)行在線病毒分析
在線病毒分析列表:
https://habo.qq.com/ 騰訊哈勃分析系統(tǒng)
https://www.virustotal.com/gui/home/upload virustotal
https://www.virscan.org/language/zh-cn/ VirSCAN
https://s.threatbook.cn/ 微步云沙箱
https://virusscan.jotti.org/ Jotti的惡意軟件掃描系統(tǒng)
在線的病毒查殺都是看誰(shuí)的病毒庫(kù)特征碼更新快 你也可以多找?guī)讉€(gè)進(jìn)行驗(yàn)證
0.05 用戶賬戶
0.051 net user 查看系統(tǒng)用戶
C:\Users\Administrator>net user
\\YDKVDLXFIN0M3U6 的用戶帳戶
-------------------------------------------------------------------------------
Administrator DefaultAccount Guest
mysql WDAGUtilityAccount www
0.052 我的電腦(此電腦)右鍵屬性-控制面板-用戶賬戶
有些用戶是隱藏了的 那么使用命令看到的就比較多 而這個(gè)只顯示了超級(jí)管理員用戶
0.053 我的電腦(此電腦)右鍵屬性-管理-本地用戶和組-用戶
也可以使用cmd命令打開(kāi) lusrmgr.msc
這里面看到的跟我們cmd里面看到的是一樣的 當(dāng)然這里面看到的也不一定是完整的 這里留一個(gè)問(wèn)題給大家?
0.0531查看當(dāng)前已經(jīng)登錄用戶
C:\Users\Administrator>query user //查看當(dāng)前已經(jīng)登錄的用戶信息
用戶名 會(huì)話名 ID 狀態(tài) 空閑時(shí)間 登錄時(shí)間
>administrator console 1 運(yùn)行中 無(wú) 2022/5/28 星期六 22:47
C:\Documents and Settings
C:\Users 這個(gè)目錄里面可以看到新建用戶的文件夾
可以用logoff ID 命令 注銷(xiāo)已登錄用戶
0.054 注冊(cè)表 里面的用戶賬戶
wir+r 輸入regedit 打開(kāi)注冊(cè)表
編輯-查找-administrator(實(shí)例) 根據(jù)實(shí)際情況做出調(diào)整
0.541示例一
計(jì)算機(jī)\HKEY_CLASSES_ROOT\*\shell\runas\command
cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F
上面這段的意思就是讓當(dāng)前用戶成為當(dāng)前文件夾的所有者 獲得超級(jí)管理員組權(quán)限
0.542示例二
計(jì)算機(jī)\HKEY_CLASSES_ROOT\.doc\WPS.Doc.6\ShellNew
C:\Users\Administrator\AppData\Local\Kingsoft\WPS Office\11.1.0.8840\office6\mui\zh_CN\templates\newfile.wps
上面這段就是一個(gè)wps的新建文件模板絕對(duì)路徑 算是殘留在注冊(cè)表
還有一些殺毒軟件也會(huì)在注冊(cè)表添加administrators 組權(quán)限值
0.0543 如果你不想動(dòng)手 那么可以用工具看下
0.6 端口
這里普及一下端口
常用端口號(hào):
代理服務(wù)器常用以下端口:
主要看的是日志事件是否丟失斷點(diǎn)清除痕跡
0.071
可以雙擊事件 看到常規(guī)信息 詳細(xì)信息
常規(guī)信息 簡(jiǎn)要信息 留意事件 計(jì)算機(jī) 用戶 事件ID
詳細(xì)信息 哪一步出現(xiàn)錯(cuò)誤
咱們主要看的還是詳細(xì)信息
0.072 使用Log Parser 分析 微軟的工具GUI界面 【數(shù)據(jù)量大的可以使用工具】
https://www.microsoft.com/en-us/download/details.aspx?id=24659
日志解析器是一個(gè)強(qiáng)大的通用工具,它提供對(duì)基于文本的數(shù)據(jù)(如日志文件、XML 文件和 CSV 文件)以及 Windows? 操作系統(tǒng)上的關(guān)鍵數(shù)據(jù)源(如事件日志、注冊(cè)表、文件系統(tǒng)和 Active Directory?。
雙擊安裝 步驟:
1.下一步
2.勾選 我用一下一步
3.完整安裝 complete
4.install 安裝
logparser使用方法 先保存所有事件(將所有事件另存為evtx格式)
使用工具步驟 界面
里面的使用方法已經(jīng)全說(shuō)明
網(wǎng)格顯示指定分析日志 csv/iisw3c等都可以
C:\Program Files (x86)\Log Parser 2.2>Logparser.exe -i:EVT -o:DATAGRID "SELECT * FROM C:\log.evtx"
可以看到上面的圖片已經(jīng)整理的非常巴適
未完待續(xù)……