windows ipsec set
1 | 导出IPsec安全策略:Netsh ipsec static exportpolicy file = d:\ExportSecurity.ipsec |
删除所有的安全策略
1
echo ipsec static delete all > c:/temp.ips
建立一个新的安全策略
1
2rem 创建安全策略mrdTomcat
echo ipsec static add policy name = mrdTomcat >> c:/temp.ips创建筛选操作(允许和拒绝)
1
2
3rem 创建筛选操作
echo ipsec static add filteraction name = allow action = permit >> c:/temp.ips
echo ipsec static add filteraction name = deny action = block >> c:/temp.ips创建筛选器并对其设置过滤规则
1
2
3
4
5
6
7
8
9
10
11
12
13
14rem 自身连接
echo ipsec static add filterlist name = allow_me >> c:/temp.ips
echo ipsec static add filter filterlist = allow_me srcaddr = me dstaddr = 10.0.0.0 dstmask = 255.0.0.0 protocol = any mirrored = yes >> c:/temp.ips
echo ipsec static add filter filterlist = allow_me srcaddr = me dstaddr = 127.0.0.1 protocol = any mirrored = yes >> c:/temp.ips
rem 中控连接22
echo ipsec static add filterlist name = allow_22 >> c:/temp.ips
echo ipsec static add filter filterlist = allow_22 srcaddr = 111.206.12.11 dstaddr = me dstport = 22 description = cc_access protocol = TCP mirrored = yes >> c:/temp.ips
echo ipsec static add filter filterlist = allow_22 srcaddr = 220.181.142.11 dstaddr = me dstport = 22 description = cc_access protocol = TCP mirrored = yes >> c:/temp.ips
rem 拒绝其他所有ip
echo ipsec static add filterlist name = deny_all >> c:/temp.ips
echo ipsec static add filter filterlist = deny_all srcaddr = me dstaddr = any dstport = 0 protocol = any mirrored = yes >> c:/temp.ips
echo ipsec static add filter filterlist = deny_all srcaddr = any dstaddr = me dstport = 0 protocol = any mirrored = yes >> c:/temp.ips将筛选器规则加入到安全策略
1
2
3
4echo ipsec static add rule name = allow_me Policy = mrdTomcat filterlist = allow_me filteraction = allow >> c:/temp.ips
echo ipsec static add rule name = allow_22 Policy = mrdTomcat filterlist = allow_22 filteraction = allow >> c:/temp.ips
echo ipsec static add rule name = allow_3389 Policy = mrdTomcat filterlist = allow_3389 filteraction = allow >> c:/temp.ips
echo ipsec static add rule name = deny_all Policy = mrdTomcat filterlist = deny_all filteraction = deny >> c:/temp.ips1
2
3
4rem 连接zabbix
echo ipsec static add filterlist name = allow_zabbix >> c:/temp.ips
echo ipsec static add filter filterlist = allow_zabbix srcaddr = x.x.x.0 srcmask = 255.255.255.0 dstaddr = me dstport = 10050 description = zabbix_to_me protocol = TCP mirrored = yes >> c:/temp.ips
echo ipsec static add filter filterlist = allow_zabbix srcaddr = me dstaddr = any dstport = 10051 description = me_to_zabbix protocol = TCP mirrored = yes >> c:/temp.ips1
2
3
4rem 连接snmp
echo ipsec static add filterlist name = allow_snmp >> c:/temp.ips
echo ipsec static add filter filterlist = allow_snmp srcaddr = x.x.x.0 srcmask = 255.255.255.0 dstaddr = me dstport = 161 description = snmp_to_me protocol = UDP mirrored = yes >> c:/temp.ips
echo ipsec static add filter filterlist = allow_snmp srcaddr = me dstaddr = any dstport = 161 description = me_to_snmp protocol = UDP mirrored = yes >> c:/temp.ips1
2
3
4rem 连接icmp
echo ipsec static add filterlist name = allow_icmp >> c:/temp.ips
echo ipsec static add filter filterlist = allow_icmp srcaddr = x.x.x.0 srcmask = 255.255.255.0 dstaddr = me description = snmp_to_me protocol = ICMP mirrored = yes >> c:/temp.ips
echo ipsec static add filter filterlist = allow_icmp srcaddr = me dstaddr = any description = me_to_icmp protocol = ICMP mirrored = yes >> c:/temp.ips激活安全策略
1
echo ipsec static set policy name = mrdTomcat assign = y >> c:/temp.ips
应用配置
1
netsh -f "c:/temp.ips"
ipsec 参数
1 | C:\Users\Administrator>netsh ipsec static add filter /? |