The networking module for Windows based systems
Disable an interface
CLI Example:
salt -G 'os_family:Windows' ip.disable 'Local Area Connection #2'
Enable an interface
CLI Example:
salt -G 'os_family:Windows' ip.enable 'Local Area Connection #2'
Return configs for all interfaces
CLI Example:
salt -G 'os_family:Windows' ip.get_all_interfaces
Set DNS source to DHCP on Windows
CLI Example:
salt -G 'os_family:Windows' ip.get_default_gateway
Return the configuration of a network interface
CLI Example:
salt -G 'os_family:Windows' ip.get_interface 'Local Area Connection'
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
Returns True
if interface is disabled, otherwise False
CLI Example:
salt -G 'os_family:Windows' ip.is_disabled 'Local Area Connection #2'
Returns True
if interface is enabled, otherwise False
CLI Example:
salt -G 'os_family:Windows' ip.is_enabled 'Local Area Connection #2'
Return raw configs for all interfaces
CLI Example:
salt -G 'os_family:Windows' 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'
Set DNS source to DHCP on Windows
CLI Example:
salt -G 'os_family:Windows' ip.set_dhcp_dns 'Local Area Connection'
Set Windows NIC to get IP from DHCP
CLI Example:
salt -G 'os_family:Windows' ip.set_dhcp_ip 'Local Area Connection'
Set static DNS configuration on a Windows NIC
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.
A dictionary containing the new DNS settings
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'
Set static IP configuration on a Windows NIC
The name of the interface to manage
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.
If specified, the default gateway will be set to this value.
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