1.0



作者: Andrew Colin Kissa <andrew [at] topdog [dot] za [dot] net>



最後編輯日期 03/08/2008



譯者:Nica  < nicaliu at gmail dot com >







背景說明

我最近決定開始研究 Cisco CSSP 認證 。一開始主要是因為我發現大部份的 Lab 模擬軟體都只能在 Windows 上跑,這下我這樣一個沒有 Windows 電腦的人來說,是個麻煩。



快速搜尋後,我發現超棒的 Dynamips 專案,一個優於其它執行實際 Cisco ISO image 的模擬器。還有 PEMU 專案 -- 可以用來執行 Cisco PIX images。為了整合各式軟體片段,並提供與裝置互動之介面,我選擇了 dynagen







準備動作

你必須會用 Linux 的命令列,並具備 Cisco IOS/PIX 方面的知識。請特別注意,這裡你必須提供你自有的 Cisco IOS/PIX images,請不要傳任何訊息跟我要 image







軟體安裝



這些指令雖然是在 Centos 5.2 下執行,但也能輕鬆套用至其它 Linux 系統。在我們使用的是 rpm 為基礎的系統的情況下,所有套件都將用 rpm 安裝,而非 source,這麼作可以讓套件管理更容易 。所有這裡提及的專案 (除了 pemu ) 都有 source rpm,供你取得編譯之。你可以從我的網站下載 到我取得並編譯的那些 source rpm,當然你也可以去你想要的其它地方取用並編譯之。我建立完成的 PEMU rpm,你也可以下載 使用。

以上 rpm 皆使用我的金鑰 簽章完成,所以你可以核對它們。


wget  http://www.topdog-software.com/oss/roundcube/andrew_topdog-software.com_key.txt



rpm --import andrew_topdog-software.com_key.txt



現在,開始安裝。



Dynamips



此乃提供 Cisco IOS 模擬器與 PEMU wrapper 的主要元件



rpm -Uvh http://www.topdog-software.com/oss/dynamips/dynamips-0.2.8RC2-1.i386.rpm





Dynagen



這是 dynamips 軟體的介面,提供簡化後的 ini 型組態檔、frame-relay內建於交換器、橋接器裡的功能,以及管理用 CLI (命令列模式)



rpm -Uvh http://www.topdog-software.com/oss/dynagen/dynagen-0.11.0-1.noarch.rpm





PEMU



這是 Cisco PIX/ASA 模擬器,用來執行 PIX image



rpm -Uvh http://www.topdog-software.com/oss/pemu/pemu-0.0.1-20070420.i386.rpm



Lab 範例



為了我們的 Lab 範例,我透過 SNPA 模組建置了一個 LAB,因為此模組可以讓我們看 IOS PIX 兩者的動作,不過首先我們得先啟動服務:





service dynamips start

service pemu start


解開 image,這樣它們開機會更快。





unzip snrs.bin

cp C3640-JK.BIN /var/lib/pemu/images/snrs.bin

unzip asa722-k8.bin

cp target/f1/pix /var/lib/pemu/images/pix


因為在這個 Lab 要用到 dynagen ini 檔,所以我們建立檔案 /tmp/snpa.net,該檔案內容如下:
















autostart = false



model = 3640



ghostios = true



sparsemem = true



[localhost]



workingdir = /var/lib/pemu



[[3640]]



image = /var/lib/pemu/images/snrs.bin



#idlepc = 0x60ba8df4



[[router inside]]



# This router will be on the "inside" of the firewall



# Connect this router's e0/0 interface to fw1's e1 interface



e0/0 = fw1 e1



[[router outside]]



# This router will be on the "outside" of the firewall



# Connect this router's e0/0 interface to fw1's e0 interface



e0/0 = fw1 e0



[[ethsw s1]]



1 = access 1



# Bridge the below interface to allow fw1's e2 interface access to real networks



# e.g. for using ASDM from a PC to manage the firewall, change the interface to



# reflect your system



2 = access 1 NIO_gen_eth:eth1



