2011年6月24日 星期五

用Perl縮短維護Cisco Router Switch時間




因為一直用相同的指令在多台設備之間進行維護,實在覺得很…浪費時間,
透過Perl可以縮短許多重覆的部份。

下面是如何用Perl對一群Switch或Router做同樣的網路維護動作,
也把running-config備份下來:

Step.1 裝Perl:
以Windows來說,可以到這裡下載合適的Active Perl
http://www.activestate.com/activeperl/downloads
下載完點兩下進行安裝,安裝完記得重開機。

Step.2 裝Net::Telnet::Cisco 模組:
執行Comand_> ppm install Net::Telnet::Cisco進行安裝

Step.3 寫一段Perl:
用文字編輯器編寫並存成xxx.pl檔案:(以下範例即對一些IP進行相同的網維指令)
use Net::Telnet::Cisco;

my @hosts = qw( 192.168.1 192.168.3 192.168.6.6 192.168.8.8 192.168.12.4);
#把要登入的Swich或Router全打進上面

foreach my $host( @hosts ) {
my $session = Net::Telnet::Cisco->new(Host => $host);
$session->login('admin','1234');
#上面這段即輸入Switch或Ruter的帳號密碼
$session->enable('1234');
#再輸入enable的帳號密碼
open(write_file,">$host.txt");
#上面是把每一台主機的維護資訊都以IP名稱存檔
#下面是維護想要看的指令集
my @output;
push(@output,$session->cmd('show version'));
push(@output,$session->cmd('show log'));
push(@output,$session->cmd('show process cpu'));
push(@output,$session->cmd('show env all'));
push(@output,$session->cmd('show ip inter brief'));
push(@output,$session->cmd('show interface'));
push(@output,$session->cmd('show flash'));

print write_file @output;
close(write_file);
#最後再把running-config給備起來,IP是當時自已電腦的IP
$session->cmd('copy run tftp://IP');
}

2011年6月22日 星期三

Cisco 註冊碼之2101與2102

最近裝了一台4507R

遇到一個問題: 怎麼IOS都換不上去????

後來同事告訴我要注意Register值是不是2101,是的話就換不過去,Check一下:

到底什2101是啥咪意思?
這裡有說明:http://www.cisco.com/en/US/products/hw/routers/ps133/products_tech_note09186a008022493f.shtml

0x2101就是開機用bootstrap開機,不管你放在flash裡的東西:
Boots into bootstrap
Ignores break
Boots into ROM if initial boot fails
9600 console baud rate

更換成0x2102之後,就不用bootstrap開機,會去找flash裡的ios:
Ignores break
Boots into ROM if initial boot fails
9600 console baud rate default value for most platforms

時常要破掉密碼的0x2142就是跳過存在RAM裡的startup開機:
Ignores break
Boots into ROM if initial boot fails
9600 console baud rate
Ignores the contents of Non-Volatile RAM (NVRAM) (ignores configuration)

所以下次IOS換不過,可以確認一下註冊碼^^

耐熱的工業用Switch 2955


幫客戶維護發現這款Switch工作溫度竟然高達65度@@

確認過這款耐熱型Swich2955,工作溫度可達60度耶!!

真是夠屌的!

2011年6月12日 星期日

NME-X-23ES-1G-P模組的Password Recovery

這陣子在這下面台3845上:

插入了一片Switch的Service Module: NME-X-23ES-1G-P

這片模組是透過3845的背版相連接的,當登入到3845之後,要進入這片的方式如下:
Router#service-module gigabitEthernet 2/0 session

上面的gi 2/0就是3845上面接到模組的背版介面,以session即可連入。

如果是正常的情況要做密碼回復(Password Recovery),只要到Cisco這個便利的網站:
http://www.cisco.com/en/US/products/sw/iosswrel/ps1831/products_tech_note09186a00801746e6.shtml
就能找到。

但… NME-X-23ES-1G-P這片模組比較糗的是,當你重開Router時,Switch也開好了@@
不知道怎麼進行Rest,其實方法很簡單,如下:

Step.1 重設NME-X-23ES-1G-P模組密碼:
Router#service-module gigabitEthernet 2/0 password-reset
Do you want to proceed with password reset process?[confirm]
Starting password reset process...
Wait for 50 secs for password reset process to complete
Password reset process is complete...

[Resuming connection 1 to 192.168.10.253 ... ]

重設好之後會再登入Switch
switch:

Step.2 初始化Switch
switch: flash_init

Initializing Flash...

flashfs[0]: 503 files, 7 directories

flashfs[0]: 0 orphaned files, 0 orphaned directories

flashfs[0]: Total bytes: 32514048

flashfs[0]: Bytes used: 19305984

flashfs[0]: Bytes available: 13208064

flashfs[0]: flashfs fsck took 9 seconds.

...done Initializing Flash.


switch:

Step.3 備份開機檔config.text
switch: rename flash:config.text flash:config.text.bak

Step.4 開機
switch: boot

Loading "flash:c3750-ipbase-mz.122-35.SE5/c3750-ipbase-mz.122-35.SE5.bin"...@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

File "flash:c3750-ipbase-mz.122-35.SE5/c3750-ipbase-mz.122-35.SE5.bin" uncompressed and installed, entry point: 0x3000

executing...
(原來NME模組上有自已的IOS耶~)

Step.5 設定新密碼
Would you like to enter the initial configuration dialog? [yes/no]: no
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#enable password Mypass123
Switch(config)#exit
Switch#write
Switch#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
Switch#reload

2011年6月1日 星期三

Fortinet的Password Recovery


如果實體能存取的到設備,只要接上Console就能重設admin的密碼,
方式如下:


輸入帳號:maintainer
密碼:bcpb(Forti的序號)
(如: bcpbFGT50A2905408509)

進去後改掉密碼:
config system admin
edit admin
set password
end

再輸入:
show system interface
了解現在ip後就可重WEB登入管理了^^