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
注解
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
注解
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.
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.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.False to ensure that this interface is disabled.