顯示具有 Network Admin 標籤的文章。 顯示所有文章
顯示具有 Network Admin 標籤的文章。 顯示所有文章

星期三, 12月 01, 2010

常用網路檢測工具備忘筆記

常用軟體與指令:

節點檢查:
ping
traceroute (BSD)
tracert (Win)
MTR (BSD)
WinMTR (Win)

流量檢測:
iftop (BSD)
trafshow (BSD)
slurm (BSD)
ntop (WEB)

DNS 檢查:
nslookup (BSD)
dig (BSD)
doc (BSD)

封包檢查:
tcpdump (BSD)
Ethereal/Wireshark (Win)

其他:
netcat (BSD):可讀寫 tcp/upd 連線。
nmap (BSD) :可掃描網路安全,通常用來掃 port 用。

某些工具用法實例:
http://sonic.net/support/faq/advanced/troubleshooting.shtml

星期三, 11月 24, 2010

CISCO switch/router 與 ntop 配合監視網路流量的方法

CISCO switch/router 與 ntop 配合監視網路流量的方法

ntop 是一個流量監控程式 http://www.ntop.org/

* ntop 主機 http://192.168.1.1:3000 (FreeBSD Server)
* switch 為 CISCO GSR 12012 (機器名稱為 sw1)


(1) 先在 switch/router上做一些設置

在 IOS 下這個指令:

sw1# show ip flow export

Flow export is enabled
Exporting flows to 192.168.1.1 (2055)
Exporting using source interface POS4/0 <---------(重點)
Version 5 flow records
774916459 flows exported in 25831727 udp datagrams
0 flows failed due to lack of export packet
0 export packets were sent up to process level
0 export packets were dropped due to no fib
0 export packets were dropped due to adjacency issues
0 export packets were dropped due to fragmentation failures
0 export packets were dropped due to encapsulation fixup failures
0 export packets were dropped enqueuing for the RP
739 export packets were dropped due to IPC rate limiting
9241 export packets were dropped due to output drops


(2) 看是否為要監聽的 source, 若不是;

則在以下命令列下:(假設要監聽這個interface)

sw1(config)#ip flow-export source pos3/2


則在(1)步驟所列的(重點)會顯示為:

Exporting using source interface POS3/2 <---------(重點)


(3) 然後再進入 interface POS3/2 做設定:

sw1(config-if)#ip route-cache flow


(4) 進入 ntop 網頁, http://192.168.1.1:3000

上方的 Admin 選項 , 選 Switch NIC 進入頁面

點選已經設定好的 switch1 按 Switch NIC



(5) 點選上方 IP 選項, 選 Summary 選項, Traffic

然後看排序的最上方, 就知道兇手是誰了.


(補充一點,若是新加主機,務必對應到 ip&連接阜)

例:
sw1(config)#ip flow-export version 5
sw1(config)#ip flow-export destination 192.168.1.1(ntop主機ip) 2055(port)

星期一, 7月 06, 2009

Layer L2/L3/L4 switch 的定義

Layer L2/L3/L4 switch 的定義:

The "Layer" Based on OSI Layer:

A Layer 3 switch performs the function of layer 2 switch which learns,
filters and forwards based on the MAC address, operate on every single
port. But layer 3 includes the ability to examine the IP address.

A Layer 4 switch has the ability to not only examine the IP address but also
to control the traffic based on the port numbers located at Layer 4 of the
OSI model. It is almost similar to a router but with a much higher speed of
data throughput using hardware (ASICs). Layer 4 switch is more intelligent
as it can give priority to data intended for mission critical appl such as
HTTP (port 80) appl on a web server at the same time running less critical
appl on the same server. All these is made possible because it can see both
the port number and IP address of a data packet.

星期四, 2月 15, 2007

How-to Log Cisco Router/Switch with FreeBSD

How-to Log Cisco Router/Switch with FreeBSD

一般來說,安裝完 FreeBSD 之後系統就會有 syslog daemon,不過預設的那個 syslog 功能蠻陽春的,所以我們改用 syslog-ng 來替換原來的 syslog。

Step.1:
在 FreeBSD 上用 ports 安裝 syslog-ng:
cd /usr/ports/sysutils/syslog-ng
make install clean
修改 rc.conf 置換預設的 syslogd:

syslogd_enable="NO"
syslog_ng_enable="YES"
Step.2:
設定 syslog-ng:
cd /usr/local/etc/syslog-ng
cp syslog-ng.conf.sample syslog-ng.conf
vi syslog-ng.conf
基本上前面那堆設定都不用去改,在最後面加上如下設定:
(這個範例是兩台機器,一台叫 core 1 是在 192.168.1.1,另一台叫 core 2 在 192.168.1.2,這個設定是在真正運作中的設定取出兩台當範例的,完整的設定實際上是記錄十幾台機器)
### Cisco Routers, Switches ###

