IPSecPol Topics | Next

IPSecPol Syntax


One Stepipsecpol [\\computername] [-?] [flags]

Where:

\\computername
sets policies on that computer. If used, this flag must be the first argument. If not used, the local computer is assumed.

 

note-icon

Note

You must have administrative privileges on the computer specified.

-?
displays an extended usage screen. Run without arguments, IpSecPol displays a basic usage screen.

Other flags are listed under either Dynamic Mode or Static Mode.

Flags for dynamic or static mode (listed under Dynamic Mode below):

One Step-f FilterList [-n NegotiationPolicyList] [-t TunnelAddress] [-a AuthMethodList] [-u] [-soft] [{-dialup | -lan}] [-1s SecurityMethodList] [-1k Phase1RekeyAfter] [-1p]

Flag for dynamic mode only:

One Step[-confirm]

Flags for static mode only:

One Step[-w TYPE:DOMAIN] [-p PolicyName:PollInterval] [-r RuleName] [-x] [-y] [-o]

All flags except -f have defaults. You must usually provide -f to specify to which filters to apply the policy, except with the ûu, ûx, or ûy flags, which delete policies or rules.

Dynamic Mode

Dynamic mode plumbs policy into the Policy Agent, which is active only for the lifetime of the Policy Agent service. This means it will not be active after a restart or stopping of the service. The benefit of dynamic mode is that the policy can co-exist with directory service-based policies, which override any local policy not plumbed by IPSecPol.

Each execution of the tool sets an IPSec rule, an IKE policy, or both. When setting the IPSec policy, think of it as setting an IP Security Rule in the UI. So, if you need to set up a tunnel policy, you will need to execute the tool twice, once for the outbound filters and outgoing tunnel endpoint, and once for the inbound filters and incoming tunnel endpoint.

In dynamic mode, if you use a DNS name that resolves to multiple addresses only the first address in the list is used. This is not a problem in static mode.

Read the filter spec help carefully, it is the most difficult and easiest to confuse. In particular, pay attention to how a protocol is specified.

 

note-icon

Note

References to SHA in IPSecPol refer to the SHA1 algorithm.

Flags for Dynamic or Static Mode

The following flags deal with IPSec policy. If omitted, a default value is used where specified.

