# salt.states.win_network

## Configuration of network interfaces on Windows hosts

Added in version 2014.1.0.

This module provides the `network` state(s) on Windows hosts. DNS servers, IP addresses and default gateways can currently be managed.

Below is an example of the configuration for an interface that uses DHCP for both DNS servers and IP addresses:

    Local Area Connection #2:
      network.managed:
        - dns_proto: dhcp
        - ip_proto: dhcp

Note

Both the `dns_proto` and `ip_proto` arguments are required.

Static DNS and IP addresses can be configured like so:

    Local Area Connection #2:
      network.managed:
        - dns_proto: static
        - dns_servers:
          - 8.8.8.8
          - 8.8.4.4
        - ip_proto: static
        - ip_addrs:
          - 10.2.3.4/24

Note

IP addresses are specified using the format `<ip-address>/<subnet-length>`. Salt provides a convenience function called `ip.get_subnet_length` to calculate the subnet length from a netmask.

Optionally, if you are setting a static IP address, you can also specify the default gateway using the `gateway` parameter:

    Local Area Connection #2:
      network.managed:
        - dns_proto: static
        - dns_servers:
          - 8.8.8.8
          - 8.8.4.4
        - ip_proto: static
        - ip_addrs:
          - 10.2.3.4/24
        - gateway: 10.2.3.1

salt.states.win_network.managed(name, dns_proto=None, dns_servers=None, ip_proto=None, ip_addrs=None, gateway=None, enabled=True, **kwargs)

  Ensure that the named interface is configured properly.

  Parameters:

    - name (str) -- The name of the interface to manage

    - dns_proto (str) -- None Set to `static` and use the `dns_servers` parameter to provide a list of DNS nameservers. set to `dhcp` to use DHCP to get the DNS servers.

    - dns_servers (list) -- None A list of static DNS servers. To clear the list of DNS servers pass an empty list (`[]`). `None` will make no changes.

    - ip_proto (str) -- None Set to `static` and use the `ip_addrs` and (optionally) `gateway` parameters to provide a list of static IP addresses and the default gateway. Set to `dhcp` to use DHCP.

    - ip_addrs (list) -- None A list of static IP addresses with netmask flag, ie: 192.168.0.11/24

    - gateway (str) -- None The gateway to set for the interface

    - enabled (bool) -- True Set to `False` to ensure that this interface is disabled.

  Returns:

    A dictionary of old and new settings

  Return type:

    dict

  Example:

      Ethernet1:
        network.managed:
          - dns_proto: static
          - dns_servers:
            - 8.8.8.8
            - 8.8.8.4
          - ip_proto: static
          - ip_addrs:
            - 192.168.0.100/24

  Clear DNS entries example:

      Ethernet1:
        network.managed:
          - dns_proto: static
          - dns_servers: []
          - ip_proto: dhcp