1. The basic process of IPSec composition and Operation
IP Security Policy list: composed of multiple IP security policies
IP Security Policy: consists of one or more rules
Rule: Consists of an IP filter list and a corresponding filter action
IP Filter list: consists of one or more IP filters
Filter action: Permit or block
Action Flow: Create an IP Security policy--Create a filter action--Create an IP filter List--Create a policy rule--Activate IP Security Policy
2. Complete example
REM emptying strategy
netsh ipsec static del all
REM Create IP Security Policy
netsh ipsec static add policy name=myipsec
REM Create filter action (block and permit)
netsh ipsec static add filteraction name=permit Action=permit
netsh ipsec static add filteraction name=block Action=block
REM first disables all access (Create IP filter lists, create policy rules)
netsh ipsec static add filterlist name=allaccess
netsh ipsec static add filter filterlist=allaccess Srcaddr=me dstaddr=any mirrored=yes
netsh ipsec static add rule name=blockallaccess policy=myipsec filterlist=allaccess Filteraction=block
REM Open some IP unrestricted access (Create IP filter list, create policy rule)
netsh ipsec static add filterlist Name=unlimitedip
netsh ipsec static add filter Filterlist=unlimitedip srcaddr=192.168.120.83 dstaddr=me mirrored=yes
netsh ipsec static add rule Name=allowunlimitedip policy=myipsec filterlist=unlimitedip Filteraction=permit
REM Open Some ports (Create IP filter list, create policy rule)
netsh ipsec static add filterlist Name=opensomeport
netsh ipsec static add filter filterlist=opensomeport srcaddr=any dstaddr=me dstport=3389 protocol=tcp mirrored=yes
netsh ipsec static add rule name=allowopensomeport policy=myipsec filterlist=opensomeport Filteraction=permit
REM open Some IPs can access certain ports (create IP filter lists, create policy rules)
netsh ipsec static add filterlist Name=someipsomeport
netsh ipsec static add filter filterlist=someipsomeport srcaddr=me dstaddr=any protocol=icmp mirrored=yes
netsh ipsec static add filter filterlist=someipsomeport srcaddr=me dstaddr=any dstport=80 protocol=tcp mirrored=yes
netsh ipsec static add filter filterlist=someipsomeport srcaddr=me dstaddr=any dstport=443 protocol=tcp mirrored=yes
netsh ipsec static add filter filterlist=someipsomeport srcaddr=me dstaddr=any dstport=53 protocol=tcp mirrored=yes
netsh ipsec static add filter filterlist=someipsomeport srcaddr=me dstaddr=any dstport=53 protocol=udp mirrored=yes
netsh ipsec static add rule name=allowsomeipsomeport policy=myipsec filterlist=someipsomeport Filteraction=permit
REM Activation IP Security Policy
netsh ipsec static set policy Name=myipsec assign=y
REM ================= End ================
3. Operation Supplement
Delete Rule
netsh ipsec static del rule name=blockallaccess policy=myipsec
Remove filter List
netsh ipsec static add filterlist name=allaccess
Export policy
netsh ipsec static exportpolicy file=d:\myipsec.ipsec
Import Policy
netsh ipsec static importpolicy file=d:\myipsec.ipsc
1. Network Security Tools Netsh IPsec