Skip to content

Windows Network

DHCP and static IP

Windows DHCP and Static IP with dhcpstaticipcoexistence. You can not do it from GUI. Source

netsh interface ipv4 show interface
netsh interface ipv4 set interface interface="interface name" dhcpstaticipcoexistence=enabled
netsh interface ipv4 add address "interface name" 192.168.x.xxx 255.255.255.0
ipconfig /all

NAT

Set a NAT where all the data from InternalSubnet will be nated to the hosts IP. Can be used to connect another computer to a VPN.

$InternalSubnet = "192.168.250.0/24"

# Stop ICS service (conflicts with New-NetNat)
Stop-Service -Name SharedAccess -Force

# Create the NAT for the internal prefix
New-NetNat -Name NAT -InternalIPInterfaceAddressPrefix $InternalSubnet

# Configure firewall rules to allow forwarding for the internal subnet
New-NetFirewallRule -DisplayName "NAT_Allow_Outbount" -Direction Outbound -Action Allow -LocalAddress $InternalSubnet -RemoteAddress Any -Profile Any
New-NetFirewallRule -DisplayName "NAT_Allow_Inbound"  -Direction Inbound  -Action Allow -LocalAddress $InternalSubnet -RemoteAddress Any -Profile Any

Ports

Get-NetTCPConnection | Where-Object { $_.State -eq "LISTEN" } | select @{Name="Process";Expression={(Get-Process -Id $_.OwningProcess).ProcessName}}, localaddress, localport