Windows Firewal - Block all inbound ports and allow only configured ones - windows-server-2008-r2

I want to block all inbound traffic to a Windows 2008 R2 server and allow only configured ports (with allow rules).
I've created a rule to block all inbound ports and it works, but it has priority over the allow rules.
How can I achieve that?

Windows firewall has the ability to set a "default action" of inbound connections to "Block" or "Allow."
For your desired configuration, you want to change the default inbound action to "Block" and then add your "Allow" rules.
WARNING: these changes take affect immediately. If you are connecting remotely, and you do not have the needed allow rules in place, you may lose your ability to connect remotely to this machine.
You can change the default inbound action to "Block" in 2008R2 by running the following command:
netsh advfirewall set currentprofile firewallpolicy blockinbound,allowoutbound
Alternately, this can also be set in the "Windows Firewall with Advanced Security" snap-in (run wf.msc from cmd.exe), select "Windows Firewall Properties", choose the correct profile tab, and change "Inbound Connections" to "Block"
NOTE: in the above snap-in instructions, I'm assuming that you understand how to detect which profile (domain, public, or private) is associated with your network. You can open the network and sharing center if you are unsure.

Related

How to setup Azure virtual machine port rules to allow PsExec traffic?

I run PsExec on VirtualMachine01 which connects and perform an action on VirtualMachine02 both hosted in Azure.
That's the command:
PsExec.exe \\VirtualMachine02.publicaddres.com IISReset /restart
In order to allow a traffic through Azure I started with the fastest and the most insecure config. These are the rules I added on Azure in Networking panel:
VirtualMachine01: allow all outbound traffic from any port any protocol
VirutalMachine02: allow all inbound traffic from any port any protocol
How can I set up port rules specifically to the command I run?
I read that PsExec dynamically allocates ports but in Azure there's no way to add firewall rule like Windows Remote Management or Windows COM+ Remote Administration like you could set up directly in Windows.
You need to add the port 135,445 and dynamic port 49152-65535 to the inbound rule of the NSG attached with Virtual Machine02.

Can't access Azure VM HTTP Web Site from Outside of Azure

I've setup a VM and installed IIS. I checked that the firewall rules were enabled for HTTP and HTTPS. Furthermore, in Azure Portal, I've enabled the two predefined inbound security network group rules for HTTP and HTTPS.
When in the VM, I can go to localhost and see the default Web page of IIS Default Web Site.
Inbound security rule in Network Security Group
Anybody know how to go about figuring out how to make this work?
Thx
You should add port 443 and port 80 to azure VM windows firewall inbound rules.
Are the Source port ranges on your inbound rules set to 80/443 or * (i.e. all source ports)?
Try changing them to * with only the destination ports set to 80 or 443 respectively.
Ex:
Refer How to open ports to a virtual machine with the Azure portal for more details.
There are two ways to make your site accessible from the Internet.
Use the public IP address which is associated to the virtual machine's NIC.
Configure DNS for your VM machine (e.g. web.southeastasia.cloudapp.azure.com). This DNS is bounded to the associated public IP Address.
Reference: https://learn.microsoft.com/en-us/azure/virtual-machines/windows/portal-create-fqdn
In your IIS, just configure binding to make sure the incoming request from the Internet is recognized by IIS.
You also need to make sure you have no rule in Network Security Group (NSG) blocking port 80. Or if there is a NSG, you need to create an inbound rule to allow port 80.
I Azure Windows VM, apart from configuring the NSG rule, we should also create a Windows firewall rule to allow inbound TCP connections on the required port. Just RDP into your windows VM, open Windows Defender Firewall and add the rule

Cannot connect FTP to Azure virtual machine

I provisioned a Windows Server 2012 vm in Azure. When I try to connect to it via FileZilla FTP client I get a Could not connect to server error.
Here's what I have tried so far:
Added inbound rule for FTP (TCP/21) in the Azure portal
In IIS, configured FTP Firewall Support. Set Data Channel Port Range to 7000-7002, External IP Address of Firewall to my vm's public IP, added 7000, 7001 and 7002 to inbound rules, did a net start/stop ftpsvc
The step I'm missing in your description, is enabling "FTP server" rules in Windows firewall.
They are created during IIS server installation, but are disabled by default. You have to enable them.
Quoting my guide to Installing a Secure FTP Server on Windows using IIS:
An internal Windows firewall is automatically configured with rules for the ports 21, 990 and 1024-65535, when IIS FTP server is installed.
The rules are not enabled initially though. To enable or change the rules, go to Control Panel > System and Security > Windows Firewall > Advanced Settings > Inbound Rules and locate three “FTP server” rules. If the rules are not enabled, click on Actions > Enable Rule.
If you do not have them, for whatever reason, you have to create them manually. For port 21 and the data ports (in your case 7000-7002).

Azure VM Remote Desktop Can't Connect

