salt.modules.win_ip
The networking module for Windows based systems
-
Disable an interface
CLI Example:
salt -G 'os_family:Windows' ip.disable 'Local Area Connection #2'
salt.modules.win_ip.disable(iface)
-
Enable an interface
CLI Example:
salt -G 'os_family:Windows' ip.enable 'Local Area Connection #2'
salt.modules.win_ip.enable(iface)
-
Return configs for all interfaces
CLI Example:
salt -G 'os_family:Windows' ip.get_all_interfaces
salt.modules.win_ip.get_all_interfaces()
-
Set DNS source to DHCP on Windows
CLI Example:
salt -G 'os_family:Windows' ip.get_default_gateway
salt.modules.win_ip.get_default_gateway()
-
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_interface(iface)
-
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.get_subnet_length(mask)
-
Returns
True
if interface is disabled, otherwiseFalse
CLI Example:
salt -G 'os_family:Windows' ip.is_disabled 'Local Area Connection #2'
salt.modules.win_ip.is_disabled(iface)
-
Returns
True
if interface is enabled, otherwiseFalse
CLI Example:
salt -G 'os_family:Windows' ip.is_enabled 'Local Area Connection #2'
salt.modules.win_ip.is_enabled(iface)
-
Return raw configs for all interfaces
CLI Example:
salt -G 'os_family:Windows' ip.raw_interface_configs
salt.modules.win_ip.raw_interface_configs()
-
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_all(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_dns(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_dhcp_ip(iface)
-
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 orNone
no changes will be made.
- Returns
-
A dictionary containing the new DNS settings
- Return type
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_dns(iface, *addrs)
-
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
). Theip.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 isFalse
, which overrides any existing configuration for the interface and setsaddr
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
salt.modules.win_ip.set_static_ip(iface, addr, gateway=None, append=False)
© 2021 SaltStack.
Licensed under the Apache License, Version 2.0.
https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.win_ip.html