[pemu localhost]



[[525]]



#for pix 7 & 8



serial = 0x1234568



key = 0xffffffff,0xffffffff,0xffffffff,0xffffffff



image = /var/lib/pemu/images/pix



[[fw fw1]]



# Connect the firewall's e2 interface to the virtual switch, which will bridge it



# to the real network



e2 = s1 1


















現在,連結 dynagen console 並與我們的 lab 環境互動該有的東西都有了。



dynagen /tmp/snpa.net





你會看到如下提示畫面:
















Reading configuration file...



Network successfully loaded



Dynagen management console for Dynamips and Pemuwrapper 0.11.0



Copyright (c) 2005-2007 Greg Anuzelli, contributions Pavel Skovajsa



=>






















來看看在 dynagen console 下有哪些選擇可用,你可以輸入常見的 ? 命令:












=> ?



Documented commands (type help <topic>):



========================================



capture  confreg  cpuinfo  export  hist    list  py      save   show   suspend



clear    console  end      filter  idlepc  no    reload  send   start  telnet



conf     copy     exit     help    import  push  resume  shell  stop   ver



=>






















也可以用 list 命令,列出所有我們 lab 環境下可使用的裝置:




















=> list



Name       Type       State      Server          Console



inside     3640       stopped    localhost:7200  2000



outside    3640       stopped    localhost:7200  2001



fw1        525        stopped    localhost:10525 4000



s1         ETHSW      always on  localhost:7200  n/a



=>






















啟動裝置:




















=> start outside



100-VM 'outside' started



=> start inside



100-VM 'inside' started



=> start fw1



100-PEMU 'fw1' started



=>






















為改善我們的裝置效能,可以設定 idlepc 值給各種不同的裝置:
















=> idlepc get inside





Please wait while gathering statistics...



1: 0x605a39c8 [61]



2: 0x605a3a40 [25]



3: 0x604fd014 [78]



4: 0x604fd044 [64]



5: 0x6048daa0 [80]



6: 0x604fe168 [75]



*  7: 0x604fe584 [59]



8: 0x604fe734 [46]



9: 0x604fe75c [49]



Potentially better idlepc values marked with "*"



Enter the number of the idlepc value to apply [1-9] or ENTER for no change: 7






















你可以針對想要設定 idlepc 值的裝置,重複上述動作。



其它範例 lab



你可以在 /usr/share/doc/dynagen-0.11.0/sample_labs 目錄下找到其它範例 Lab





Console 存取



現在是啟動也在執行中了,不過我想你大概會問:那我要怎麼 console 登入,操縱這台裝置? 每一台啟動的裝置都會提供你使用 console 存取的連接埠,在 dynagen console 下使用 list 命令,查看哪台機器用哪個連結埠。



當我們查到內部路由器可透過 2000 連接埠打開 console,就可以檢查看看了。







telnet localhost 2000


第一次你應會遇到如下畫面:












Trying 127.0.0.1...



Connected to localhost.localdomain (127.0.0.1).



Escape character is '^]'.



Connected to Dynamips VM "inside" (ID 0, type c3600) - Console port





% Please answer 'yes' or 'no'.



Would you like to enter the initial configuration dialog? [yes/no]:












接下來我們連結 PIX console



telnet localhost 4000



Enter 你會看到如下畫面:
















Trying 127.0.0.1...



Connected to localhost.localdomain (127.0.0.1).



Escape character is '^]'.



pixfirewall>












GUI 版本



對那些想使用圖形使用者介面建置 lab 的人來說,可以看看 GNS 專案 ,我個人喜歡使用命令列,所以沒有用這個。





致謝



感謝這些優異專案的開發人員;如果可以請考慮捐款予這些專案:









原文出處:



How To Set Up A Cisco Lab On Linux (CentOS 5.2)



如有版權問題,請來信 (nicaliu at gmail dot com) 告知,謝謝。









arrow
arrow
    全站熱搜

    nicaliu 發表在 痞客邦 留言(0) 人氣()