salt.modules.win_ip

The networking module for Windows based systems

salt.modules.win_ip.disable(iface)

Disable an interface

CLI Example:

salt -G 'os_family:Windows' ip.disable 'Local Area Connection #2'
salt.modules.win_ip.enable(iface)

Enable an interface

CLI Example:

salt -G 'os_family:Windows' ip.enable 'Local Area Connection #2'
salt.modules.win_ip.get_all_interfaces()

Return configs for all interfaces

CLI Example:

salt -G 'os_family:Windows' ip.get_all_interfaces
salt.modules.win_ip.get_default_gateway()

Set DNS source to DHCP on Windows

CLI Example:

salt -G 'os_family:Windows' ip.get_default_gateway
salt.modules.win_ip.get_interface(iface)

Return the configuration of a network interface

CLI Example:

salt -G 'os_family:Windows' ip.get_interface 'Local Area Connection'
salt.modules.win_ip.get_subnet_length(mask)

Convenience function to convert the netmask to the CIDR subnet length

CLI Example:

salt -G 'os_family:Windows' ip.get_subnet_length 255.255.255.0
salt.modules.win_ip.is_disabled(iface)

Returns True if interface is disabled, otherwise False

CLI Example:

salt -G 'os_family:Windows' ip.is_disabled 'Local Area Connection #2'
salt.modules.win_ip.is_enabled(iface)

Returns True if interface is enabled, otherwise False

CLI Example:

salt -G 'os_family:Windows' ip.is_enabled 'Local Area Connection #2'
salt.modules.win_ip.raw_interface_configs()

Return raw configs for all interfaces

CLI Example:

salt -G 'os_family:Windows' ip.raw_interface_configs
salt.modules.win_ip.set_dhcp_all(iface)

Set both IP Address and DNS to DHCP

CLI Example:

salt -G 'os_family:Windows' ip.set_dhcp_all 'Local Area Connection'
salt.modules.win_ip.set_dhcp_dns(iface)

Set DNS source to DHCP on Windows

CLI Example:

salt -G 'os_family:Windows' ip.set_dhcp_dns 'Local Area Connection'
salt.modules.win_ip.set_dhcp_ip(iface)

Set Windows NIC to get IP from DHCP

CLI Example:

salt -G 'os_family:Windows' ip.set_dhcp_ip 'Local Area Connection'
salt.modules.win_ip.set_static_dns(iface, *addrs)

Set static DNS configuration on a Windows NIC

Parameters:
  • iface (str) -- The name of the interface to set

  • addrs -- One or more DNS servers to be added. To clear the list of DNS servers pass an empty list ([]). If undefined or None no changes will be made.

Returns:

A dictionary containing the new DNS settings

Return type:

dict

CLI Example:

salt -G 'os_family:Windows' ip.set_static_dns 'Local Area Connection' '192.168.1.1'
salt -G 'os_family:Windows' ip.set_static_dns 'Local Area Connection' '192.168.1.252' '192.168.1.253'
salt.modules.win_ip.set_static_ip(iface, addr, gateway=None, append=False)

Set static IP configuration on a Windows NIC

iface

The name of the interface to manage

addr

IP address with subnet length (ex. 10.1.2.3/24). The ip.get_subnet_length function can be used to calculate the subnet length from a netmask.

gatewayNone

If specified, the default gateway will be set to this value.

appendFalse

If True, this IP address will be added to the interface. Default is False, which overrides any existing configuration for the interface and sets addr as the only address on the interface.

CLI Example:

salt -G 'os_family:Windows' ip.set_static_ip 'Local Area Connection' 10.1.2.3/24 gateway=10.1.2.1
salt -G 'os_family:Windows' ip.set_static_ip 'Local Area Connection' 10.1.2.4/24 append=True