2010年4月17日 星期六
網路效能測試工具: iperf
iperf
Shell Script: 每日檢查硬碟的使用量,當到達90%時寄出Alert mail給root
#!/bin/bash
df -h | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 90 ]; then
echo "Running out of space "$partition $usep%" on $(hostname) as on $(date)" | mail -s "Alert: Almost out of disk space $usep%" root
fi
done
2. # chmod 755 diskspace.sh
3. # crontab -e
-> 10 5 * * * /root/bin/diskspace.sh
這個範例用了 grep,awk與cut指令來實作,可以見得它們有多好用了 :)
參考來源: http://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html
Bind view
整 個named.conf的架構舉例如下:
22 view "intranet" {
23 match-clients {"192.168.1.0/24";};
24 zone "." IN {
25 type hint;
26 file "named.root";
27 };
28
29 zone "localdomain." IN {
30 type master;
31 file "localdomain.zone";
32 allow-update { none; };
33 };
34
35 zone "localhost." IN {
36 type master;
37 file "localhost.zone";
38 allow-update { none; };
39 };
40
41 zone "0.0.127.in-addr.arpa." IN {
42 type master;
43 file "named.local";
44 allow-update { none; };
45 };
46
47 zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa." IN {
48 type master;
49 file "named.ip6.local";
50 allow-update { none; };
51 };
52
53 zone "255.in-addr.arpa." IN {
54 type master;
55 file "named.broadcast";
56 allow-update { none; };
57 };
58
59 zone "0.in-addr.arpa." IN {
60 type master;
61 file "named.zero";
62 allow-update { none; };
63 };
64
65 zone "example.com" {
66 type master;
67 file "example.com.zone";
68 };
69 };
70
71
72 view "internet" {
73 match-clients {"!192.168.1.0/24";};
74 zone "." IN {
75 type hint;
76 file "named.root";
77 };
78
79 zone "localdomain." IN {
80 type master;
81 file "localdomain.zone";
82 allow-update { none; };
83 };
84
85 zone "localhost." IN {
86 type master;
87 file "localhost.zone";
88 allow-update { none; };
89 };
90
91 zone "0.0.127.in-addr.arpa." IN {
92 type master;
93 file "named.local";
94 allow-update { none; };
95 };
96
97 zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa." IN {
98 type master;
99 file "named.ip6.local";
100 allow-update { none; };
101 };
102
103 zone "255.in-addr.arpa." IN {
104 type master;
105 file "named.broadcast";
106 allow-update { none; };
107 };
108
109 zone "0.in-addr.arpa." IN {
110 type master;
111 file "named.zero";
112 allow-update { none; };
113 };
114 };
115
116 include "/etc/rndc.key";
其實就是多了
view "internet" {
match-clients {"!192.168.1.0/24";};
};
與
view "intranet" {
match-clients {"192.168.1.0/24";};
};
在這兩個區域內設定相關的zone/zone file就可以了。
queryperf: 測試DNS Server的效能/壓力工具
使用的語法也不難主要如下:
./queryperf -d -s
-d 是讀取測試RR文檔的意思
-s 是指定所要測試的DNS Server
RR_document的格式也是很簡單的,請參考以下 範例:
server1.example.com A -> query server1.example.com A Record
example.com MX -> query example.com domain mx Record
mail.example.com CNAME -> query mail.example.com CNAME
server1.example.com TXT -> query server1.example.com TXT Record
example.com TXT -> query example.com domain TXT Record
example.com NS -> query example.com domain NS Record
100.10.10.10.in-addr.arpa PTR -> query 10.10.10.100 PTR Record
101.10.10.10.in-addr.arpa PTR -> query 10.10.10.101 PTR Record
Note: ->是說明,不需要加入到RR_document
執行結果:
Statistics:
Parse input file: once
Ended due to: reaching end of file
Queries sent: 8 queries
Queries completed: 8 queries
Queries lost: 0 queries
Queries delayed(?): 0 queries
RTT max: 0.033874 sec
RTT min: 0.013128 sec
RTT average: 0.023992 sec
RTT std deviation: 0.007508 sec
RTT out of range: 0 queries
Percentage completed: 100.00%
Percentage lost: 0.00%
Started at: Mon Aug 25 03:33:47 2008
Finished at: Mon Aug 25 03:33:47 2008
Ran for: 0.034861 seconds
Queries per second: 229.482803 qps
緊接著來寫個簡單的script讓他不斷的執行 queryperf吧!
#!/bin/bash
while true
do
./queryperf -d dnstest -s $1 -v
done
把DNS所有的RR都寫入RR_document,這麼一來,就可以來試看看你的DNS Server耐不耐操了 XD!
2010年4月5日 星期一
cisco switch configure
草草寫完,如果誤謬,望期指正..
交換機cisco1900
設定ip
en
conf t
ip address 210.60.166.253 255.255.255.0
no shutdown
設定預設閘道
ip default-gateway 210.60.166.254
show ip
show interface
show interface ethernet 0/2
列出mac table
show mac-address-table
限制mac table量
en
conf t
interface ethernet 0/1
port secure max-mac-count 20
取消限制mac table量
en
conf t
interface ethernet 0/1
no port secure
查看所設定mac table量
show mac-address-table security
更改交換機主機名稱
en
conf t
hostname test
查看spanning tree protocol的資訊
show spantree
查看cdp相關資訊
show cdp
查看其他相連的交換機設備
show cdp neighbors
查看歷史紀錄
show history
查看vlan
show vlan
設定port的全雙模式
en
duplex ?
duplex [auto|full|full-flow-control|haft]
使vtp還原為預設值
delete vtp
新增vlan
en
conf t
vlan 100 name vlan100
vlan [編號] name [名稱]
將某個port加入vlan100
en
conf t
interface e0/1
vlan-membership static 100
查看編號100的vlan
show vlan 20
查看vtp的設定
show vtp
設定vtp 的 domain
vtp domain [domain]
vtp domain denny
設定vtp的密碼
en
vtp password [password]
設定vtp的模式
vtp server
vtp client
vtp transparent
開啟trunk
en
conf t
interface ethernet 0/24
trunk on
trunk off
--------------------------------------------------------
switch 2900 3500
設定vlan的domain與password
en
vlan database
vtp domain denny password denny
vtp server
查看vtp參數
show vtp ?
配置靜態vlan
en
vlan database
vlan name
exit
conf t
int fa 0/1
switchport mode access
switchport access vlan 將port設定在某個vlan上
為交換機上配置的vlan設置trunk
en
conf t
int fa 0/24
switchport mode trunk
switchport trunk encapsulation [isl|dot1q]
switchport trunk allowed vlan remove
switchport trunk allowed vlan add
設定介面為trunk模式
要讓多個vlan資訊通過此介面
en
conf t
int fa0/23
switchport mode trunk
為每個vlan設定ip位置
en
conf t
int vlan 30
ip address 210.60.166.220 255.255.255.0
Extreme設備實作ACL
Access-mask Configuration
Access-list Configuration
for example deny 192.168.100.22
# Access-mask Configuration
create access-mask ip_src_mask source-ip / 32
create access-mask destl4_port_mask ip-protocol dest-L4port
#
#before configure "access-list" command ,you have to configure "access-mask" command
# Access-list Configuration
create access-list denyudp135 access-mask destl4_port_mask ip-protocol 17 dest-L4port 135 deny
create access-list denytcp135 access-mask destl4_port_mask ip-protocol 6 dest-L4port 135 deny
create access-list denyudp445 access-mask destl4_port_mask ip-protocol 17 dest-L4port 445 deny
create access-list denytcp445 access-mask destl4_port_mask ip-protocol 6 dest-L4port 445 deny
#for example deny 192.168.100.22
create access-list deny100_22 access-mask ip_src_mask source-ip 192.168.100.22 / 32 deny
Extreme設備實作load sharing
可利用load sharing作備援線路
load sharing
可利用load sharing作備援線路
enable sharing <port> grouping <portlist> {algorithm {port-based | address-based |round-robin}}
disable sharing [<port>]
enable sharing 25 grouping 25,26 algorithm address-based
BD的ios支援較多的演算法
enable sharing 1:28 grouping 1:28 , 1:29 algorithm address-based