When an intruder scans for an exploitable open port such as port 3389 for Windows or port 22 for Linux on an Elastic Compute Service (ECS) instance, the intruder uses the port to attack the instance. To prevent the attack, you can change the default remote port on the instance or restrict remote access from specific IP addresses to the instance. This topic describes how to use Windows Firewall with Advanced Security (WFAS) to restrict remote access from specific IP addresses to an ECS instance. In this topic, an ECS instance that runs Windows Server 2012 R2 is used.
Background information
The procedure described in this topic is inapplicable to ECS instances that run Windows Server 2016. For ECS instances that run Windows Server 2016, we recommend that you add security group rules to restrict remote access sources. For more information, see Add a security group rule. For information about use cases of security groups, see the "Security group rules for restricting access from instances to external websites" section in Security groups for different use cases.
Use MMC to configure WFAS
Connect to a Windows instance.
For more information, see Connect to a Windows instance by using a password.
Enable the firewall.
Press the shortcut keys Win+R to open the Run window.
Enter
firewall.cpl
and click OK.On the left side of the Windows Firewall window, click Turn Windows Firewall on or off to view the firewall status.
NoteBy default, the firewall is disabled.
Select Turn on Windows Firewall for each network type and click OK.
Check Remote Desktop Protocol (RDP) port 3389.
Press the shortcut keys Win+R to open the Run window.
Enter
wf.msc
and click OK.On the left side of the Windows Firewall with Advanced Security window, click Inbound Rules. The Open RDP Port 3389 inbound rule is displayed, which indicates that the default open port is 3389.
Add RDP port 3389 to Windows Firewall with Advanced Security.
In the Actions section, click New Rule. The New Inbound Rule Wizard dialog box is displayed.
In the Rule Type step, select Port and click Next.
In the Protocol and Ports step, select TCP as the protocol, select Specific local ports option, enter 3389 in the field, and then click Next.
Select Allow the connection and click Next.
Retain the default settings and click Next.
Enter a rule name. In this example,
RemoteDesktop
is used. Click Finish.
Configure the scope.
In the Windows Firewall with Advanced Security window, right-click the inbound rule named
RemoteDesktop
and select Properties.On the Scope tab, select These IP addresses: in the Remote IP Address section, add one or more IP addresses or CIDR blocks, and then click OK.
ImportantAfter the scope parameters are set, remote connections are allowed only from the IP addresses that you specified in the scope.
Verify the scope. Add an IP address to the Remote IP address section. Then, click OK.
If the connection is automatically disconnected, the scope is in effect.
If the connection is unaffected, right-click the
Open RDP Port 3389
inbound rule and select Disable Rule.ImportantIf you disable the
Open RDP Port 3389
inbound rule for port 3389, you cannot connect to the instance by using Workbench. If you want to re-enable port 3389, use Virtual Network Computing (VNC) to connect to the Windows instance and enable theOpen RDP Port 3389
inbound rule. For more information, see Connect to an instance by using VNC.
Connect to the ECS instance by using VNC and replace the remote IP address in the scope with the public IP address of your on-premises computer to restore the connection.
Connect to the Windows instance by using VNC.
For more information, see Connect to an instance by using VNC.
In the scope that is defined in the
RemoteDesktop
inbound rule, change the remote IP address to the public IP address of your on-premises computer. For more information, see the Configure the scope step in this topic.NoteIn this case, only the public IP address of your on-premises computer can be used to connect to the ECS instance. This way, WFAS restricts remote access sources.