# core 1
destination core1.tpe { file("/var/log/cisco/core1.log"); };
filter f_core1.tpe { host("^192.168.1.1$"); };
log { source(src); filter(f_local7); filter(f_core1.tpe); destination(core1.tpe); };

# core 2
destination core2.tpe { file("/var/log/cisco/core2.log"); };
filter f_core2.tpe { host("^192.168.1.2$"); };
log { source(src); filter(f_local7); filter(f_core2.tpe); destination(core2.tpe); };
然後 touch 空檔案來做記錄,如此例中請用:
touch /var/log/cisco/core1.log
touch /var/log/cisco/core2.log
Step.3:
然後到 Cisco 的 Router 與 Switch 裡設定:
假設 log server 主機在 192.168.2.1 裡,你還必須要有 lv15 的權限:
conf t
logging 192.168.2.1
logging on
end
exit
這樣就可以了。

如果要知道更多詳細的設定請參考:
http://www.cisco.com/univercd/cc/td/doc/product/software/ios11/dbook/dintro.htm
http://www.gentoo.tw/got-doc/syslog-ng.xml
http://www.campin.net/syslog-ng/faq.html

星期二, 12月 12, 2006

FreeBSD 上的 TACACS+ Server for Cisco NAS

術語解釋:
TACACS --- Terminal Access Controller Access Control System 終端存取控制器存取控制系統。
AAA ---
Authentication、Authorization、Accounting 認證、授權、記帳。
NAS --- Network Access Server,會向 TACACS+ 要求認證(AAA)需求的『客戶端』伺服器,如 CISCO Router、Switch、Server 等等。
daemon -- 提供 TACACS+ AAA 服務的行程。
passwd(5) files -- Unix 密碼格式檔案,請參照 Unix 手冊中的文件第5段。
AV pairs -- 在 NAS 和 tacacs+ daemon 之間傳遞格式如
"attribute=value" 的一組文字,是 Tacacs+ 傳輸協定的一部份。

因為要求 Tacacs+ AAA 的機器本身很有可能也是伺服器,為了避免混淆,所以我們不用 Server 來稱呼提供 Tacacs+ 服務的機器,而是用 Daemon(Server) 與 NAS(Client) 來表示 Server/Client。

TACACS 介紹:
目前一般人提及的 TACACS 認證協定至少有三種版本。第一種就是傳統的 TACACS,最先是在 Cisco 的設備上使用多年的。第二種叫做 XTACACS 則是在 1990 發展出來,是 TACACS 的擴展版本。第三種則是 TACACS+,也是目前通用的版本,但是這個版本和舊版本的 TACACS 是完全不相容的。

tac_plus:
tac_plus 是一個 freeware,可以在大多數的類 Unix 的環境上找到,tac_plus 可以使用內建的資料庫、s/key 或 passwd(5) 格式的檔案,除此之外也可以透過 LDAP 或 RADIUS 由外部取得認證。

Step.1
在 FreeBSD 上,我們可以直接使用 ports 來安裝:
cd /usr/ports/net/tac_plus4
make install clean
Step.2
將 /usr/local/etc/tac_plus.conf.example 複製一份來修改:
cd /usr/local/etc
cp tac_plus.conf.example tac_plus.conf
vi tac_plus.conf
Step.3
tac_plus.conf 的內容:
#自定義用來跟 router 溝通的 key
key = "I think therefor I am"

# log 檔路徑
accounting file = /var/log/tac.log

user = irene {
login = des H9rhDCGdkjVG2
service = exec {
priv-lvl = 15
}
}

user = daisy {
login = cleartext "lollipop%@)"
service = exec {
priv-lvl = 1
}
}

user = $enab15$ {
login = des $1$tBwWeG3L$viCdJZu4gLw7zQBPOysGu0
}
NOTE: 密碼可以使用明文(plain text)或是 des 編碼,des 編碼可以用 tac_pwd -e 來產生。

Step.4
到 Cisco Router/Switch 上設定:
測試過的型號: GSR 12012、GSR 12008、7204 VXR、C2950。
IOS 版本:Version 12.0(21)S7, EARLY DEPLOYMENT RELEASE SOFTWARE (fc2)
tacacs-server host 192.168.1.100
tacacs-server key I think therefor I am
aaa new-model
aaa authentication login default tacacs+ local
aaa authorization exec default tacacs+ local
aaa accounting exec default start-stop tacacs+
aaa accounting commands 15 default stop-only tacacs+
aaa accounting network default start-stop tacacs+
aaa accounting connection default start-stop tacacs+
aaa accounting system default start-stop tacacs+
其他資訊請參考 Cisco 官網: http://www.cisco.com/warp/public/480/tacplus.shtml