OS: CentOS 5.5
Nagios: nagios-3.2.3-3.el5.rf.i386
這篇是關於Nagios Plugin Check_SNMP中關於--rate指令的使用方式。
如果你是用YUM或是apt等方式安裝的Nagios,可能在使用check_snmp的--rate選項的時候會發生錯誤。
原因是因為check_snmp在儲存rate的狀態的時候,會除存在/var/check_snmp裡面,而extinfo.cgi確無法在開啟檔案,原因是目錄建立的時候,使用者及群組不是nagios(或你自訂的群組),權限也只有700。
所以將使用者及群組改成nagios(或你自訂的群組),權限也修改成755(或你覺得安全權限)。
裡面如果原本就有檔案的話,也請將使用者及群組改成nagios(或你自訂的群組),權限640即可。想省事一點可以把檔案全砍了,反正重新建立也不會有啥影響。之後重新啟動nagios就會正常。
2011/02/22
2011/02/16
CentOS Yum Repo
CentOS預設安裝的Yum有蠻多東西都沒有的。
所以下面是幾個目前常用的repo及安裝方式。
1.remi
wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
2.rpmforge
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.i386.rpm
3.IUS
wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-8.ius.el5.noarch.rpm
rpm -Uvh ius-release*.rpm
PS:請注意上面是i386版本,若是64bit版的,必須把i386的字串改為x86_64。
PS2:RHEL已經有6版了,但不建議在系統不是6版的狀況下裝6版的repo。
2012/07/02 redhar的域名修正
所以下面是幾個目前常用的repo及安裝方式。
1.remi
wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
2.rpmforge
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.i386.rpm
3.IUS
wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-8.ius.el5.noarch.rpm
rpm -Uvh ius-release*.rpm
PS:請注意上面是i386版本,若是64bit版的,必須把i386的字串改為x86_64。
PS2:RHEL已經有6版了,但不建議在系統不是6版的狀況下裝6版的repo。
2012/07/02 redhar的域名修正
2011/02/15
Wireshark的cli版 tshark
TShark 1.0.15
Dump and analyze network traffic.
See http://www.wireshark.org for more information.
Copyright 1998-2010 Gerald Combs and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Usage: tshark [options] ...
Capture interface:
-i name or idx of interface (def: first non-loopback)
-f packet filter in libpcap filter syntax
-s packet snapshot length (def: 65535)
-p don't capture in promiscuous mode
-y link layer type (def: first appropriate)
-D print list of interfaces and exit
-L print list of link-layer types of iface and exit
Capture stop conditions:
-c stop after n packets (def: infinite)
-a ... duration:NUM - stop after NUM seconds
在幾秒後停止
filesize:NUM - stop this file after NUM KB
在檔案大小為幾KB後停止
files:NUM - stop after NUM files
在幾個檔案後停止
Capture output:
-b ... duration:NUM - switch to next file after NUM secs
在幾秒後換新檔案
filesize:NUM - switch to next file after NUM KB
在檔案大小為幾KB後換新檔案
files:NUM - ringbuffer: replace after NUM files
在幾次後後換覆蓋檔案(類似logrotate的功能)
Input file:
-r set the filename to read from (no pipes or stdin!)
Processing:
-R packet filter in Wireshark display filter syntax
-n disable all name resolutions (def: all enabled)
-N enable specific name resolution(s): "mntC"
-d==, ...
"Decode As", see the man page for details
Example: tcp.port==8888,http
Output:
-w set the output filename (or '-' for stdout)
將抓到的資料存放到 (或輸入 '-' 來輸出到stdout也就是顯示在螢幕上)
-C start with specified configuration profile
-F
Dump and analyze network traffic.
See http://www.wireshark.org for more information.
Copyright 1998-2010 Gerald Combs
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Usage: tshark [options] ...
Capture interface:
-i
-f
-s
-p don't capture in promiscuous mode
-y link layer type (def: first appropriate)
-D print list of interfaces and exit
-L print list of link-layer types of iface and exit
Capture stop conditions:
-c
-a
在幾秒後停止
filesize:NUM - stop this file after NUM KB
在檔案大小為幾KB後停止
files:NUM - stop after NUM files
在幾個檔案後停止
Capture output:
-b
在幾秒後換新檔案
filesize:NUM - switch to next file after NUM KB
在檔案大小為幾KB後換新檔案
files:NUM - ringbuffer: replace after NUM files
在幾次後後換覆蓋檔案(類似logrotate的功能)
Input file:
-r
Processing:
-R
-n disable all name resolutions (def: all enabled)
-N
-d
"Decode As", see the man page for details
Example: tcp.port==8888,http
Output:
-w
將抓到的資料存放到 (或輸入 '-' 來輸出到stdout也就是顯示在螢幕上)
-C
-F
2010/12/10
2010/11/17
[PHP]解決網站被 SQL injection 攻擊
其實這個安全性的問題,在目前台灣網站都存在這樣的問題,大家平常用 $_POST,$_GET 用得很順利,但是沒有想過帳號密碼被 SQL injection 破解,當網站被破解了,基本上你損失就是相當嚴重,網路上也有很多攻擊方式,不過這方法是最常被拿出來講的,我自己有一套解決方式,除了比較重要的地方,就是輸入帳號密碼的地方要加強防護之外,加上數字驗證碼,還要 check 帳號的特性,我底下是我驗證帳號密碼機制
上面可以解決帳號只能輸入數字加上英文,然後底下在過濾很多特殊字元加上 addslashes 或者是用 mysql_escape_string()
上面那段,可以避免利用特殊字元做 SQL injection 攻擊,這部份程式碼是我去 trace PHPBB2 code 裡面寫的^^。
文章來源:[PHP]解決網站被 SQL injection 攻擊
if($user_name == '' || $user_passwd == ''){
ErrMsg("帳號或密碼不得空白");
}
if (!preg_match('/^\w+$/', $user_name)){
ErrMsg("請勿攻擊本站台");
}
上面可以解決帳號只能輸入數字加上英文,然後底下在過濾很多特殊字元加上 addslashes 或者是用 mysql_escape_string()
if( !get_magic_quotes_gpc() )
{
if( is_array($_GET) )
{
while( list($k, $v) = each($_GET) )
{
if( is_array($_GET[$k]) )
{
while( list($k2, $v2) = each($_GET[$k]) )
{
$_GET[$k][$k2] = addslashes($v2);
}
@reset($_GET[$k]);
}
else
{
$_GET[$k] = addslashes($v);
}
}
@reset($_GET);
}
if( is_array($_POST) )
{
while( list($k, $v) = each($_POST) )
{
if( is_array($_POST[$k]) )
{
while( list($k2, $v2) = each($_POST[$k]) )
{
$_POST[$k][$k2] = addslashes($v2);
}
@reset($_POST[$k]);
}
else
{
$_POST[$k] = addslashes($v);
}
}
@reset($_POST);
}
if( is_array($_COOKIE) )
{
while( list($k, $v) = each($_COOKIE) )
{
if( is_array($_COOKIE[$k]) )
{
while( list($k2, $v2) = each($_COOKIE[$k]) )
{
$_COOKIE[$k][$k2] = addslashes($v2);
}
@reset($_COOKIE[$k]);
}
else
{
$_COOKIE[$k] = addslashes($v);
}
}
@reset($_COOKIE);
}
}
上面那段,可以避免利用特殊字元做 SQL injection 攻擊,這部份程式碼是我去 trace PHPBB2 code 裡面寫的^^。
文章來源:[PHP]解決網站被 SQL injection 攻擊
2010/11/14
2010/11/12
如何Windows2003中建立智能DNS服务器
如何Windows2003中建立智能DNS服务器(BIND,附配置文件下载) - [Windows]
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://iamsam.blogbus.com/logs/29402246.html
前言
随着原中国电信集团按南北地域分家,新的中国电信和网通集团随即成立,互联网的骨干网也被一分为二了,北有网通、南有电信。从此,细心的网民可以发现,有些经常访问的网站速度一下子慢了下来,有时候还有访问不到的情况出现。例如北方地区的网络用户访问中国网通的服务器会非常快,而访问中国电信的服务器时,感觉非常慢。这种现象不仅影响了网站的访问量,更严重的是它直接影响了一些经营性网站的经济效益。据分析,产生这个问题的根本原因是中国电信分家之后,电信与网通之间的互连存在问题。虽然信息产业部已经在规划南北互通计划,但在今后相当长的一段时期内,南北方网互连的问题还会长期存在。
解决方案
智能DNS策略解析很好的解决了上面所述的问题。DNS策略解析最基本的功能是可以智能的判断访问您网站的用户,然后根据不同的访问者把您的域名分别解析成不同的IP地址。如访问者是网通用户,DNS策略解析服务器会把你的域名对应的网通IP地址解析给这个访问者。如果用户是电信用户,DNS策略解析服务器会把您域名对应的电信IP地址解析给这个访问者。
智能DNS策略解析还可以给你的多个主机实现负载均衡,这时来自各地的访问流量会比较平均的分布到你的每一个主机上。
软件的相关资源
官方网站: http://www.bind.com/
最新版本: 9.3.2 http://www.isc.org/index.pl?/sw/bind/view/?release=9.3.2-P2
帮助文档: http://www.isc.org/sw/bind/
配置文件样例: http://www.bind.com/bind.html
实施步骤:
1。 WINDOWS 2003 服务器
2。使用BIND9做智能DNS,自动根据客户端IP来判断,网通的用户解析出网通的IP,电信的解析出电信IP
测试做的域名
www.dnsany.com
电信IP 60.171.45.152
网通IP 220.248.236.152
电信用户PING www.dnsany.com会解析到60.171.45.152
网通用户PING www.dnsany.com会解析到220.248.236.152
配置步骤:
1.BIND 9.3.2
http://ftp.isc.org/isc/bind9/9.3.2-P2/BIND9.3.2-P2.zip
2. 安装BIND 9 .3.2
解压到一个临时目录,而后运行 BINDInstall.exe,一直默认安装就行了,不需要更改什么设置。
默认安装到 \windows\system32\dns目录下
3.配置
运行CMD进入安装目录(\windows\system32\dns)下面的bin目录,而后运行
rndc-confgen -a (运行完成后会在etc目录下生成rndc.key)
rndc-confgen > ..\etc\rndc.conf
进入etc目录,用 notepad 新建 named.conf 复制下面的内容,注意把rndc.conf中# Use with the following in named.conf, adjusting the allow list as needed: 以后的内容复制到named.conf文件中,去掉全面的#。
named.conf
######################named.conf############################
acl "trust-lan" { 127.0.0.1/8; 10.0.0.0/24;};
options {
directory "C:\WINDOWS\system32\dns\etc";
recursion no;
version "0.0.0";
allow-transfer { "trust-lan";};
allow-notify { "trust-lan"; };
auth-nxdomain no;
forwarders { 60.171.45.171;60.171.45.150;};
};
#这一段内容拷贝来自rndc.conf
key "rndc-key" {
algorithm hmac-md5;
secret "p30d5VTh6iP+QBiVsEI0lw==";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
#注意在C:\WINDOWS\system32\dns\log\ 下建dns_warnings.txt dns_logs.txt
logging {
channel warning
{ file "C:\WINDOWS\system32\dns\log\dns_warnings.txt" versions 3 size 1240k;
severity warning;
print-category yes;
print-severity yes;
print-time yes;
};
channel general_dns
{ file "C:\WINDOWS\system32\dns\log\dns_logs.txt" versions 3 size 1240k;
severity info;
print-category yes;
print-severity yes;
print-time yes;
};
category default { warning; };
category queries { general_dns; };
};
#将网通的地址范围数据
include "cnc.conf";
# 判断如果是网通的地址范围,则会执行此处,调用网通的解析
view "view_cnc" {
match-clients { CNC; };
zone "." {
type hint;
file "named.root";
};
zone "0.0.127.IN-ADDR.ARPA" {
type master;
file "localhost.rev";
};
include "master/cnc.def";
};
view "view_any" {
match-clients { any; };
zone "." {
type hint;
file "named.root";
};
zone "0.0.127.IN-ADDR.ARPA" {
type master;
file "localhost.rev";
};
include "master/telecom.def";
};
###################### named.conf############################
用notepad 新建 cnc.conf复制下面的内容
###################### cnc.conf############################
# jul/14/2006 09:44:25 by coolice
# software id = EFTB-IZN
#
acl "CNC" {
58.16.0.0/16;
58.17.0.0/17;
60.12.0.0/16;
222.163.128.0/17;
219.235.56.194;
};
###################### cnc.conf############################
用notepad 新建 named.root复制下面的内容
###################### named.root############################
; This file holds the information on root name servers needed to
; initialize cache of Internet domain name servers
; (e.g. reference this file in the "cache . "
; configuration file of BIND domain name servers).
;
; This file is made available by InterNIC
; under anonymous FTP as
; file /domain/named.root
; on server FTP.INTERNIC.NET
; -OR- RS.INTERNIC.NET
;
; last update: Jan 29, 2004
; related version of root zone: 2004012900
;
;
; formerly NS.INTERNIC.NET
;
. 3600000 IN NS A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
;
; formerly NS1.ISI.EDU
;
. 3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 192.228.79.201
;
; formerly C.PSI.NET
;
. 3600000 NS C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12
;
; formerly TERP.UMD.EDU
;
. 3600000 NS D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET. 3600000 A 128.8.10.90
;
; formerly NS.NASA.GOV
;
. 3600000 NS E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10
;
; formerly NS.ISC.ORG
;
. 3600000 NS F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241
;
; formerly NS.NIC.DDN.MIL
;
. 3600000 NS G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET. 3600000 A 192.112.3***
;
; formerly AOS.ARL.ARMY.MIL
;
. 3600000 NS H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53
;
; formerly NIC.NORDU.NET
;
. 3600000 NS I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
;
; operated by VeriSign, Inc.
;
. 3600000 NS J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30
;
; operated by RIPE NCC
;
. 3600000 NS K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
;
; operated by ICANN
;
. 3600000 NS L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET. 3600000 A 198.32.64.12
;
; operated by WIDE
;
. 3600000 NS M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33
; End of File
###################### named.root############################
新建master文件夹 并在里面新建cnc 和 telecom 文件夹
进入masrer文件夹 用notepad 新建cnc.def 和telecom.def
###################### cnc.def############################
zone "dnsany.com" {
type master;
file "C:\WINDOWS\system32\dns\etc\master\cnc\dnsany.com.txt";
};
###################### cnc.def############################
###################### telecom.def############################
zone "dnsany.com" {
type master;
file "C:\WINDOWS\system32\dns\etc\master\telecom\dnsany.com.txt";
};
###################### telecom.def############################
分别进入cnc和telecom文件夹建立dnsany.com.txt文件
#########################cnc\dnsany.com.txt##############################
$TTL 3600
$ORIGIN dnsany.com.
@ IN SOA ns.joysp.com. root. joysp.com.(
2006111520 ;Serial
3600 ; Refresh ( seconds )
900 ; Retry ( seconds )
68400 ; Expire ( seconds )
15 );Minimum TTL for Zone ( seconds )
;
@ IN NS ns.joysp.com.
@ IN A 220.248.236.152
www IN A 220.248.236.152
* IN A 220.248.236.152
;
;end
#########################cnc\dnsany.com.txt##############################
#########################telecom\dnsany.com.txt##############################
$TTL 3600
$ORIGIN dnsany.com.
@ IN SOA ns.joysp.com. root. joysp.com.(
2006111520 ;Serial
3600 ; Refresh ( seconds )
900 ; Retry ( seconds )
68400 ; Expire ( seconds )
15 );Minimum TTL for Zone ( seconds )
;
@ IN NS ns.joysp.com.
@ IN A 60.171.45.152
www IN A 60.171.45.152
* IN A 60.171.45.152
;
;end
#########################telecom\dnsany.com.txt##############################
全部配置完成后,可以进入Windows 服务管理器,找到那个叫 ISC Bind的服务,而后属性更改登陆为本地系统用户选择启动,如果出现错误,请打开你的事件查看器,到应用程序部分看看什么错误。如果没有问题,则已经运行起来了。
3.测试
运行CMD,而后输入: nslookup
C:\>nslookup
Default Server: ns.ahhfptt.net.cn
Address: 202.102.192.68
> server 60.171.45.152
Default Server: [60.171.45.152]
Address: 60.171.45.152
> set type=any
> dnsany.com
Server: [60.171.45.152]
Address: 60.171.45.152
dnsany.com
primary name server = ns.joysp.com
responsible mail addr = root.592365.com
serial = 2005121213
refresh = 3600 (1 hour)
retry = 900 (15 mins)
expire = 68400 (19 hours)
default TTL = 15 (15 secs)
dnsany.com nameserver = ns.joysp.com
dnsany.com internet address = 60.171.45.152
说明DNS服务器解析正常!
说明下dnsany.com.txt
#########################cnc\dnsany.com.txt##############################
$TTL 3600
$ORIGIN dnsany.com.
@ IN SOA ns.joysp.com. root. joysp.com.(
2006111520 ;Serial
3600 ; Refresh ( seconds )
900 ; Retry ( seconds )
68400 ; Expire ( seconds )
15 );Minimum TTL for Zone ( seconds )
;
@ IN NS ns.joysp.com.
@ IN MX 0 mail.
@ IN A 220.248.236.152
www IN A 220.248.236.152
webserver IN CNAME www
mail IN A 220.248.236.152
* IN A 220.248.236.152
;
;end
#########################cnc\dnsany.com.txt##############################
第一行是TTL设定,生存时间记录字段。它以秒为单位定义该资源记录中的信息存放在高速缓存中的时间长度。这里定义为604800秒,也就是1周.
第二行是$ORIGIN设定,说明下面的记录出自何处.请您加倍留意最后的一个小小数点"."
然后,第三行,是一个 SOA 记录的设定,在这里我们看到一个特殊字符 @ ,它就是 ORIGIN 的意思,也就是刚刚所定义的$ ORIGIN dnsany.com. 的内容,您可以写成 dnsany.com. 也可以用 @ 来代替。
假如这个文件前面没有定义 $ ORIGIN 的话, 那這个 @ 的值就以 named.conf 里的 zone .
接着 SOA 后面,指定了这个区域的授权主机和管理者的信箱,这里分别是"joysp.com." 和"root.joysp.com."。我们平时使用的信箱通常是“user@host”这样的格式,但因为@在 DNS 记录中是个保留字符,所以在 SOA 中就用“.”来代替了@。目前这个信箱是 "root@joysp.com."。
接下来的 SOA 设置,是被括在“( )”之间的 5 组数字,主要作为和 slave 服务器同步 DNS 资料所使用的资料:
Serial:其格式通常会是“年月日+修改次序”(但也不一定如此,您自己能够记得就行)。当 slave 要进行资料同步的时候,会比较这个号码。如果发现在这里的号码比它那边的数值“大”,就进行更新,否则忽略。不过设 serial 有一个地方您要留意:不能超过 10 位数字!
Refresh:这里是是告诉 slave 要隔多久要进行资料同步(是否同步要看 Serial 的比较结果)。
Retry:如果 slave 在进行更新失败后,要隔多久再进行重试。
Expire:这是记录逾期时间:当 slave 一直未能成功与 master 取得联系,那到这里就放弃 retry,同时这里的资料也将标识为过期(
expired )。
Minimum:这是最小默认 TTL 值,如果您在前面没有用“$TTL”来定义,就会以此值为准。
请注意:SOA 记录中这对 “ ( ) ”符号之第一个 “ (”括号一定要和 SOA 写在同一行,而不能用 Enter 断行到下一行去,而且其左边最好有一个空格键或 tab 建。而最后一个 “ )”括号也不能写在注解符号 “ ;”的右边。 置 DNS 的 RR 记录档,其格式要求非常严格,我们丝毫不能掉以轻心。比方说:如果句子不是以空格键、Tab 键、 或注解符号 ( ; )开头,也不在 SOA 的 “ ( ) ”之内,则表示要定义一个“新记录项 (Entry) ”;如果句子是以空格键或 tab 键开始的话,其设置被视为上一个“记录项”的内容。所以,如果您要为“同一个记录项”定义多个记录设置,而不想重复打字,您倒可以偷懒:在接着它的后面几行用空白或 Tab 来缩排就可以了。
NS表明负责dnsany.com.这个域的Name Server是ns.joysp.com这台主机
MX记录标明发往mail域的邮件由mail.dnsany.com这台服务器接收
A记录标明了IP地址和域名之间的对应关系
后记
DNS智能策略解析还可以给你的多个主机实现负载均衡,这时来自各地的访问流量会比较平均的分布到你的每一个主机上。
只需要在相应的CNC TELECOM文件中加@ www记录
#########################cnc\dnsany.com.txt##############################
$TTL 3600
$ORIGIN dnsany.com.
@ IN SOA ns.joysp.com. root. joysp.com.(
2006111520 ;Serial
3600 ; Refresh ( seconds )
900 ; Retry ( seconds )
68400 ; Expire ( seconds )
15 );Minimum TTL for Zone ( seconds )
;
@ IN NS ns.joysp.com.
@ IN A 220.248.236.152
@ IN A 220.248.236.153
@ IN A 220.248.236.154
@ IN A 220.248.236.155
www IN A 220.248.236.152
www IN A 220.248.236.153
www IN A 220.248.236.154
www IN A 220.248.236.155
* IN A 220.248.236.152
;
;end
#########################cnc\dnsany.com.txt##############################
#########################telecom\dnsany.com.txt##############################
$TTL 3600
$ORIGIN dnsany.com.
@ IN SOA ns.joysp.com. root. joysp.com.(
2006111520 ;Serial
3600 ; Refresh ( seconds )
900 ; Retry ( seconds )
68400 ; Expire ( seconds )
15 );Minimum TTL for Zone ( seconds )
;
@ IN NS ns.joysp.com.
@ IN A 60.171.45.152
@ IN A 60.171.45.153
@ IN A 60.171.45.154
@ IN A 60.171.45.155
www IN A 60.171.45.152
www IN A 60.171.45.153
www IN A 60.171.45.154
www IN A 60.171.45.155
* IN A 60.171.45.152
;
;end
#########################telecom\dnsany.com.txt##############################
C:\Documents and Settings\coolice>cd \
C:\>nslookup
Default Server: ns.ahhfptt.net.cn
Address: 202.102.192.68
>server ns.joysp.com
> set q=a
> dnsany.com
Server: ns.joysp.com
Address: 60.171.45.152
Non-authoritative answer:
Name: dnsany.com
Addresses: 60.171.45.152, 60.171.45.153, 60.171.45.154, 60.171.45.155
配置文件下载: http://iamsam.blogbus.com/files/12218213130.zip
官方配置文件示例:
http://www.bind.com/?path=dns
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://iamsam.blogbus.com/logs/29402246.html
前言
随着原中国电信集团按南北地域分家,新的中国电信和网通集团随即成立,互联网的骨干网也被一分为二了,北有网通、南有电信。从此,细心的网民可以发现,有些经常访问的网站速度一下子慢了下来,有时候还有访问不到的情况出现。例如北方地区的网络用户访问中国网通的服务器会非常快,而访问中国电信的服务器时,感觉非常慢。这种现象不仅影响了网站的访问量,更严重的是它直接影响了一些经营性网站的经济效益。据分析,产生这个问题的根本原因是中国电信分家之后,电信与网通之间的互连存在问题。虽然信息产业部已经在规划南北互通计划,但在今后相当长的一段时期内,南北方网互连的问题还会长期存在。
解决方案
智能DNS策略解析很好的解决了上面所述的问题。DNS策略解析最基本的功能是可以智能的判断访问您网站的用户,然后根据不同的访问者把您的域名分别解析成不同的IP地址。如访问者是网通用户,DNS策略解析服务器会把你的域名对应的网通IP地址解析给这个访问者。如果用户是电信用户,DNS策略解析服务器会把您域名对应的电信IP地址解析给这个访问者。
智能DNS策略解析还可以给你的多个主机实现负载均衡,这时来自各地的访问流量会比较平均的分布到你的每一个主机上。
软件的相关资源
官方网站: http://www.bind.com/
最新版本: 9.3.2 http://www.isc.org/index.pl?/sw/bind/view/?release=9.3.2-P2
帮助文档: http://www.isc.org/sw/bind/
配置文件样例: http://www.bind.com/bind.html
实施步骤:
1。 WINDOWS 2003 服务器
2。使用BIND9做智能DNS,自动根据客户端IP来判断,网通的用户解析出网通的IP,电信的解析出电信IP
测试做的域名
www.dnsany.com
电信IP 60.171.45.152
网通IP 220.248.236.152
电信用户PING www.dnsany.com会解析到60.171.45.152
网通用户PING www.dnsany.com会解析到220.248.236.152
配置步骤:
1.BIND 9.3.2
http://ftp.isc.org/isc/bind9/9.3.2-P2/BIND9.3.2-P2.zip
2. 安装BIND 9 .3.2
解压到一个临时目录,而后运行 BINDInstall.exe,一直默认安装就行了,不需要更改什么设置。
默认安装到 \windows\system32\dns目录下
3.配置
运行CMD进入安装目录(\windows\system32\dns)下面的bin目录,而后运行
rndc-confgen -a (运行完成后会在etc目录下生成rndc.key)
rndc-confgen > ..\etc\rndc.conf
进入etc目录,用 notepad 新建 named.conf 复制下面的内容,注意把rndc.conf中# Use with the following in named.conf, adjusting the allow list as needed: 以后的内容复制到named.conf文件中,去掉全面的#。
named.conf
######################named.conf############################
acl "trust-lan" { 127.0.0.1/8; 10.0.0.0/24;};
options {
directory "C:\WINDOWS\system32\dns\etc";
recursion no;
version "0.0.0";
allow-transfer { "trust-lan";};
allow-notify { "trust-lan"; };
auth-nxdomain no;
forwarders { 60.171.45.171;60.171.45.150;};
};
#这一段内容拷贝来自rndc.conf
key "rndc-key" {
algorithm hmac-md5;
secret "p30d5VTh6iP+QBiVsEI0lw==";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
#注意在C:\WINDOWS\system32\dns\log\ 下建dns_warnings.txt dns_logs.txt
logging {
channel warning
{ file "C:\WINDOWS\system32\dns\log\dns_warnings.txt" versions 3 size 1240k;
severity warning;
print-category yes;
print-severity yes;
print-time yes;
};
channel general_dns
{ file "C:\WINDOWS\system32\dns\log\dns_logs.txt" versions 3 size 1240k;
severity info;
print-category yes;
print-severity yes;
print-time yes;
};
category default { warning; };
category queries { general_dns; };
};
#将网通的地址范围数据
include "cnc.conf";
# 判断如果是网通的地址范围,则会执行此处,调用网通的解析
view "view_cnc" {
match-clients { CNC; };
zone "." {
type hint;
file "named.root";
};
zone "0.0.127.IN-ADDR.ARPA" {
type master;
file "localhost.rev";
};
include "master/cnc.def";
};
view "view_any" {
match-clients { any; };
zone "." {
type hint;
file "named.root";
};
zone "0.0.127.IN-ADDR.ARPA" {
type master;
file "localhost.rev";
};
include "master/telecom.def";
};
###################### named.conf############################
用notepad 新建 cnc.conf复制下面的内容
###################### cnc.conf############################
# jul/14/2006 09:44:25 by coolice
# software id = EFTB-IZN
#
acl "CNC" {
58.16.0.0/16;
58.17.0.0/17;
60.12.0.0/16;
222.163.128.0/17;
219.235.56.194;
};
###################### cnc.conf############################
用notepad 新建 named.root复制下面的内容
###################### named.root############################
; This file holds the information on root name servers needed to
; initialize cache of Internet domain name servers
; (e.g. reference this file in the "cache . "
; configuration file of BIND domain name servers).
;
; This file is made available by InterNIC
; under anonymous FTP as
; file /domain/named.root
; on server FTP.INTERNIC.NET
; -OR- RS.INTERNIC.NET
;
; last update: Jan 29, 2004
; related version of root zone: 2004012900
;
;
; formerly NS.INTERNIC.NET
;
. 3600000 IN NS A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
;
; formerly NS1.ISI.EDU
;
. 3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 192.228.79.201
;
; formerly C.PSI.NET
;
. 3600000 NS C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12
;
; formerly TERP.UMD.EDU
;
. 3600000 NS D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET. 3600000 A 128.8.10.90
;
; formerly NS.NASA.GOV
;
. 3600000 NS E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10
;
; formerly NS.ISC.ORG
;
. 3600000 NS F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241
;
; formerly NS.NIC.DDN.MIL
;
. 3600000 NS G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET. 3600000 A 192.112.3***
;
; formerly AOS.ARL.ARMY.MIL
;
. 3600000 NS H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53
;
; formerly NIC.NORDU.NET
;
. 3600000 NS I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
;
; operated by VeriSign, Inc.
;
. 3600000 NS J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30
;
; operated by RIPE NCC
;
. 3600000 NS K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
;
; operated by ICANN
;
. 3600000 NS L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET. 3600000 A 198.32.64.12
;
; operated by WIDE
;
. 3600000 NS M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33
; End of File
###################### named.root############################
新建master文件夹 并在里面新建cnc 和 telecom 文件夹
进入masrer文件夹 用notepad 新建cnc.def 和telecom.def
###################### cnc.def############################
zone "dnsany.com" {
type master;
file "C:\WINDOWS\system32\dns\etc\master\cnc\dnsany.com.txt";
};
###################### cnc.def############################
###################### telecom.def############################
zone "dnsany.com" {
type master;
file "C:\WINDOWS\system32\dns\etc\master\telecom\dnsany.com.txt";
};
###################### telecom.def############################
分别进入cnc和telecom文件夹建立dnsany.com.txt文件
#########################cnc\dnsany.com.txt##############################
$TTL 3600
$ORIGIN dnsany.com.
@ IN SOA ns.joysp.com. root. joysp.com.(
2006111520 ;Serial
3600 ; Refresh ( seconds )
900 ; Retry ( seconds )
68400 ; Expire ( seconds )
15 );Minimum TTL for Zone ( seconds )
;
@ IN NS ns.joysp.com.
@ IN A 220.248.236.152
www IN A 220.248.236.152
* IN A 220.248.236.152
;
;end
#########################cnc\dnsany.com.txt##############################
#########################telecom\dnsany.com.txt##############################
$TTL 3600
$ORIGIN dnsany.com.
@ IN SOA ns.joysp.com. root. joysp.com.(
2006111520 ;Serial
3600 ; Refresh ( seconds )
900 ; Retry ( seconds )
68400 ; Expire ( seconds )
15 );Minimum TTL for Zone ( seconds )
;
@ IN NS ns.joysp.com.
@ IN A 60.171.45.152
www IN A 60.171.45.152
* IN A 60.171.45.152
;
;end
#########################telecom\dnsany.com.txt##############################
全部配置完成后,可以进入Windows 服务管理器,找到那个叫 ISC Bind的服务,而后属性更改登陆为本地系统用户选择启动,如果出现错误,请打开你的事件查看器,到应用程序部分看看什么错误。如果没有问题,则已经运行起来了。
3.测试
运行CMD,而后输入: nslookup
C:\>nslookup
Default Server: ns.ahhfptt.net.cn
Address: 202.102.192.68
> server 60.171.45.152
Default Server: [60.171.45.152]
Address: 60.171.45.152
> set type=any
> dnsany.com
Server: [60.171.45.152]
Address: 60.171.45.152
dnsany.com
primary name server = ns.joysp.com
responsible mail addr = root.592365.com
serial = 2005121213
refresh = 3600 (1 hour)
retry = 900 (15 mins)
expire = 68400 (19 hours)
default TTL = 15 (15 secs)
dnsany.com nameserver = ns.joysp.com
dnsany.com internet address = 60.171.45.152
说明DNS服务器解析正常!
说明下dnsany.com.txt
#########################cnc\dnsany.com.txt##############################
$TTL 3600
$ORIGIN dnsany.com.
@ IN SOA ns.joysp.com. root. joysp.com.(
2006111520 ;Serial
3600 ; Refresh ( seconds )
900 ; Retry ( seconds )
68400 ; Expire ( seconds )
15 );Minimum TTL for Zone ( seconds )
;
@ IN NS ns.joysp.com.
@ IN MX 0 mail.
@ IN A 220.248.236.152
www IN A 220.248.236.152
webserver IN CNAME www
mail IN A 220.248.236.152
* IN A 220.248.236.152
;
;end
#########################cnc\dnsany.com.txt##############################
第一行是TTL设定,生存时间记录字段。它以秒为单位定义该资源记录中的信息存放在高速缓存中的时间长度。这里定义为604800秒,也就是1周.
第二行是$ORIGIN设定,说明下面的记录出自何处.请您加倍留意最后的一个小小数点"."
然后,第三行,是一个 SOA 记录的设定,在这里我们看到一个特殊字符 @ ,它就是 ORIGIN 的意思,也就是刚刚所定义的$ ORIGIN dnsany.com. 的内容,您可以写成 dnsany.com. 也可以用 @ 来代替。
假如这个文件前面没有定义 $ ORIGIN 的话, 那這个 @ 的值就以 named.conf 里的 zone .
接着 SOA 后面,指定了这个区域的授权主机和管理者的信箱,这里分别是"joysp.com." 和"root.joysp.com."。我们平时使用的信箱通常是“user@host”这样的格式,但因为@在 DNS 记录中是个保留字符,所以在 SOA 中就用“.”来代替了@。目前这个信箱是 "root@joysp.com."。
接下来的 SOA 设置,是被括在“( )”之间的 5 组数字,主要作为和 slave 服务器同步 DNS 资料所使用的资料:
Serial:其格式通常会是“年月日+修改次序”(但也不一定如此,您自己能够记得就行)。当 slave 要进行资料同步的时候,会比较这个号码。如果发现在这里的号码比它那边的数值“大”,就进行更新,否则忽略。不过设 serial 有一个地方您要留意:不能超过 10 位数字!
Refresh:这里是是告诉 slave 要隔多久要进行资料同步(是否同步要看 Serial 的比较结果)。
Retry:如果 slave 在进行更新失败后,要隔多久再进行重试。
Expire:这是记录逾期时间:当 slave 一直未能成功与 master 取得联系,那到这里就放弃 retry,同时这里的资料也将标识为过期(
expired )。
Minimum:这是最小默认 TTL 值,如果您在前面没有用“$TTL”来定义,就会以此值为准。
请注意:SOA 记录中这对 “ ( ) ”符号之第一个 “ (”括号一定要和 SOA 写在同一行,而不能用 Enter 断行到下一行去,而且其左边最好有一个空格键或 tab 建。而最后一个 “ )”括号也不能写在注解符号 “ ;”的右边。 置 DNS 的 RR 记录档,其格式要求非常严格,我们丝毫不能掉以轻心。比方说:如果句子不是以空格键、Tab 键、 或注解符号 ( ; )开头,也不在 SOA 的 “ ( ) ”之内,则表示要定义一个“新记录项 (Entry) ”;如果句子是以空格键或 tab 键开始的话,其设置被视为上一个“记录项”的内容。所以,如果您要为“同一个记录项”定义多个记录设置,而不想重复打字,您倒可以偷懒:在接着它的后面几行用空白或 Tab 来缩排就可以了。
NS表明负责dnsany.com.这个域的Name Server是ns.joysp.com这台主机
MX记录标明发往mail域的邮件由mail.dnsany.com这台服务器接收
A记录标明了IP地址和域名之间的对应关系
后记
DNS智能策略解析还可以给你的多个主机实现负载均衡,这时来自各地的访问流量会比较平均的分布到你的每一个主机上。
只需要在相应的CNC TELECOM文件中加@ www记录
#########################cnc\dnsany.com.txt##############################
$TTL 3600
$ORIGIN dnsany.com.
@ IN SOA ns.joysp.com. root. joysp.com.(
2006111520 ;Serial
3600 ; Refresh ( seconds )
900 ; Retry ( seconds )
68400 ; Expire ( seconds )
15 );Minimum TTL for Zone ( seconds )
;
@ IN NS ns.joysp.com.
@ IN A 220.248.236.152
@ IN A 220.248.236.153
@ IN A 220.248.236.154
@ IN A 220.248.236.155
www IN A 220.248.236.152
www IN A 220.248.236.153
www IN A 220.248.236.154
www IN A 220.248.236.155
* IN A 220.248.236.152
;
;end
#########################cnc\dnsany.com.txt##############################
#########################telecom\dnsany.com.txt##############################
$TTL 3600
$ORIGIN dnsany.com.
@ IN SOA ns.joysp.com. root. joysp.com.(
2006111520 ;Serial
3600 ; Refresh ( seconds )
900 ; Retry ( seconds )
68400 ; Expire ( seconds )
15 );Minimum TTL for Zone ( seconds )
;
@ IN NS ns.joysp.com.
@ IN A 60.171.45.152
@ IN A 60.171.45.153
@ IN A 60.171.45.154
@ IN A 60.171.45.155
www IN A 60.171.45.152
www IN A 60.171.45.153
www IN A 60.171.45.154
www IN A 60.171.45.155
* IN A 60.171.45.152
;
;end
#########################telecom\dnsany.com.txt##############################
C:\Documents and Settings\coolice>cd \
C:\>nslookup
Default Server: ns.ahhfptt.net.cn
Address: 202.102.192.68
>server ns.joysp.com
> set q=a
> dnsany.com
Server: ns.joysp.com
Address: 60.171.45.152
Non-authoritative answer:
Name: dnsany.com
Addresses: 60.171.45.152, 60.171.45.153, 60.171.45.154, 60.171.45.155
配置文件下载: http://iamsam.blogbus.com/files/12218213130.zip
官方配置文件示例:
http://www.bind.com/?path=dns
用Bind9架设自己的智能DNS
用Bind9架设自己的智能DNS
by ProdigYu on Oct.20, 2010, under CDN
中国的南北网络问题,是许多做网站的人的心病
除了使用双通或者多通机房以外,还可以通过多台镜像服务器的方法来提高用户的访问速度
但是,如果使用的双通机房并不是单IP的,或者使用多台镜像的做法,就会面临多个不同的服务器IP的问题
最早的时候,很多镜像服务器都是使用不同的域名的,比如说www1和www2,或者www和cnc
这样的做法,对用户相当不友好,而且不方便推广,比如说,你要告诉朋友一个网站,还要问他是什么线路才能给网址吗,或者可能你还不知道这个网站有一个专为网通的线路所设置的镜像
用统一的域名,然后根据用户的线路自动判断引导到不同的镜像服务器,正是智能DNS的功用(智能DNS其实是CDN的其中一部分,是最前端的部分)
现在还是有一些地方使用多域名,比如说下载网站的下载镜像服务器,因为智能DNS有一定的缺陷(并不一定选择到正确的线路,下面说),也提供给用户自由选择线路的权利
目前也有一些公司提供智能DNS解释服务,把你的域名NS指到他们服务器,然后输入网通和电信服务器的IP就ok了
也有一些公司提供比较完整的CDN服务,比如比较出名的就是chinacache,不少中型网站是使用他们的服务
最初的bind是不支持通过来源选择不同的ip的,因此只能通过iptables的辅助来实现智能DNS,方法也很简单,在DNS服务器上面启动两份bind,都不要用默认的端口,两份分别解析不同的线路,然后再用iptables将默认端口的DNS请求根据来源IP发送到不同的bind实例
这种方法缺点很明显,需要多个bind实例,如果需要更多的线路解释那就还要再开bind实例,另外iptables对来源的解释也会导致iptables太多规则
现在的bind支持了根据来源选择的功能,我不确定是不是bind9的新特性,不过bind9是重写过的,相比漏洞百出的bind8来说,稳定和安全很多,以下的配置以bind9为基础
我使用的是CentOS,由于bind服务没有其他服务(比如apache,squid)要求那么高,所以也没有必要自己编译一份,我是用过yum安装的,版本不是最新的稳定版
装好之后,可以用过/etc/init.d/named start成功启动服务
有一个文件named.conf出现在/etc下,就是bind的主config文件,我们只要改动他
(我只说明智能DNS实现部分,其他的bind设置自行修改,呵呵)
另外一个小技巧,可以通过/usr/sbin/named -g -u named来启动bind,可以立刻看到输出信息,方便调试
我们是通过bind9的view功能来分离判断的
首先,我们需要一份网通的IP列表,这是一份在网上流传的列表,呵呵
acl “CNC” {
58.16.0.0/16;
58.17.0.0/17;
58.17.128.0/17;
58.18.0.0/16;
58.19.0.0/16;
58.20.0.0/16;
58.21.0.0/16;
58.22.0.0/15;
58.240.0.0/15;
58.242.0.0/15;
58.244.0.0/15;
58.246.0.0/15;
58.248.0.0/13;
60.0.0.0/13;
60.8.0.0/15;
60.10.0.0/16;
60.11.0.0/16;
60.12.0.0/16;
60.13.0.0/18;
60.13.128.0/17;
60.14.0.0/15;
60.16.0.0/13;
60.24.0.0/14;
60.30.0.0/16;
60.31.0.0/16;
60.208.0.0/13;
60.216.0.0/15;
60.218.0.0/15;
60.220.0.0/14;
61.48.0.0/13;
61.133.0.0/17;
61.134.96.0/19;
61.134.128.0/17;
61.135.0.0/16;
61.137.128.0/17;
61.138.0.0/17;
61.138.128.0/18;
61.139.128.0/18;
61.148.0.0/15;
61.156.0.0/16;
61.159.0.0/18;
61.161.0.0/18;
61.161.128.0/17;
61.162.0.0/16;
61.163.0.0/16;
61.167.0.0/16;
61.168.0.0/16;
61.176.0.0/16;
61.179.0.0/16;
61.181.0.0/16;
61.182.0.0/16;
61.189.0.0/17;
125.32.0.0/16;
125.40.0.0/13;
202.96.0.0/18;
202.96.64.0/21;
202.96.72.0/21;
202.97.128.0/18;
202.97.224.0/21;
202.97.240.0/20;
202.98.0.0/21;
202.98.8.0/21;
202.99.64.0/19;
202.99.96.0/21;
202.99.128.0/19;
202.99.160.0/21;
202.99.168.0/21;
202.99.176.0/20;
202.99.208.0/20;
202.99.224.0/21;
202.99.232.0/21;
202.99.240.0/20;
202.102.128.0/21;
202.102.224.0/21;
202.102.232.0/21;
202.106.0.0/16;
202.107.0.0/17;
202.108.0.0/16;
202.110.0.0/17;
202.111.128.0/18;
203.93.8.0/24;
203.93.192.0/18;
210.13.128.0/17;
210.14.160.0/19;
210.14.192.0/19;
210.15.32.0/19;
210.15.96.0/19;
210.15.128.0/18;
210.21.0.0/16;
210.52.128.0/17;
210.53.0.0/17;
210.53.128.0/17;
210.74.96.0/19;
210.74.128.0/19;
210.82.0.0/15;
218.8.0.0/14;
218.12.0.0/16;
218.21.128.0/17;
218.24.0.0/14;
218.56.0.0/14;
218.60.0.0/15;
218.67.128.0/17;
218.68.0.0/15;
218.104.0.0/14;
219.154.0.0/15;
219.156.0.0/15;
219.158.0.0/17;
219.158.128.0/17;
219.159.0.0/18;
220.252.0.0/16;
221.0.0.0/15;
221.2.0.0/16;
221.3.0.0/17;
221.3.128.0/17;
221.4.0.0/16;
221.5.0.0/17;
221.5.128.0/17;
221.6.0.0/16;
221.7.0.0/19;
221.7.32.0/19;
221.7.64.0/19;
221.7.96.0/19;
221.8.0.0/15;
221.10.0.0/16;
221.11.0.0/17;
221.11.128.0/18;
221.11.192.0/19;
221.12.0.0/17;
221.12.128.0/18;
221.13.0.0/18;
221.13.64.0/19;
221.13.96.0/19;
221.13.128.0/17;
221.14.0.0/15;
221.192.0.0/15;
221.194.0.0/16;
221.195.0.0/16;
221.196.0.0/15;
221.198.0.0/16;
221.199.0.0/19;
221.199.32.0/20;
221.199.128.0/18;
221.199.192.0/20;
221.200.0.0/14;
221.204.0.0/15;
221.206.0.0/16;
221.207.0.0/18;
221.207.64.0/18;
221.207.128.0/17;
221.208.0.0/14;
221.212.0.0/16;
221.213.0.0/16;
221.216.0.0/13;
222.128.0.0/14;
222.132.0.0/14;
222.136.0.0/13;
222.160.0.0/15;
222.162.0.0/16;
222.163.0.0/19;
222.163.32.0/19;
222.163.64.0/18;
222.163.128.0/17;
};
如果觉得有哪些部分不是很准确的话,可以自行修改
由于这个部分太长了,所以写在一个专门的文件然后include进named.conf比较容易维护
例如,我们把上面这段配置保存为cnc_acl.conf
然后在named.conf写入
include “/data/named/cnc_acl.conf”;
即可
接下来就是view的配置,假设域名是xyz.com,呵呵
view “view_cnc” {
match-clients { CNC; };
zone “xyz.com” {
type master;
file “/data/named/cnc_xyz”;
};
};
view “view_any” {
match-clients { any; };
zone “xyz.com” {
type master;
file “/data/named/any_xyz”;
};
};
就这样就足够了
然后我们需要cnc\_xyz和any_xyz两个具体的zone file
两个文件基本是一模一样的,就是指向不同的ip
$TTL 2h
xyz.com. IN SOA ns.xyz.com. root.xyz.com. (
20071022
2h
40m
1w
2h
)
this6.com. IN NS ns.xyz.com.
this6.com. IN MX 1 mail.xyz.com.
ns IN A 1.1.1.1
mail IN A 1.1.1.1
www IN A 1.1.1.1
根据不同的线路把www指向不同的IP即可
这样,我们就实现了自己的智能DNS
后话,目前许多大型网站都是用这个来实现不同的线路来源访问不同的镜像,甚至还做到地区级别,例如,在佛山机房部署了一台镜像服务器,就将广东省的访问都指向这台服务器
另外,刚刚提到智能DNS也有缺陷,这里详细描述一下,bind9通过用户的来源IP来返回不同的解释IP,而实际上,并不是实际用户直接访问我们的 DNS,而是用户所使用的DNS(比如说广州ADSL用户的默认DNS)负责访问我们的DNS,网通的DNS就保存有我们网通的IP,如果用户自行修改了 DNS,比如说电信的用户硬要用网通的DNS,或者网通的用户使用国外的DNS(比如opendns之类的),就会导致判断失误
by ProdigYu on Oct.20, 2010, under CDN
中国的南北网络问题,是许多做网站的人的心病
除了使用双通或者多通机房以外,还可以通过多台镜像服务器的方法来提高用户的访问速度
但是,如果使用的双通机房并不是单IP的,或者使用多台镜像的做法,就会面临多个不同的服务器IP的问题
最早的时候,很多镜像服务器都是使用不同的域名的,比如说www1和www2,或者www和cnc
这样的做法,对用户相当不友好,而且不方便推广,比如说,你要告诉朋友一个网站,还要问他是什么线路才能给网址吗,或者可能你还不知道这个网站有一个专为网通的线路所设置的镜像
用统一的域名,然后根据用户的线路自动判断引导到不同的镜像服务器,正是智能DNS的功用(智能DNS其实是CDN的其中一部分,是最前端的部分)
现在还是有一些地方使用多域名,比如说下载网站的下载镜像服务器,因为智能DNS有一定的缺陷(并不一定选择到正确的线路,下面说),也提供给用户自由选择线路的权利
目前也有一些公司提供智能DNS解释服务,把你的域名NS指到他们服务器,然后输入网通和电信服务器的IP就ok了
也有一些公司提供比较完整的CDN服务,比如比较出名的就是chinacache,不少中型网站是使用他们的服务
最初的bind是不支持通过来源选择不同的ip的,因此只能通过iptables的辅助来实现智能DNS,方法也很简单,在DNS服务器上面启动两份bind,都不要用默认的端口,两份分别解析不同的线路,然后再用iptables将默认端口的DNS请求根据来源IP发送到不同的bind实例
这种方法缺点很明显,需要多个bind实例,如果需要更多的线路解释那就还要再开bind实例,另外iptables对来源的解释也会导致iptables太多规则
现在的bind支持了根据来源选择的功能,我不确定是不是bind9的新特性,不过bind9是重写过的,相比漏洞百出的bind8来说,稳定和安全很多,以下的配置以bind9为基础
我使用的是CentOS,由于bind服务没有其他服务(比如apache,squid)要求那么高,所以也没有必要自己编译一份,我是用过yum安装的,版本不是最新的稳定版
装好之后,可以用过/etc/init.d/named start成功启动服务
有一个文件named.conf出现在/etc下,就是bind的主config文件,我们只要改动他
(我只说明智能DNS实现部分,其他的bind设置自行修改,呵呵)
另外一个小技巧,可以通过/usr/sbin/named -g -u named来启动bind,可以立刻看到输出信息,方便调试
我们是通过bind9的view功能来分离判断的
首先,我们需要一份网通的IP列表,这是一份在网上流传的列表,呵呵
acl “CNC” {
58.16.0.0/16;
58.17.0.0/17;
58.17.128.0/17;
58.18.0.0/16;
58.19.0.0/16;
58.20.0.0/16;
58.21.0.0/16;
58.22.0.0/15;
58.240.0.0/15;
58.242.0.0/15;
58.244.0.0/15;
58.246.0.0/15;
58.248.0.0/13;
60.0.0.0/13;
60.8.0.0/15;
60.10.0.0/16;
60.11.0.0/16;
60.12.0.0/16;
60.13.0.0/18;
60.13.128.0/17;
60.14.0.0/15;
60.16.0.0/13;
60.24.0.0/14;
60.30.0.0/16;
60.31.0.0/16;
60.208.0.0/13;
60.216.0.0/15;
60.218.0.0/15;
60.220.0.0/14;
61.48.0.0/13;
61.133.0.0/17;
61.134.96.0/19;
61.134.128.0/17;
61.135.0.0/16;
61.137.128.0/17;
61.138.0.0/17;
61.138.128.0/18;
61.139.128.0/18;
61.148.0.0/15;
61.156.0.0/16;
61.159.0.0/18;
61.161.0.0/18;
61.161.128.0/17;
61.162.0.0/16;
61.163.0.0/16;
61.167.0.0/16;
61.168.0.0/16;
61.176.0.0/16;
61.179.0.0/16;
61.181.0.0/16;
61.182.0.0/16;
61.189.0.0/17;
125.32.0.0/16;
125.40.0.0/13;
202.96.0.0/18;
202.96.64.0/21;
202.96.72.0/21;
202.97.128.0/18;
202.97.224.0/21;
202.97.240.0/20;
202.98.0.0/21;
202.98.8.0/21;
202.99.64.0/19;
202.99.96.0/21;
202.99.128.0/19;
202.99.160.0/21;
202.99.168.0/21;
202.99.176.0/20;
202.99.208.0/20;
202.99.224.0/21;
202.99.232.0/21;
202.99.240.0/20;
202.102.128.0/21;
202.102.224.0/21;
202.102.232.0/21;
202.106.0.0/16;
202.107.0.0/17;
202.108.0.0/16;
202.110.0.0/17;
202.111.128.0/18;
203.93.8.0/24;
203.93.192.0/18;
210.13.128.0/17;
210.14.160.0/19;
210.14.192.0/19;
210.15.32.0/19;
210.15.96.0/19;
210.15.128.0/18;
210.21.0.0/16;
210.52.128.0/17;
210.53.0.0/17;
210.53.128.0/17;
210.74.96.0/19;
210.74.128.0/19;
210.82.0.0/15;
218.8.0.0/14;
218.12.0.0/16;
218.21.128.0/17;
218.24.0.0/14;
218.56.0.0/14;
218.60.0.0/15;
218.67.128.0/17;
218.68.0.0/15;
218.104.0.0/14;
219.154.0.0/15;
219.156.0.0/15;
219.158.0.0/17;
219.158.128.0/17;
219.159.0.0/18;
220.252.0.0/16;
221.0.0.0/15;
221.2.0.0/16;
221.3.0.0/17;
221.3.128.0/17;
221.4.0.0/16;
221.5.0.0/17;
221.5.128.0/17;
221.6.0.0/16;
221.7.0.0/19;
221.7.32.0/19;
221.7.64.0/19;
221.7.96.0/19;
221.8.0.0/15;
221.10.0.0/16;
221.11.0.0/17;
221.11.128.0/18;
221.11.192.0/19;
221.12.0.0/17;
221.12.128.0/18;
221.13.0.0/18;
221.13.64.0/19;
221.13.96.0/19;
221.13.128.0/17;
221.14.0.0/15;
221.192.0.0/15;
221.194.0.0/16;
221.195.0.0/16;
221.196.0.0/15;
221.198.0.0/16;
221.199.0.0/19;
221.199.32.0/20;
221.199.128.0/18;
221.199.192.0/20;
221.200.0.0/14;
221.204.0.0/15;
221.206.0.0/16;
221.207.0.0/18;
221.207.64.0/18;
221.207.128.0/17;
221.208.0.0/14;
221.212.0.0/16;
221.213.0.0/16;
221.216.0.0/13;
222.128.0.0/14;
222.132.0.0/14;
222.136.0.0/13;
222.160.0.0/15;
222.162.0.0/16;
222.163.0.0/19;
222.163.32.0/19;
222.163.64.0/18;
222.163.128.0/17;
};
如果觉得有哪些部分不是很准确的话,可以自行修改
由于这个部分太长了,所以写在一个专门的文件然后include进named.conf比较容易维护
例如,我们把上面这段配置保存为cnc_acl.conf
然后在named.conf写入
include “/data/named/cnc_acl.conf”;
即可
接下来就是view的配置,假设域名是xyz.com,呵呵
view “view_cnc” {
match-clients { CNC; };
zone “xyz.com” {
type master;
file “/data/named/cnc_xyz”;
};
};
view “view_any” {
match-clients { any; };
zone “xyz.com” {
type master;
file “/data/named/any_xyz”;
};
};
就这样就足够了
然后我们需要cnc\_xyz和any_xyz两个具体的zone file
两个文件基本是一模一样的,就是指向不同的ip
$TTL 2h
xyz.com. IN SOA ns.xyz.com. root.xyz.com. (
20071022
2h
40m
1w
2h
)
this6.com. IN NS ns.xyz.com.
this6.com. IN MX 1 mail.xyz.com.
ns IN A 1.1.1.1
mail IN A 1.1.1.1
www IN A 1.1.1.1
根据不同的线路把www指向不同的IP即可
这样,我们就实现了自己的智能DNS
后话,目前许多大型网站都是用这个来实现不同的线路来源访问不同的镜像,甚至还做到地区级别,例如,在佛山机房部署了一台镜像服务器,就将广东省的访问都指向这台服务器
另外,刚刚提到智能DNS也有缺陷,这里详细描述一下,bind9通过用户的来源IP来返回不同的解释IP,而实际上,并不是实际用户直接访问我们的 DNS,而是用户所使用的DNS(比如说广州ADSL用户的默认DNS)负责访问我们的DNS,网通的DNS就保存有我们网通的IP,如果用户自行修改了 DNS,比如说电信的用户硬要用网通的DNS,或者网通的用户使用国外的DNS(比如opendns之类的),就会导致判断失误
2010/11/03
2010/11/02
[Linux] 在 windows底下讀寫linux
« [Linux] cwRsync [rsync for windows] SSH 加密異地備份
Ubuntu Edgy Release KDE 桌面環境 »
[Linux] 在 windows底下讀寫linux
Dec 15th, 2006 by appleboy 參觀者:9,215Views 機器人:1,295Views
推到 Twitter!
推到 Plurk!
推到 Facebook!
剛剛在ptt看到的,一連串討論
□ XP 認得 ext2/ext3 磁區嗎 ?
裡面有很多文章 寫的不錯,可以提供出來
問題:
想問一下,我有一個移動式硬碟 60G
所以只能format 成 NTFS or ext2/ext3
而在 Linux 下, 目前支援 NTFS 讀寫可能要另外掛 package…
所以想問,那 Windows XP 是否支援 ext2 / ext3
ext3好像不行, 因為剛剛在 Linux 下 format成 ext3了
並備份了一些東東,到進到了Windows XP底下好像認不得了,
想問,ext2 在 Windows XP 底下,OK嗎…
xp認得嗎?
解法如下
作者 wyocbu@kkcity.com.tw (wyocbu),
以前下載過一個商業軟體 Paragon Mount Everything
http://www.mount-everything.com/
印象中好像可以讀寫 ext3
作者 ogre0403 (肚子餓)
只要讀的話 試試這個 應該是free的
http://www.chrysocome.net/explore2fs
寫的話應該不行
作者 alpe (薛丁格的貓)
http://www.fs-driver.org/
IFS Drivewrs 讀寫可… 不過中文編碼就…
作者 adolf.bbs@cd.twbbs.org (蘇怡華 有人要死了),
> http://ext2fsd.sf.net/
> ext2 可讀可寫
> ext3 唯讀
其實這類的driver都可以正常寫ext3
只是把journal關掉而已…
http://pank.org/blog/archives/000621.html
作者 jlovet (阿我真是猜不透XD)
ext2 跟 ext3是相容的檔案系統
在只支援ext2的OS上面mount ext3可以正常讀寫
只是會略過journal
關於ntfs-3g的測試…網站上面就有了…
http://www.ntfs-3g.org/performance.html
Ubuntu 掛載 Windows 分割區
Ubuntu 6.10 (Edgy):
deb http://givre.cabspace.com/ubuntu/ edgy main
deb http://ntfs-3g.sitesweetsite.info/ubuntu/ edgy main
deb http://flomertens.keo.in/ubuntu/ edgy main
Ubuntu 6.06 (Dapper Drake):
deb http://givre.cabspace.com/ubuntu/ dapper main main-all
deb http://ntfs-3g.sitesweetsite.info/ubuntu/ dapper main main-all
deb http://flomertens.keo.in/ubuntu/ dapper main main-all
然後執行以下指令更新 repositories 及安裝 ntfs-3g:
wget http://flomertens.keo.in/ubuntu/givre_key.asc -O- | sudo apt-key add -
wget http://givre.cabspace.com/ubuntu/givre_key.asc -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install ntfs-3g
http://www.real-blog.com/linux-bsd-notes/290
文章來源
Ubuntu Edgy Release KDE 桌面環境 »
[Linux] 在 windows底下讀寫linux
Dec 15th, 2006 by appleboy 參觀者:9,215Views 機器人:1,295Views
推到 Twitter!
推到 Plurk!
推到 Facebook!
剛剛在ptt看到的,一連串討論
□ XP 認得 ext2/ext3 磁區嗎 ?
裡面有很多文章 寫的不錯,可以提供出來
問題:
想問一下,我有一個移動式硬碟 60G
所以只能format 成 NTFS or ext2/ext3
而在 Linux 下, 目前支援 NTFS 讀寫可能要另外掛 package…
所以想問,那 Windows XP 是否支援 ext2 / ext3
ext3好像不行, 因為剛剛在 Linux 下 format成 ext3了
並備份了一些東東,到進到了Windows XP底下好像認不得了,
想問,ext2 在 Windows XP 底下,OK嗎…
xp認得嗎?
解法如下
作者 wyocbu@kkcity.com.tw (wyocbu),
以前下載過一個商業軟體 Paragon Mount Everything
http://www.mount-everything.com/
印象中好像可以讀寫 ext3
作者 ogre0403 (肚子餓)
只要讀的話 試試這個 應該是free的
http://www.chrysocome.net/explore2fs
寫的話應該不行
作者 alpe (薛丁格的貓)
http://www.fs-driver.org/
IFS Drivewrs 讀寫可… 不過中文編碼就…
作者 adolf.bbs@cd.twbbs.org (蘇怡華 有人要死了),
> http://ext2fsd.sf.net/
> ext2 可讀可寫
> ext3 唯讀
其實這類的driver都可以正常寫ext3
只是把journal關掉而已…
http://pank.org/blog/archives/000621.html
作者 jlovet (阿我真是猜不透XD)
ext2 跟 ext3是相容的檔案系統
在只支援ext2的OS上面mount ext3可以正常讀寫
只是會略過journal
關於ntfs-3g的測試…網站上面就有了…
http://www.ntfs-3g.org/performance.html
Ubuntu 掛載 Windows 分割區
Ubuntu 6.10 (Edgy):
deb http://givre.cabspace.com/ubuntu/ edgy main
deb http://ntfs-3g.sitesweetsite.info/ubuntu/ edgy main
deb http://flomertens.keo.in/ubuntu/ edgy main
Ubuntu 6.06 (Dapper Drake):
deb http://givre.cabspace.com/ubuntu/ dapper main main-all
deb http://ntfs-3g.sitesweetsite.info/ubuntu/ dapper main main-all
deb http://flomertens.keo.in/ubuntu/ dapper main main-all
然後執行以下指令更新 repositories 及安裝 ntfs-3g:
wget http://flomertens.keo.in/ubuntu/givre_key.asc -O- | sudo apt-key add -
wget http://givre.cabspace.com/ubuntu/givre_key.asc -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install ntfs-3g
http://www.real-blog.com/linux-bsd-notes/290
文章來源
Ubuntu 9.10 增加 / 設定 語系(Locale)
Ubuntu 9.10 增加 / 設定 語系(Locale)
語系增加在 Debian / Ubuntu Linux 上, 都是編輯 /etc/locale.gen 此檔案, 再執行 locale-gen 即可.
在 Ubuntu Linux 9.10 後, /etc/locale.gen 這個檔案不見了, 設上去也沒有用, 於是來找找新的設定法.
Locales 設定
* 由 "man locale-gen" 可以找到新的設定位置: /var/lib/locales/supported.d/*
* cat /var/lib/locales/supported.d/local # 可以看到目前設定語系
zh_TW.UTF-8 UTF-8
Locales 增加
要增加語系可以有下述兩種做法: (註: 語系列表可見: /usr/share/i18n/SUPPORTED)
1. 手動加入語系
* vim /var/lib/locales/supported.d/zh # 隨意新增一個檔案(zh 這個檔名可隨意命名)
zh_CN.UTF-8 UTF-8
zh_SG.UTF-8 UTF-8
zh_HK.UTF-8 UTF-8
zh_TW.UTF-8 UTF-8
2. 使用 locale-gen 加入語系
1. sudo locale-gen zh_TW
2. sudo locale-gen zh_TW.UTF-8
3. cat /var/lib/locales/supported.d/local # 加入完成後, 可於此檔案看到資訊
重新建立 Locales
上述設定完成後, 執行重新建立的動作.
1. sudo locale-gen # 執行即可
2. 完成可見: ls /usr/lib/locale # 語系檔資料庫.
原始來源
語系增加在 Debian / Ubuntu Linux 上, 都是編輯 /etc/locale.gen 此檔案, 再執行 locale-gen 即可.
在 Ubuntu Linux 9.10 後, /etc/locale.gen 這個檔案不見了, 設上去也沒有用, 於是來找找新的設定法.
Locales 設定
* 由 "man locale-gen" 可以找到新的設定位置: /var/lib/locales/supported.d/*
* cat /var/lib/locales/supported.d/local # 可以看到目前設定語系
zh_TW.UTF-8 UTF-8
Locales 增加
要增加語系可以有下述兩種做法: (註: 語系列表可見: /usr/share/i18n/SUPPORTED)
1. 手動加入語系
* vim /var/lib/locales/supported.d/zh # 隨意新增一個檔案(zh 這個檔名可隨意命名)
zh_CN.UTF-8 UTF-8
zh_SG.UTF-8 UTF-8
zh_HK.UTF-8 UTF-8
zh_TW.UTF-8 UTF-8
2. 使用 locale-gen 加入語系
1. sudo locale-gen zh_TW
2. sudo locale-gen zh_TW.UTF-8
3. cat /var/lib/locales/supported.d/local # 加入完成後, 可於此檔案看到資訊
重新建立 Locales
上述設定完成後, 執行重新建立的動作.
1. sudo locale-gen # 執行即可
2. 完成可見: ls /usr/lib/locale # 語系檔資料庫.
原始來源
2010/11/01
PHP Check and Validate
<?php
class check{
var $bench_start = 0;
function check(){
}
function check_int($value){
$help = (int)$value;
if(strcmp($help, $value)){
return false;
}
else{
return true;
}
}
function check_empty($value, $type = 1){
if($type == 0){
if(empty($value)){
return true;
}
else{
return false;
}
}
else{
if(!empty($value) || $value == "0"){
return true;
}
else{
return false;
}
}
}
function get_max($value_arr){
$max = $value_arr[0];
$i = 0;
$arr_index = $i;
foreach($value_arr as $val){
if($val > $max){
$max = $val;
$arr_index = $i;
}
$i++;
}
$return["arr_index"] = $arr_index;
$return["max_val"] = $max;
return $return;
}
function get_min($value_arr){
$min = $value_arr[0];
$i = 0;
$arr_index = $i;
foreach($value_arr as $val){
if($val < $min){
$min = $val;
$arr_index = $i;
}
$i++;
}
$return["arr_index"] = $arr_index;
$return["min_val"] = $min;
return $return;
}
function max($value, $max){
if($value > $max){
return false;
}
else{
return true;
}
}
function min($value, $min){
if($value < $min){
return false;
}
else{
return true;
}
}
function max_strlen($string, $max){
if(strlen($string) > $max){
return false;
}
else{
return true;
}
}
function min_strlen($string, $min){
if(strlen($string) < $min){
return false;
}
else{
return true;
}
}
function check_email($value){
$reg_exp="^($-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~�])+@($-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~�]+\\.)+$a-zA-Z]{2,6}\$";
$is_valid = eregi($reg_exp, $value);
if(!$is_valid){
return false;
}
else{
return true;
}
}
function check_plz($value, $check_strlen = 1){
$help = $value;
$first_letter = substr($value, 0, 1);
$is_null = false;
if(!strcmp($first_letter, "0")){
$is_null = true;
}
$plz= (int)$value;
if($is_null){
$plz = "0".$plz;
}
switch($check_strlen){
case 1:
if(strcmp($plz, $help) || strlen($plz) <5){
return false;
}
else{
return true;
}
break;
case 0:
if(strcmp($plz, $help)){
return false;
}
else{
return true;
}
break;
default:
echo "False type for check_strlen";
}
}
function sum($val_array = array(), $sum_val){
$sum = 0;
foreach($val_array as $val){
$sum += $val;
}
if($sum == $sum_val){
return true;
}
else{
return false;
}
}
function check_date($date){
$d = explode(".", $date);
if(strlen(@$d$2]) > 2){
@$d$2] = substr($d$2], strlen($d$2]) - 2 , 2);
}
if(checkdate(@$d$1], @$d$0], @$d$2])){
return true;
}
else{
return false;
}
}
function german_chars($string){
$string = str_replace("A", "Ä", $string);
$string = str_replace("O", "Ö", $string);
$string = str_replace("U", "Ü", $string);
$string = str_replace("a", "ä", $string);
$string = str_replace("o", "ö", $string);
$string = str_replace("u", "ü", $string);
$string = str_replace("s", "ß", $string);
$string = str_replace("e", "é", $string);
return $string;
}
function is_hostname($url){
// (type of stream )(domain ).(tld )
$reg_exp = "/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/)*($a-z]{1,}$\w-.]{0,}).($a-z]{2,6})$/i";
if(!preg_match($reg_exp, $url, $result)){
return false;
}
return true;
}
function is_url($url){
// (type of stream )(domain ).(tld )(scriptname or dirs )
$reg_exp = "/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/)($a-z]{1,}$\w-.]{0,}).($a-z]{2,6})(\/{1}$\w_]{1}$\/\w-&?=_%]{0,}(.{1}$\/\w-&?=_%]{0,})*)*$/i";
if(!preg_match($reg_exp, $url, $result)){
return false;
}
return true;
}
function base_convert($num, $from){
$result["binary"] = base_convert($num, $from, 2);
$result["octal"] = base_convert($num, $from, 8);
$result["decimal"] = base_convert($num, $from, 10);
$result["hex"] = base_convert($num, $from, 16);
return $result;
}
function random_nr($min = 0, $max = 100000000000000){
return (mt_rand($min, $max));
}
function random_text($prefix = "generate_random_id"){
return md5(uniqid($prefix));
}
function microtime(){
$time = microtime();
$time = explode(" ", $time);
return $time[1] + $time[0];
}
function start_benchmark(){
$GLOBALS["bench_start_time"] = check::microtime();
}
function stop_benchmark(){
$GLOBALS["bench_end_time"] = check::microtime();
$time = $GLOBALS["bench_end_time"] - $GLOBALS["bench_start_time"];
$time = explode(".", $time);
$time[1] = substr($time[1], 0, 4);
$days = 0;
$hours = 0;
$mins = 0;
$seconds = $time[0];
while($seconds > 60){
$mins++;
$seconds -= 60;
}
while($mins > 60){
$hours++;
$mins -= 60;
}
while($hours > 24){
$days++;
$hours -= 24;
}
$durability = $days." 耗時 ".$hours." 時 ".$mins." 分 ".$seconds.".".$time[1]." 秒";
echo "<br><b>腳本時間: ".$durability."</b>";
}
function debug($array, $blank=0, $echo_class=0){
$multi = false;
if(is_object($array) && !$echo_class){
echo "<b>調試的對象: ".get_class($array)."</b><br>";
$multi = true;
}
if(is_array($array) && !$echo_class){
echo "<b>調試一個陣列</b><br>";
$multi = true;
}
if(!$multi && !$echo_class){
echo "<b>單變數調試</b><br>";
echo $array;
}
else{
$blanks = "";
for($i=0; $i<$blank; $i++){
$blanks .= " ";
}
while(list($key, $val) = each ($array)){
if(is_array($val) || is_object($val)){
if(is_object($val)){
echo $blanks.$key." => "."<b>".$val." ".get_class($val)."</b><br>";
}
else{
echo $blanks.$key." => "."<b>".$val."</b><br>";
}
debug($val, $blank+1, 1);
}
else{
echo $blanks.$key." => ".$val."<br>";
}
}
}
}
function object_info($object){
$methods = get_class_methods(get_class($object));
$vars = get_class_vars(get_class($object));
echo "<b>概述對象類:".get_class($object)."</b><br>";
echo "<b>父類:".get_parent_class($object)."</b><br>";
echo "<b>概述方法類:<br></b>";
foreach($methods as $method){
echo " ".$method."<br>";
}
echo "<b>概述變量類: (名稱 => 預設值)<br></b>";
foreach($vars as $var => $val){
echo " ".$var." => ".$val."<br>";
}
}
}
?>
<?php
/**
* Validation class for validation of misc strings
*
* @author Sven Wagener <wagener_at_indot_de>
* @include Funktion:_include_
*/
class validate{
var $country_code;
var $string;
/**
* Regular expressions for postcode of the following countries
* at = austria
* au = australia
* ca = canada
* de = german
* ee = estonia
* nl = netherlands
* it = italy
* pt = portugal
* se = sweden
* uk = united kingdom
* us = united states
**/
var $pattern_postcode=array(
'at'=>'^$0-9]{4,4},
'au'=>'^$2-9]$0-9]{2,3},
'ca'=>'^$a-zA-Z].$0-9].$a-zA-Z].\s$0-9].$a-zA-Z].$0-9].',
'de'=>'^$0-9]{5,5},
'ee'=>'^$0-9]{5,5},
'nl'=>'^$0-9]{4,4}\s$a-zA-Z]{2,2},
'it'=>'^$0-9]{5,5},
'pt'=>'^$0-9]{4,4}-$0-9]{3,3},
'se'=>'^$0-9]{3,3}\s$0-9]{2,2},
'uk'=>'^($A-Z]{1,2}$0-9]{1}$0-9A-Z]{0,1}) ?($0-9]{1}$A-Z]{1,2}),
'us'=>'^$0-9]{5,5}$\-]{0,1}$0-9]{4,4}'
);
var $pattern_email='^($a-zA-Z0-9_\-\.]+)@((\$0-9]{1,3}\.$0-9]{1,3}\.$0-9]{1,3}\.)|(($a-zA-Z0-9\-]+\.)+))($a-zA-Z]{2,4}|$0-9]{1,3})(\]?)$ ';
var $pattern_ip='($0-9]{1,3}\.$0-9]{1,3}\.$0-9]{1,3}\.$0-9]{1,3})';
var $pattern_url='^(http|ftp)://(www\.)?.+\.(com|net|org);
/**
* The constructor of the validation class
* @param string $string the string which have to be validated
* @desc The constructor of the validation class
*/
function validate($string){
$this->string=$string;
}
/**
* Validates the string if it consists of alphabetical chars
* @param int $num_chars the number of chars in the string
* @param string $behave defines how to check the string: min, max or exactly number of chars
* @desc Validates the string if it consists of alphabetical chars
*/
function alpha($num_chars,$behave){
if($behave=="min"){
$pattern="^$a-zA-Z]{".$num_chars.",}$";
}else if ($behave=="max"){
$pattern="^$a-zA-Z]{0,".$num_chars."}$";
}else if ($behave=="exactly"){
$pattern="^$a-zA-Z]{".$num_chars.",".$num_chars."}$";
}
return ereg($pattern,$this->string);
}
/**
* Validates the string if it consists of lowercase alphabetical chars
* @param int $num_chars the number of chars in the string
* @param string $behave defines how to check the string: min, max or exactly number of chars
* @desc Validates the string if it consists of lowercase alphabetical chars
*/
function alpha_lowercase($num_chars,$behave){
if($behave=="min"){
$pattern="^$a-z]{".$num_chars.",}$";
}else if ($behave=="max"){
$pattern="^$a-z]{0,".$num_chars."}$";
}else if ($behave=="exactly"){
$pattern="^$a-z]{".$num_chars.",".$num_chars."}$";
}
return ereg($pattern,$this->string);
}
/**
* Validates the string if it consists of uppercase alphabetical chars
* @param int $num_chars the number of chars in the string
* @param string $behave defines how to check the string: min, max or exactly number of chars
* @desc Validates the string if it consists of uppercalse alphabetical chars
*/
function alpha_uppercase($num_chars,$behave){
if($behave=="min"){
$pattern="^$A-Z]{".$num_chars.",}$";
}else if ($behave=="max"){
$pattern="^$A-Z]{0,".$num_chars."}$";
}else if ($behave=="exactly"){
$pattern="^$A-Z]{".$num_chars.",".$num_chars."}$";
}
return ereg($pattern,$this->string);
}
/**
* Validates the string if it consists of numeric chars
* @param int $num_chars the number of chars in the string
* @param string $behave defines how to check the string: min, max or exactly number of chars
* @desc Validates the string if it consists of numeric chars
*/
function numeric($num_chars,$behave){
if($behave=="min"){
$pattern="^$0-9]{".$num_chars.",}$";
}else if ($behave=="max"){
$pattern="^$0-9]{0,".$num_chars."}$";
}else if ($behave=="exactly"){
$pattern="^$0-9]{".$num_chars.",".$num_chars."}$";
}
return ereg($pattern,$this->string);
}
/**
* Validates the string if it consists of alphanumerical chars
* @param int $num_chars the number of chars in the string
* @param string $behave defines how to check the string: min, max or exactly number of chars
* @desc Validates the string if it consists of alphanumerical chars
*/
function alpha_numeric($num_chars,$behave){
if($behave=="min"){
$pattern="^$0-9a-zA-Z]{".$num_chars.",}$";
}else if ($behave=="max"){
$pattern="^$0-9a-zA-Z]{0,".$num_chars."}$";
}else if ($behave=="exactly"){
$pattern="^$0-9a-zA-Z]{".$num_chars.",".$num_chars."}$";
}
return ereg($pattern,$this->string);
}
/**
* Validates the string if its a valid postcode
* @param string $country_code the country code for the country of the postcode (de,en)
* @desc Validates the string if its a valid postcode
*/
function postcode($country_code){
if(array_key_exists($country_code,$this->pattern_postcode)){
return ereg($this->pattern_postcode$country_code],$this->string);
}else{
return false;
}
}
/**
* Validates the string if its a valid email address
* @desc Validates the string if its a valid email adress
*/
function email(){
return ereg($this->pattern_email,$this->string);
}
/**
* Validates the string if its a valid ip address
* @desc Validates the string if its a valid ip address
*/
function ip_address(){
return ereg($this->pattern_ip,$ip);
}
/**
* Validates the string if its a valid URL
* @desc Validates the string if its a valid URL
*/
function url(){
return ereg($this->pattern_url,$ip);
}
}
?>
2010/08/23
Rsyslog Template for Fortigate Traffic
CREATE TABLE IF NOT EXISTS `Fortigate` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`log_time` datetime NOT NULL,
`log_id` int(10) unsigned NOT NULL,
`type` varchar(20) NOT NULL,
`subtype` varchar(20) NOT NULL,
`pri` varchar(20) NOT NULL,
`fwver` varchar(20) NOT NULL,
`vd` varchar(20) NOT NULL,
`msg` varchar(100) NOT NULL,
`action` varchar(20) NOT NULL,
`rem_ip` varchar(15) NOT NULL,
`loc_ip` varchar(15) NOT NULL,
`rem_port` int(10) unsigned NOT NULL,
`loc_port` int(10) unsigned NOT NULL,
`out_intf` varchar(20) NOT NULL,
`cookies` varchar(40) NOT NULL,
`user` varchar(20) NOT NULL,
`group` varchar(20) NOT NULL,
`xauth_user` varchar(20) NOT NULL,
`xauth_group` varchar(20) NOT NULL,
`vpn_tunnel` varchar(20) NOT NULL,
`status` varchar(20) NOT NULL,
`init` varchar(20) NOT NULL,
`mode` varchar(20) NOT NULL,
`dir` varchar(20) NOT NULL,
`stage` int(10) unsigned NOT NULL,
`role` varchar(20) NOT NULL,
`result` varchar(20) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
$template fortigate, "insert into Fortigate (log_time,log_id,type,subtype,pri,fwver,vd,msg,action,rem_ip,loc_ip,rem_port,loc_port,out_intf,cookies,user,group,xauth_user,xauth_group,vpn_tunnel,status,init,mode,dir,stage,role,result) values ('%timegenerated:::date-mysql%','%msg:R,ERE,1,BLANK:log_id=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:type=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:subtype=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:pri=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:fwver=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:vd=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:msg=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:action=([a-zA-Z0-9]+)--end%',%msg:R,ERE,1,BLANK:rem_ip=([0-9]+.[0-9]+.[0-9]+.[0-9]+)--end%,'%msg:R,ERE,1,BLANK:loc_ip=([0-9]+.[0-9]+.[0-9]+.[0-9]+)--end%',%msg:R,ERE,1,ZERO:rem_port=([0-9]+)--end%,%msg:R,ERE,1,ZERO:loc_port=([0-9]+)--end%,
'%msg:R,ERE,1,BLANK:out_intf=([a-zA-Z0-9_]+)--end%',%msg:R,ERE,1,BLANK:cookies=([a-zA-Z0-9]+)--end%,'%msg:R,ERE,1,BLANK:user=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:group=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:xauth_user=([a-zA-Z0-9]+)--end%',%msg:R,ERE,1,BLANK:xauth_group=([a-zA-Z0-9]+)--end%,
%msg:R,ERE,1,BLANK:vpn_tunnel=([a-zA-Z0-9]+)--end%,'%msg:R,ERE,1,BLANK:status=([a-zA-Z0-9]+)--end%',%msg:R,ERE,1,BLANK:init=([a-zA-Z0-9]+)--end%,'%msg:R,ERE,1,BLANK:mode=([a-zA-Z0-9]+)--end%',%msg:R,ERE,1,BLANK:dir=([a-zA-Z0-9]+)--end%,'%msg:R,ERE,1,BLANK:stage=([a-zA-Z0-9]+)--end%',%msg:R,ERE,1,BLANK:role=([a-zA-Z0-9]+)--end%,%msg:R,ERE,1,BLANK:result=([a-zA-Z0-9]+)--end%)", SQL
CREATE TABLE IF NOT EXISTS `Fortigate2` (
`ID` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
`log_time` DATETIME NOT NULL ,
`log_id` INT( 10 ) UNSIGNED NOT NULL ,
`type` VARCHAR( 20 ) NOT NULL ,
`subtype` VARCHAR( 20 ) NOT NULL ,
`pri` VARCHAR( 20 ) NOT NULL ,
`vd` VARCHAR( 20 ) NOT NULL ,
`msg` VARCHAR( 100 ) NOT NULL ,
`action` VARCHAR( 20 ) NOT NULL ,
`user` VARCHAR( 20 ) NOT NULL ,
`status` VARCHAR( 20 ) NOT NULL ,
`reason` VARCHAR( 20 ) NOT NULL ,
`ui` VARCHAR( 20 ) NOT NULL ,
PRIMARY KEY ( `ID` ))
ENGINE = MYISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT =1;
$template fortigate2, "insert into Fortigate2 (log_time,log_id,type,subtype,pri,vd,msg,action,user,status,reason) values ('%timegenerated:::date-mysql%','%msg:R,ERE,1,BLANK:log_id=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:type=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:subtype=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:pri=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:vd=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:msg=([a-zA-Z0-9() .]+)--end%','%msg:R,ERE,1,BLANK:action=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:user="([a-zA-Z0-9]"+)--end%','%msg:R,ERE,1,BLANK:status=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:reason=([a-zA-Z0-9"_]+)--end%')", SQL
2010/08/17
2010/08/15
修改遠端桌面的port
Windows XP『遠端桌面』功能預設以編號3389連接埠作訊息傳輸,但可因應需要而進行修改︰啟動Regedit
,到路徑HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TerminalServer\WinStations\RDP-Tcp
中DWORD值PortNumber,把數值由3389改為任何的數值便可,然後重新開機。
,到路徑HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TerminalServer\WinStations\RDP-Tcp
中DWORD值PortNumber,把數值由3389改為任何的數值便可,然後重新開機。
2010/08/14
2010/08/11
修改 Office 2007 序號 ( Change Office 2007 product license key)
1.關閉所有Office軟體,如:Word、Excel、Access 等
2.執行 regedit,找到此機碼HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Registration\{30120000-0011-0000-0000-0000000FF1CE}
3.在上方最後機碼或許不一樣,但進入該機碼中找到
DigitalProductID
ProductID
4.刪除該二個機碼值
5.開啟任一 Office 軟體,輸入新序號即可
2.執行 regedit,找到此機碼HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Registration\{30120000-0011-0000-0000-0000000FF1CE}
3.在上方最後機碼或許不一樣,但進入該機碼中找到
DigitalProductID
ProductID
4.刪除該二個機碼值
5.開啟任一 Office 軟體,輸入新序號即可
修改 Windows XP CD Key
修改 Windows XP CD Key
微軟在推出了各種打擊盜版的手段,雖然不見得能完全解決盜版的問題,但我個人認為,與其每當微軟推出新政策時上網找解決方法,例不如花小小錢買一套正版 Windows,而一套 Windows XP Home 的 OEM 版也只不過數百元。
當買了正版後,只需換上新的 CD Key,而不需要重新安裝 Windows,以下是修改 XP CD Key 的方法:
1. 按開始功能表選擇 "執行",輸入 "regedit" 並按 Enter。
2. 開啟 HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\Current Version\WPAEvents,選擇 OOBE Timer,按滑鼠右鍵並選擇修改。
3. 最少修改一個機碼,改成什麼都沒問題,目的是要讓 Windows 變成無效。
4. 關閉 Regedit 後,再到 "執行" 並輸入 "%systemroot%\system32\oobe\msoobe.exe /a"。
5. 選擇 "Yes, I want to telephone a customer service representative to activate Windows"。
6. 按 "Change Product key",然後輸入新的 CD Key 及按 Update。
另一個方法則較簡單,直接用軟件去改,Magical Jelly Bean Keyfinder 是修改 XP CD key 的免費軟件。
微軟在推出了各種打擊盜版的手段,雖然不見得能完全解決盜版的問題,但我個人認為,與其每當微軟推出新政策時上網找解決方法,例不如花小小錢買一套正版 Windows,而一套 Windows XP Home 的 OEM 版也只不過數百元。
當買了正版後,只需換上新的 CD Key,而不需要重新安裝 Windows,以下是修改 XP CD Key 的方法:
1. 按開始功能表選擇 "執行",輸入 "regedit" 並按 Enter。
2. 開啟 HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\Current Version\WPAEvents,選擇 OOBE Timer,按滑鼠右鍵並選擇修改。
3. 最少修改一個機碼,改成什麼都沒問題,目的是要讓 Windows 變成無效。
4. 關閉 Regedit 後,再到 "執行" 並輸入 "%systemroot%\system32\oobe\msoobe.exe /a"。
5. 選擇 "Yes, I want to telephone a customer service representative to activate Windows"。
6. 按 "Change Product key",然後輸入新的 CD Key 及按 Update。
另一個方法則較簡單,直接用軟件去改,Magical Jelly Bean Keyfinder 是修改 XP CD key 的免費軟件。
2010/08/10
SQL Server 2008 安裝問題
重新安裝 SQL Server
網路上的評價,SQL Server 2008 比 SQL Server 2005 來得穩定、快速、且省空間,因為實驗室沒有太特殊的需要,我猜想 Express 版本應該就足以應付,所以決定移除原先安裝的 2005,改用 2008。
本來是打算使用「升級」的方式來做程式安裝,因為之前在自己的電腦移除過 SQL Server,不知道是甚麼檔案沒殺乾淨,之後不論甚麼版本的 SQL Server 都無法安裝。不過,機器上的 2005 是 Enterprise 版本,而要安裝的 2008 是 Express 版本,系統並不允許這樣的升級方式1,所以還是只能先移除再安裝。
SQL Server 的移除很笨,使用者必須至「控制台」的「新增或移除程式」手動移除。再安裝,沒有意外地,相同的問題又再發生,安裝一直失敗。
Overall summary:
Final result: SQL Server 安裝失敗。若要繼續,請調查失敗的原因、更正問題、解除安裝 SQL Server,然後重新執行 SQL Server 安裝程式。
Exit code (Decimal): -2068643839
Exit facility code: 1203
Exit error code: 1
Exit message: SQL Server 安裝失敗。若要繼續,請調查失敗的原因、更正問題、解除安裝 SQL Server,然後重新執行 SQL Server 安裝程式。
Start time: 2008-12-03 15:40:32
End time: 2008-12-03 15:42:49
Requested action: Install
Log with failure: C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20081203_153912\Msxml6_Cpu32_1.log
Exception help link: http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=10.0.1600.22
查詢 log,找到錯誤訊息如下:
MSI (s) (AC:04) [15:42:41:687]: Note: 1: 1708
MSI (s) (AC:04) [15:42:41:687]: 產品: MSXML 6.0 Parser (KB933579) — 安裝失敗。
MSI (s) (AC:04) [15:42:41:687]: Windows Installer 已安裝該產品。產品名稱: MSXML 6.0 Parser (KB933579)。產品版本: 6.10.1200.0。產品語言: 1028。安裝成功或錯誤狀態: 1603。
MSI (s) (AC:04) [15:42:41:687]: Cleaning up uninstalled install packages, if any exist
MSI (s) (AC:04) [15:42:41:687]: MainEngineThread is returning 1603
MSI (s) (AC:BC) [15:42:41:796]: No System Restore sequence number for this installation.
=== 停止記錄時間: 2008/12/3 15:42:41 ===
MSI (s) (AC:BC) [15:42:41:796]: User policy value 'DisableRollback' is 0
MSI (s) (AC:BC) [15:42:41:796]: Machine policy value 'DisableRollback' is 0
MSI (s) (AC:BC) [15:42:41:796]: Incrementing counter to disable shutdown. Counter after increment: 0
MSI (s) (AC:BC) [15:42:41:796]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2
MSI (s) (AC:BC) [15:42:41:796]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2
MSI (s) (AC:BC) [15:42:41:796]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\InProgress 3: 2
MSI (s) (AC:BC) [15:42:41:796]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\InProgress 3: 2
MSI (s) (AC:BC) [15:42:41:796]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (s) (AC:BC) [15:42:41:796]: Restoring environment variables
MSI (c) (4C:EC) [15:42:41:796]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (c) (4C:EC) [15:42:41:796]: MainEngineThread is returning 1603
=== Verbose logging stopped: 2008/12/3 15:42:41 ===
回到「新增或移除程式」視窗,發現應用程是列表中有一項「MSXML6 SP2」,移除2以後就可以正確安裝。
Footnotes
1. 若要查詢可行的升級方案,請至 MSDN
2. 重新安裝後記得做更新,將 MSXML6 SP2 再裝回來
網路上的評價,SQL Server 2008 比 SQL Server 2005 來得穩定、快速、且省空間,因為實驗室沒有太特殊的需要,我猜想 Express 版本應該就足以應付,所以決定移除原先安裝的 2005,改用 2008。
本來是打算使用「升級」的方式來做程式安裝,因為之前在自己的電腦移除過 SQL Server,不知道是甚麼檔案沒殺乾淨,之後不論甚麼版本的 SQL Server 都無法安裝。不過,機器上的 2005 是 Enterprise 版本,而要安裝的 2008 是 Express 版本,系統並不允許這樣的升級方式1,所以還是只能先移除再安裝。
SQL Server 的移除很笨,使用者必須至「控制台」的「新增或移除程式」手動移除。再安裝,沒有意外地,相同的問題又再發生,安裝一直失敗。
Overall summary:
Final result: SQL Server 安裝失敗。若要繼續,請調查失敗的原因、更正問題、解除安裝 SQL Server,然後重新執行 SQL Server 安裝程式。
Exit code (Decimal): -2068643839
Exit facility code: 1203
Exit error code: 1
Exit message: SQL Server 安裝失敗。若要繼續,請調查失敗的原因、更正問題、解除安裝 SQL Server,然後重新執行 SQL Server 安裝程式。
Start time: 2008-12-03 15:40:32
End time: 2008-12-03 15:42:49
Requested action: Install
Log with failure: C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20081203_153912\Msxml6_Cpu32_1.log
Exception help link: http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=10.0.1600.22
查詢 log,找到錯誤訊息如下:
MSI (s) (AC:04) [15:42:41:687]: Note: 1: 1708
MSI (s) (AC:04) [15:42:41:687]: 產品: MSXML 6.0 Parser (KB933579) — 安裝失敗。
MSI (s) (AC:04) [15:42:41:687]: Windows Installer 已安裝該產品。產品名稱: MSXML 6.0 Parser (KB933579)。產品版本: 6.10.1200.0。產品語言: 1028。安裝成功或錯誤狀態: 1603。
MSI (s) (AC:04) [15:42:41:687]: Cleaning up uninstalled install packages, if any exist
MSI (s) (AC:04) [15:42:41:687]: MainEngineThread is returning 1603
MSI (s) (AC:BC) [15:42:41:796]: No System Restore sequence number for this installation.
=== 停止記錄時間: 2008/12/3 15:42:41 ===
MSI (s) (AC:BC) [15:42:41:796]: User policy value 'DisableRollback' is 0
MSI (s) (AC:BC) [15:42:41:796]: Machine policy value 'DisableRollback' is 0
MSI (s) (AC:BC) [15:42:41:796]: Incrementing counter to disable shutdown. Counter after increment: 0
MSI (s) (AC:BC) [15:42:41:796]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2
MSI (s) (AC:BC) [15:42:41:796]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2
MSI (s) (AC:BC) [15:42:41:796]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\InProgress 3: 2
MSI (s) (AC:BC) [15:42:41:796]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\InProgress 3: 2
MSI (s) (AC:BC) [15:42:41:796]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (s) (AC:BC) [15:42:41:796]: Restoring environment variables
MSI (c) (4C:EC) [15:42:41:796]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (c) (4C:EC) [15:42:41:796]: MainEngineThread is returning 1603
=== Verbose logging stopped: 2008/12/3 15:42:41 ===
回到「新增或移除程式」視窗,發現應用程是列表中有一項「MSXML6 SP2」,移除2以後就可以正確安裝。
Footnotes
1. 若要查詢可行的升級方案,請至 MSDN
2. 重新安裝後記得做更新,將 MSXML6 SP2 再裝回來
2010/08/04
Atheros AR8131 ethernet driver install in CentOS 5.4 x86_64
Atheros AR8131 ethernet driver install in CentOS 5.4 x86_64
分類:Linux
2010/01/24 21:41
1. Download kmod-atl1e-1.0.1.0-3.el5.elrepo.x86_64.rpm
2. If link error, link here http://elrepo.org/linux/elrepo/el5/x86_64/RPMS/
3. rpm -ivh kmod-atl1e-1.0.1 .0-3.el5.elrepo.x86_64.rpm
4. Reboot the CentOS system
Note:
1. If download the AR8131 for Linux driver from Atheros Web-Site, it just can install in
CentOS 5.3 i686/x86_64; Install in CentOS 5.4, it will have error message and can not
load this driver.
分類:Linux
2010/01/24 21:41
1. Download kmod-atl1e-1.0.1.0-3.el5.elrepo.x86_64.rpm
2. If link error, link here http://elrepo.org/linux/elrepo/el5/x86_64/RPMS/
3. rpm -ivh kmod-atl1e-1.0.1 .0-3.el5.elrepo.x86_64.rpm
4. Reboot the CentOS system
Note:
1. If download the AR8131 for Linux driver from Atheros Web-Site, it just can install in
CentOS 5.3 i686/x86_64; Install in CentOS 5.4, it will have error message and can not
load this driver.
訂閱:
文章 (Atom)