2013年7月23日 星期二

每日自動備份 Fortigate 設定檔


For v5.0,build0252 (GA Patch 5)
首先在 Fortigate上面建立一個名為backup的使用者,密碼為YourPassword,權限設定如下:





















然後在 Linux 建立 sh 並賦予執行權限和建立排程,檔案內容如下:
(範例中的備份伺服器是使用 tftp)

#!/bin/bash
user="backup"
password="YourPassword"
tftp_ip="YourBackupServerIP"
fg_devices="YourFortigateIP"
date="$(date +"%Y%m%d")"
for fg_device in $fg_devices ; do
  expect -c "
  set timeout 30
  spawn ssh $user@$fg_device
  expect \"(yes/no)\" { send \"yes\r\"; exp_continue }
  expect \"*password:*\"
  set send_slow {1 0.05}
  send -s \"$password\r\"
  send_user \"$password\r\"
  expect \"FG*\"
  send -s \"execute backup full-config tftp $fg_device-$date.cfg $tftp_ip\n\"
  expect \"FG*\"
  send -s \"exit\n\"
  interact"
done


2013年7月16日 星期二

Aruba 認證出現問題 "Web Authentication Disabled, Please contact Administrator"

發生原因:
不詳。

解法:
進管理畫面的 clients 選擇 user 然後 disconnect。

2013年7月1日 星期一

解決 FortiAnalyzer-400B 日誌查看停在某一天, 但是LOG檔還是會有紀錄的問題。

在 CLI 執行 #execute sql-local rebuild-db

FortiAnalyzer-~# execute sql-local rebuild-db
Rebuild the whole SQL database has been requested.
This operation will remove the SQL database and rebuild from log data.
This operation will reboot the device.
Do you want to continue? (y/n)


等待重開機,再重新登入後右上會出現 build database 的圖示。

雖說筆者做完之後LOG資料還會存在,但是建議能備份就備份下來。

2013年4月15日 星期一

VMware vSphere 移除 Storage 問題

當使用 vCenter 要移除 iSCSI Storage 時,會出現 No virtual machine resides on the datastore
官網的 Knowledge Base 解決辦法是移除所有的 Snapshot 。
但是筆者移除後還是出現這個訊息,後來就把所有的 Virtual Machine 用 remove from inventory 指令移除後就可以順利把 iSCSI Storage 給 unmount 了。

2013年3月5日 星期二

使用 Expect 備份網路設備設定檔 for Extreme


支援 Extreme DB8800系列、X450a系列、X460系列

#!/usr/bin/expect -f

if { $argc != 4 } {
        send_user "usage: extreme.exp device_ip username password server_ip \n"
        exit
}

set timeout 1
set TERM ANSI
set date [exec date +%Y%m%d]

set DEVICE [lindex $argv 0]
set USERNAME [lindex $argv 1]
set PASSWD [lindex $argv 2]
set SERVER [lindex $argv 3]

spawn telnet
expect "telnet> "
send "open $DEVICE\r"
sleep 1
expect "login:"
send "$USERNAME\r"
sleep 1
expect "password:"
send "$PASSWD\r"
sleep 1
expect "#"
send "upload configuration $SERVER $DEVICE-$date vr VR-Default\r"
sleep 3
expect "#"
send "exit\r"
interact

使用 Expect 備份網路設備設定檔 for HP


支援 HP ProCurve Switch 2610系列、2510系列

#!/usr/bin/expect -f

if { $argc != 4 } {
        send_user "usage: hp.exp device_ip username password server_ip \n"
        exit
}

set timeout 1
set TERM ANSI
set date [exec date +%Y%m%d]

set DEVICE [lindex $argv 0]
set USERNAME [lindex $argv 1]
set PASSWD [lindex $argv 2]
set SERVER [lindex $argv 3]


spawn telnet
expect "telnet> "
send "open $DEVICE\r"
sleep 1
expect continue { send "\r" ; exp_continue }
sleep 1
expect "Username:"
send "$USERNAME\r"
sleep 1
expect "Password:"
send "$PASSWD\r"



sleep 1
send "\r\r"
expect "#"
send "copy running-config tftp $SERVER $DEVICE-$date\r"
sleep 1
expect "#"
send "exit\r"
sleep 1
expect ">"
send "exit\r"
sleep 1
expect "Do you want to log out"
send "y\r"
interact



2013年1月3日 星期四

Extreme 教學

限制 telent access:
#edit policy mytelnet.pol
entry Telnet_Allow {
if match any {
        source-address 192.168.1.0 /24;
        source-address 192.168.2.0 /24;
                } then {
                        permit;
}
}

# configure telnet access-profile mytelnet

若 source-address 有變動執行
# refresh policy "mytelnet"





IP-MAC blind:
add:
#configure iparp add 123.123.123.123 vr VR-Default 00:11:22:33:44:55
del
#configure iparp delete 123.123.123.123 vr VR-Default 00:11:22:33:44:55

設定檔備份:
#upload configuration 123.123.123.123 backupFileName vr "VR-Default"


清除 trial-license:

enable trial-license
#debug epm enable trial-license
remove trial-license
#debug epm clear trial

回覆出廠預設值:
#unconfigure  switch all

另外一個方法
使用console連線

1. 重開機出現Running POST的時候按住空白鍵。
2. POST完成之後會進入boot rom模式。 
3. 在提示符號下輸入: 
#Config abc  (abc指的是隨便一個檔名,目的在使系統找不到檔案後開機時load default) 
4. 輸入Boot後按enter。 
系統重開之後就回預設值,所有的設定都會不見。 


LACP

8810 config
enable sharing 2:47 grouping 2:47-48 algorithm address-based L2
第一個「2:47」為主要port,後面的「2:47-48」為群組。

X450 config
enable sharing 23 grouping 23-24 algorithm address-based L2 lacp

查看
show lacp lag 1

解除設定
disable sharing 2:47

備份、升級韌體
download image [<hostname> | <ipaddress>] <filename> {primary | secondary}
upload image [<hostname> | <ipaddress>] <filename> {primary | secondary}
use image [primary | secondary]