Following a how-to book's guide on setting up a VM through the Azure Portal and getting the error when trying to connect
Remote Desktop can't connect to the remote computer for one of these reasons: 1) Remote access to the service is not enabled 2) The remote computer is turned off [Verified through the Azure Portal it is turned on because Start is faded, while Restart and Stop are not] 3) The remote computer is not available on the network.
The error occurs before I'm able to enter any credentials - it doesn't find the IP at all. The RDP file details (IP removed of course):
full address:s:[IPAddress]:3389
prompt for credentials:i:1
administrative session:i:1
What I've tried:
Even though the How-To book doesn't show where/how to specify a port, when I download the RDP file from the Connect option, it specifies the port 3389. The book seems to imply that simply downloading this file and connecting will work and there's no need to specify the port. I get the above error.
Flushed DNS on my computer, ipconfig /flushdns
In the Network Security Group option for the VM, I verified that port 3389 allowed any source and wasn't specific.
I did miss associating the subnet part of the Network Security Group to a virtual network, so I did associate my NSG with the default subnet set up for my Virtual Network.
From the Quick start option, I don't see how to connect to this either; I'm guessing, I need to specify a different port, but don't see where to do it here either => Update: this appears to be in the Network Security Group's Inbound security rules in the Azure portal.
Boot Diagnostics option shows the login screen. A ping to the IP address fails four times with "Request timed out."
Note: this is not a Virtual Machine (classic).
just wanted to share what worked for me.
After receiving an error prompt:
Connect is disabled for this virtual machine because of the following
issues: Network interface 'vmwindows1094': Network security group
'VMWindows10-nsg' does not have inbound security rule that allows port
3389. VMWindows10-nsg
I have added an inbound port rule. Under VM > Settings > Add inbound port rules.
Port: 3389 Protocol/Source/Destination: Any (this can be configured based on your security rules) Action: Allow
On the Azure portal, Select your VM -> Settings -> Boot diagnostics. Make sure that you can see the login screen. You might need to enable diagnostics (under Monitoring section) if not enabled already.
If you don't see the login screen, trying the 'Redeploy' option under 'Support and Troubleshooting' section of settings.
If you can see that the machines has booted correctly, the connectivity issue might be because of a firewall at your end or on the VM. See if you can ping the machine. If you are behind a corporate firewall, try connecting from elsewhere and check your PC's firewall.
Creating a new Virtual Machine on the new portal now creates a NSG (Network Security Group) along with the VM. You should be able to find it under all resources, same name as you VM. Make sure that there is an Inbound rule configured for Remote desktop (it is created by default but might be worth checking).
I had the same problem but adding an inbound security rule was not sufficient (although it is also needed).
I had to go to virtual machines > (myVm) > Reset password and then choose Reset configuration only
Try checking your VM has enough memory.
I had tried all of above suggestions and still didn't manage to access.
After trying many times I managed to get in a message appeared saying:
Your Computer is low on memory
Not 100% sure that was the reason though.
I faced the same issue. I had created an Azure VM but wasn't able to connect to it using RDP.
The culprit was a default "Inbound Port Rule" due to which all the inbound traffic was being blocked.
The solution is to create a new rule by clicking the "Add Inbound Port Rule" and allow traffic from port 3389. Make sure that the priority of this new rule is greater than the "DenyAllInBound" rule otherwise our new rule will not have any effect.
After adding the rule, try connecting to the VM using its public IP in RDP and you should be able to connect.
This worked for me, hope it helps you as well.

Azure port-forwarding issue

I have a virtual machine on azure. On the VM with Windows Server 2012 I have a web-site which is published via IIS7. I wrote bindings for the web-site, changed a port to 8080 and now able to access it with it's ip: 10.0.0.4:8080. Now I want to have an access to this web-site via internet. My VM has static ip, for instance 1.2.3.4. I added a rule on my virtual machine for 8080 for windows firewall, to allow all connections for this port. I suppose now I need to edit binding on the azure manager, I read a lot of articles (e.g. https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-set-up-endpoints/) but I don't have 'Endpoints' menu. The only one I have is: inbound rules and outbound rules, so I've tried to do port-forwarding there (screenshot: http://take.ms/MgLWq). But it doesn't work, I still don't have access from the outside.
Any suggestions?
Thanks in advance
Your link is about endpoints which is only available in the old portal (https://manage.windowsazure.com). From your screenshot I see that you use the new portal (https://portal.azure.com).
What you have to do is the following:
1. In the new portal go to your VM and click on "All settings"
2. Select "Network interfaces" and select the network interface with the public IP address. (Probably there is only one.)
3. Select the "Network security group" and click on "All settings"
4. Select "Inbound security rules"
5. Click "Add" and create a new inbound rule with the following settings:
Name: any name, e.g. "Web"
Priority: any number lower 65500
Source: any or Internet
Protocol: any or TCP
Source port range: * (important difference to your configuration)
Destination: Any
Destination port range: 8080 (IIS' configured port)
Action: Allow
Save it, wait a minute, and that's it.
And here are some screenshots for clarification

Resources