文章教程

Windows server 2003服务器设置IP安全策略

5/10/2018 8:20:29 PM 人评论 次浏览

WebjxCom友情提示:Windows server 2003设置IP安全策略批处理脚本。

常用端口

20 ftp传送端口

21 ftp控制端口

53 nds服务端口tcp/utp

80 web服务端口

161 snmp服务端口

1433 mssql

3306 mysql

3389 远程连接

 

#=====================脚本开始=====================

  netsh ipsec static add policy name="10互联默认ip策略" description="本地可以上网,并开放常用端口."

  

#=====================添加策略允许双向ping=============

    netsh ipsec static add filter filterlist="所有ICMP 通讯" srcaddr=me srcmask=255.255.255.255 dstaddr=Any protocol=ICMP

    netsh ipsec static add rule name="所有ICMP 通讯" policy="10互联默认ip策略" filterlist="所有ICMP 通讯"  filteraction="许可"

#=====================添加2个动作,block和permit(拒绝和允许)==

  netsh ipsec static add filteraction name=Permit action=permit

  netsh ipsec static add filteraction name=Block action=block

#===开放某些IP无限制访问任何的端口(UnLimitedIP)ip为125.76.233.185可以访问服务器的任何的端口===

  netsh ipsec static add filterlist name=UnLimitedIP description="开放某些IP无限制访问任何的端口"

  netsh ipsec static add filter filterlist=UnLimitedIP srcaddr=125.76.233.185 dstaddr=Me

  netsh ipsec static add rule name=AllowUnLimitedIP policy="10互联默认ip策略" filterlist=UnLimitedIP filteraction=Permit

#===开放某些ip可以访问某些端口(SomeIPSomePort)ip为125.76.233.185可以访问3389端口,自己可以上网用到对方的80和53端口

  netsh ipsec static add filterlist name=SomeIPSomePort description="开放某些ip可以访问某些端口"

  netsh ipsec static add filter filterlist=SomeIPSomePort srcaddr=Me dstaddr=Any dstport=80 protocol=TCP

  netsh ipsec static add filter filterlist=SomeIPSomePort srcaddr=Me dstaddr=Any dstport=53 protocol=UDP

  netsh ipsec static add filter filterlist=SomeIPSomePort srcaddr=Me dstaddr=Any dstport=53 protocol=TCP   

  netsh ipsec static add filter filterlist=SomeIPSomePort srcaddr=125.76.233.185 dstaddr=Me dstport=3389 protocol=TCP

  netsh ipsec static add rule name=AllowSomeIPSomePort policy="10互联默认ip策略" filterlist=SomeIPSomePort filteraction=Permit

#===开放一些服务需要的端口(OpenSomePort)所有的端口可以是用网站+ftp+远程服务=====================

  netsh ipsec static add filterlist name=OpenSomePort description="开放一些服务需要的端口"

  netsh ipsec static add filter filterlist=OpenSomePort srcaddr=Any dstaddr=Me dstport=20 protocol=TCP

  netsh ipsec static add filter filterlist=OpenSomePort srcaddr=Any dstaddr=Me dstport=21 protocol=TCP

  netsh ipsec static add filter filterlist=OpenSomePort srcaddr=Any dstaddr=Me dstport=80 protocol=TCP

  netsh ipsec static add filter filterlist=OpenSomePort srcaddr=Any dstaddr=Me dstport=1433 protocol=TCP

  netsh ipsec static add filter filterlist=OpenSomePort srcaddr=Any dstaddr=Me dstport=3306 protocol=TCP

  netsh ipsec static add filter filterlist=OpenSomePort srcaddr=Any dstaddr=Me dstport=3389 protocol=TCP

  netsh ipsec static add rule name=AllowOpenSomePort policy="10互联默认ip策略" filterlist=OpenSomePort filteraction=Permit

#===禁止所有访问(AllAccess)=====================

  netsh ipsec static add filterlist name=AllAccess

  netsh ipsec static add filter filterlist=AllAccess srcaddr=Me dstaddr=Any

  netsh ipsec static add rule name=BlockAllAccess policy="10互联默认ip策略" filterlist=AllAccess filteraction=Block

#===激活这个策略=====================

  netsh ipsec static set policy name="10互联默认ip策略" assign=y

教程类别