-f FilterList
applies a FilterList, which is one or more space separated filterspecs. There is no default. -f is required except with the ûu, ûx, or ûy flags.

      A filterspec is of the format:
      A.B.C.D/mask:port=A.B.C.D/mask:port:protocol

      The Source address is always on the left of the = and the Destination address is always on the right.  

      MIRRORING: If you replace the = with a + two filters will be created, one in each direction.

      mask and port are optional. If omitted, Any port and
      mask 255.255.255.255 will be used for the filter.  

      You can replace A.B.C.D/mask with the following for 
      special meaning:
      0 means My address(es)
      * means Any address
      a DNS name (Note that multiple resolutions are ignored)

      protocol is optional, if omitted, Any protocol is assumed.  If you indicate a protocol, a port must precede it or :: must preceded it. Note that if protocol is specified, it must be the last item in the filter spec. 

      Examples:
      Machine1+Machine2::6 will filter TCP traffic between Machine1 and Machine2
      172.31.0.0/255.255.0.0:80=157.0.0.0/255.0.0.0:80:TCP will filter all TCP traffic from the first subnet, port 80 to the second subnet, port 80

      PASSTHRU and DROP filters: By surrounding a filter specification with (), 
      the filter will be a passthru filter.  If you surround it with [], the 
      filter will be a blocking, or drop, filter. 
      Example: (0+128.2.1.1) will create 2 filters (it's mirrored) that will 
      be exempted from policy.

      You can use the following protocol symbols: ICMP UDP RAW TCP   

      Star notation:
      If you're subnet masks are along octet boundaries, then you
      can use the star notation to wildcard subnets.
      Examples:
      128.*.*.* is same as 128.0.0.0/255.0.0.0
      128.*.* is the same as above
      128.* is the same as above
      144.92.*.* is same as 144.92.0.0/255.255.0.0
-n NegotiationPolicyList
specifies a NegotiationPolicyList, which is one or more space separated IPSec policies in the one of the following forms. The default is ESP[3DES,SHA] ESP[3DES,MD5] ESP[DES,SHA] ESP[DES,MD5].

      ESP[ConfAlg,AuthAlg]RekeyPFS 
      AH[HashAlg] 
      AH[HashAlg]+ESP[ConfAlg,AuthAlg]

      where ConfAlg can be NONE, DES, or 3DES
      and AuthAlg can be NONE, MD5, or SHA
      and HashAlg is MD5 or SHA

      NOTE: ESP[NONE,NONE] is not a supported config
      NOTE: SHA refers the SHA1 hash algorithm

      Rekey is number of KBytes or number of seconds to rekey 
      put K or S after the number to indicate KBytes or seconds, respectively
      Example: 3600S will rekey after 1 hour
      To use both, separate with a slash.
      Example: 3600S/5000K will rekey every hour and 5 MB.

      REKEY PARAMETERS ARE OPTIONAL

      PFS this is OPTIONAL, if it is present it will enable phase 2 perfect
      forward secrecy.  You may use just P for short.
-t TunnelAddress
specifies a tunnel address in one of the following forms. When omitted, TunnelAddress defaults to transport mode.

      A.B.C.D
      DNS name
-a AuthMethodList
specifies a list of space separated auth methods in the following form. The default is KERBEROS.

      A list of space separated auth methods of the form:
      PRESHARE:"preshared key string"
      KERBEROS
      CERT:"CA Info"

      The strings provided to preshared key and CA info ARE case sensitive.
      You can abbreviate the method with the first letter, ie. P, K, or C.
-u
deletes all rules added in dynamic mode.
-soft
allows soft associations. The default is to not allow soft associations.
{-dialup | -lan}
-lan sets policy only for LAN adapters. -dialup sets policy only for dialup adapters. Both are optional: if neither is specified, the default is all adapters.

The following three flags deal with IKE phase 1 policy. An easy way to remember this is that all IKE phase 1 parameters are passed with a 1 in the flag. If no IKE flags are specified, the current IKE policy is used. If there is no current IKE policy, the defaults specified below are used.

-1s SecurityMethodList
specifies a SecurityMethodList, which is one or more space separated SecurityMethods in the following form. The default is 3DES-SHA-2 3DES-MD5-2 DES-SHA-1 DES-MD5-1

      ConfAlg-HashAlg-GroupNum
      where ConfAlg can be DES or 3DES
      and HashAlg is MD5 or SHA
      and GroupNum is:
      1 (Low)
      2 (Med)

      Example: DES-SHA-1
-1k Phase1RekeyAfter
specifies the number of Quick Modes or number of seconds to rekey for phase 1. Put Q or S after the number to indicate Quick Modes or seconds,respectively. The default is no QM limit, 480 minute lifetime. This tag is optional.

      Example: 10Q will rekey after 10 quick modes
      To use both, separate with a slash.
      Example: 10Q/3600S will rekey every hour and 10 quick modes
-1p
enable PFS for phase 1. The default is not enabled.

Flag for Dynamic Mode Only

-confirm
requests confirmation before setting policy. This switch is optional, and can be abbreviated to -c.

Static Mode

In static mode, IPSecPol creates or modifies stored policy. This policy can be used again and will last the lifetime of the store. This is the mode that the IPSec MMC snap-in uses. Static mode is indicated by the -w flag. The following flags are valid only for static mode. The usage for static mode is an extension of dynamic mode, so please read through the dynamic mode section.

Static mode uses most of the dynamic mode syntax, but adds a few flags that enable it work at a policy level as well. Remember, dynamic mode just lets you add anonymous rules to the policy agent. Static mode allows you to create named policies and named rules. It also has some functionality to modify existing policies and rules, provided they were originally created with IpSecPol.

Static mode is designed to provide most of the functionality of the IPSec user interface in a command-line tool, so there are references here to the snap-in.

Static mode requires one change to the dynamic-mode usage. In static mode, pass through and block filters are indicated in the NegotiationPolicyList that is specified by -n. There are three items you can pass in the NegotiationPolicyList that have special meaning:

For static mode, authorized users can modify the ACLs of the storage to give you access. For the local or remote computer case, IP Security policy objects are stored in:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\PolicyAgent\Policy\Local

For the Directory Service case, they are stored in:

CN=IP Security,CN=System,DC=YourDCName,DC=ParentDCName,DC=TopLevelDC

in other words, the IP Security container under the System container.

Flags for Static Mode Only

All static-mode flags are required unless otherwise indicated.

-w TYPE:DOMAIN
writes the policy to storage indicated by TYPE:DOMAIN. This switch is optional.

   TYPE can be either REG for registry or DS for Directory Storage
        if \\machinename was specified and TYPE is REG, will be written
        to the remote machine's registry
   DOMAIN for the DS case only. Indicates the domain name of the
          DS to write to. If omitted, use the domain the local machine is in.
-p PolicyName:PollInterval
names the policy with the string PolicyName. If a policy with this name is already in storage, this rule is added to the policy. Otherwise a new policy is created. If PollInterval is specified, the polling interval for the policy is set.
-r RuleName
names the rule with the string RuleName. If a rule with that name already exists, that rule is modified to reflect the information supplied to IpSecPol. For example, if only -f is specified and the rule exists, only the filters of that rule are replaced.
-x
sets the policy active in the LOCAL registry case. This switch is optional.
-y
sets the policy inactive in the LOCAL registry case. This switch is optional.
-o
delete the policy specified by -p. This switch is optional.
This switch deletes all aspects of the specified policy: do not use it if you have other policies pointing to the objects in that policy.