Not able to connect to EC2 instance using windows remote desktop, when I'm whitelisting only a single ip

0

I have hosted an EC2 instance on AWS, the instance is protected using 2 security groups, network ACL, and a route table.

network acl inbound rules:

Rule NumberTypeProtocolPort rangeSourceAllow/Deny
10RDP(3389)TCP(6)338949.37.0.0/16Allow

network acl outbound rules:

Rule NumberTypeProtocolPort rangeSourceAllow/Deny
10RDP(3389)TCP(6)338949.37.0.0/16Allow

Security Group 1 inbound rules:

IP versionTypeProtocolPort rangeSource
IPV4RDPTCP338949.37.0.0/16

As security group, allow reverse traffic, I did not add any outbound rule.

Route table routes:

DestinationTargetStatusPropagated
::/0Internet gatewayActiveNo
0.0.0.0/0Internet gatewayActiveNo
1.0.0.0/16localActiveNo

I tried to connect to the EC2 instance using:

  • Windows Remote Desktop from 49.37.10.140/32
  • and telnet at port 3389

but getting an error that the Ec2 instance can't be reached.

Can anyone please let me know, if is there any misconfiguration in the settings that I have done?

1개 답변
2
수락된 답변

There appears to be a problem with the outbound rules of the network ACL.
Network ACLs are stateless security layers.
So we need to add a rule to evaluate the return packet.
Please allow 1024-65535 as ephemeral ports with outbound rule 49.37.10.140/32

network acl outbound rules:

Rule NumberTypeProtocolPort rangedestinationAllow/Deny
10Custom TCPTCP (6)1024 - 6553549.37.10.140/32Allow

https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html

profile picture
전문가
답변함 일 년 전
  • If I'm doing telnet at port 3389, and the request is going to EC2, then why EC2 is not responding back on port 3389?

    Or, if it's responding back on port 3389, and nacl already has outbound rule to allow traffic on port 3389, then why is the request failing?

  • When communicating from the client to the destination, the client is assigned one of the ephemeral ports (1024-65535) as the source port.
    So after communicating to the destination port (3389 in this case), the return destination port will be one of 1024-65535 and must be allowed in the network ACL.
    Even though port 3389 is allowed in the outbound rules, the destination port of return does not match, so it is denied

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