windows 10 firewall: block any ip address but one

i have just enabled remote desktop on a windows 10 computer, and in fact when i telnet to 3389 port from any other computer i can reach that service, but what i want is to deny the connection from any computer but a specific one (192.168.0.12), so i have issued the commands below:

netsh advfirewall firewall add rule name="RDP_regla_bloquea_entrada_IN"    dir=in action=block  protocol=tcp localport=3389 remoteip=any description="Deniega RDP IN"
netsh advfirewall firewall add rule name="RDP_regla_bloquea_entrada_OUT"   dir=out action=block protocol=tcp localport=3389 remoteip=any description="Deniega RDP OUT"

netsh advfirewall firewall add rule name="RDP_regla_permite_guacamole_IN"  dir=in action=allow  protocol=tcp localport=3389 remoteip=192.168.0.12 description="Permite RDP guacamole IN"
netsh advfirewall firewall add rule name="RDP_regla_permite_guacamole_OUT" dir=out action=allow protocol=tcp localport=3389 remoteip=192.168.0.12 description="Permite RDP guacamole OUT"

but all connections gets blocked, even if i swap the rules:

netsh advfirewall firewall add rule name="RDP_regla_permite_guacamole_IN"  dir=in action=allow  protocol=tcp localport=3389 remoteip=192.168.0.12 description="Permite RDP guacamole IN"
netsh advfirewall firewall add rule name="RDP_regla_permite_guacamole_OUT" dir=out action=allow protocol=tcp localport=3389 remoteip=192.168.0.12 description="Permite RDP guacamole OUT"

netsh advfirewall firewall add rule name="RDP_regla_bloquea_entrada_IN"    dir=in action=block  protocol=tcp localport=3389 remoteip=any description="Deniega RDP IN"
netsh advfirewall firewall add rule name="RDP_regla_bloquea_entrada_OUT"   dir=out action=block protocol=tcp localport=3389 remoteip=any description="Deniega RDP OUT"

thank you in advance, any help will be appreciated

Answer

Use New-NetFirewallRule with allow action and remoteaddress switch.
https://docs.microsoft.com/en-us/powershell/module/netsecurity/new-netfirewallrule?view=win10-ps

Attribution
Source : Link , Question Author : user3227400 , Answer Author : IshRaj

Leave a Comment