windows 本地安全策略 命令行方法

XP下的ipseccmd.exe 需要下载先,请自行google ,关键词 “ipseccmd 下载” ,或者到 http://ishare.iask.sina.com.cn/f/7579277.html下载

下面文章建议看下http://microsoft.cnfan.net/winsystem/3692.html  和 http://technet.microsoft.com/en-us/library/cc739550(WS.10).aspx#BKMK_add_rule

本博客主要目的是 屏蔽 某些ip段对本机80端口的访问,比较适用于windows服务器(如果是windows 2003 ,命令行相应的应该是 ipsec.exe )
命令如下

ipseccmd.exe -w reg -p "phpsir ipsec" -o
ipseccmd.exe -w reg -p "phpsir ipsec" -r "block lijin 1.1" -f 1.1.*.*=*:80:TCP -n BLOCK
ipseccmd.exe -w reg -p "phpsir ipsec" -r "block lijin 2.2" -f 2.2.*.*=*:80:TCP -n BLOCK
ipseccmd.exe -w reg -p "phpsir ipsec" -y

win2003/win7的netsh 方法

netsh ipsec static set policy name="phpsir-deny-policy" assign=n
netsh ipsec static delete policy name="phpsir-deny-policy"

netsh ipsec static add policy name="phpsir-deny-policy"
netsh ipsec static add filteraction name="phpsir-deny" action=block

netsh ipsec static add filter filterlist="deny 1.1.1.1" srcaddr=1.1.1.1 srcport=0 dstaddr=me dstport=0 protocol=0 mirrored=yes
netsh ipsec static add filter filterlist="deny 2.2.2.2" srcaddr=2.2.2.2 srcport=0 dstaddr=me dstport=0 protocol=0 mirrored=yes 

netsh ipsec static add rule name="11111" policy="phpsir-deny-policy" filterlist="deny 1.1.1.1" filteraction="phpsir-deny"
netsh ipsec static add rule name="22222" policy="phpsir-deny-policy" filterlist="deny 2.2.2.2" filteraction="phpsir-deny"   

netsh ipsec static set policy name="phpsir-deny-policy" assign=y

curl 检查服务器是否支持 gzip

http://www.ninjasys.co.uk/linux/using-curl-to-check-if-a-page-is-gzippedcompressed/

方法如下

curl -I -H 'Accept-Encoding: gzip,deflate' -H "Host:域名"  http://ip/url
如果结果是
HTTP/1.1 200 OK
Server: nginx/0.8.52
Date: Tue, 05 Jul 2011 01:28:30 GMT
Content-Type: application/x-javascript
Last-Modified: Tue, 10 Aug 2010 00:33:24 GMT
Connection: keep-alive
Vary: Accept-Encoding
Expires: Thu, 04 Aug 2011 01:28:30 GMT
Cache-Control: max-age=2592000
Content-Encoding: gzip  很好支持

如果没有 Content-Encoding: gzip 就不支持gzip

64位linux安装vsftpd虚拟用户的几点注意

  1. auth required /lib64/security/pam_userdb.so db=/etc/vsftpd_login  注意红色部分!!!
  2. 如果出现登陆503错误,请看 tail -f /var/log/secure 以确定具体是否是因为pam登陆验证的问题
  3. 注意权限方面问题,
  4. google 最好搜索英文 vsftpd virtual user
  5. http://linuxforfun.net/2008/04/05/vsftpd-virtual-users/  可以参考下

apache time_wait 过多,修改 keepalive 解决

最近一朋友的centos apache 2.2 发现大量的ip 出现 time_wait 显现

即 netstat -an | grep “:80″ 的结果大量显现 time_wait

初期以为是 被Ddos 了,后发现即使是就一个ip访问,也产生大量time_wait

遂修改 apache 配置文件 httpd.conf

KeepAlive On
MaxKeepAliveRequests 120
KeepAliveTimeout 15

观察后问题解决

ie下innerHTML 不起作用的时候用的修复

参考来自 http://www.jonefox.com/blog/2009/05/21/internet-explorer-and-the-innerhtml-property/

代码

function replace_html(el, html) {
	if( el ) {
                var oldEl = (typeof el === "string" ? document.getElementById(el) : el);
                var newEl = document.createElement(oldEl.nodeName);

                // Preserve any properties we care about (id and class in this example)
                newEl.id = oldEl.id;
                newEl.className = oldEl.className;

                //set the new HTML and insert back into the DOM
                newEl.innerHTML = html;
                if(oldEl.parentNode)
        	        oldEl.parentNode.replaceChild(newEl, oldEl);
                else
		        oldEl.innerHTML = html;

                //return a reference to the new element in case we need it
                return newEl;
	}
};

参考用法

replace_html(“div_id”,”<div>here is html data<div>”);

centos redhat 关闭不必要的服务

for srv in acpid anacron atd auditd autofs avahi-daemon bluetooth cpuspeed crond cups firstboot gpm haldaemon hidd hplip irqbalance isdn kudzu lm_sensors mcstrans mdmonitor messagebus microcode_ctl netfs nfslock pcscd portmap rawdevices readahead_early restorecond rpcgssd rpcidmapd sendmail setroubleshoot smartd snmpd xfs xinetd yum-updatesd
do
chkconfig $srv off
service $srv stop
done

centos 的vpn客户端配置 备忘

有颜色部分是需要根据情况修改的

1.安装包
yum -y install ppp
yum -y install pptp

2.配置文件
vi /etc/ppp/chap-secrets
——————————————
# Secrets for authentication using CHAP
# client    server    secret            IP addresses

username myvpnpassword” *
——————————————

vi /etc/ppp/peers/myvpn
——————————————
# written by pptpsetup
pty “pptp  vpnserverip –nolaunchpppd”
lock
#noauth
nobsdcomp
nodeflate
name username
remotename myvpn
ipparam myvpn
require-mppe-128
refuse-pap
refuse-chap
refuse-eap
refuse-mschap
——————————————

3.复制命令
cp /usr/share/doc/ppp-2.4.4/scripts/pon /usr/sbin/
cp /usr/share/doc/ppp-2.4.4/scripts/poff /usr/sbin/
chmod +x /usr/sbin/pon /usr/sbin/poff

4.拨vpn
pon myvpn

5)ifconfig 看ppp0

pptp 如果 yum  安装不了,可以到 rpmfind.net 去查

http://rpm.pbone.net/index.php3?stat=3&limit=1&srodzaj=1&dl=40&search=pptp&field[]=1&field[]=2

6.断开连接
poff myvpn