Not able to access EC2 instance in same VPC via private IP

Viewed 405

I have 2 EC2 instances (one window and one linux) in same subnet. I am trying to access one instance from another via private IP but I am not able to do so.

In security groups, both instances belong to same security groups and security group allows all traffic from the same security group.

I am not even able to ping one instance from another using private IP address.

Any pointers what could be wrong here.

2 Answers

By default the Windows firewall will deny all inbound requests (including ping), but the firewall also contains a list of Exceptions (otherwise it would block everything!). Those Exceptions are a set of rules that describe what connections should be allowed in out-of-the-box.

To allow any additional connections, you just add a new rule to the firewall. There is a Wizard in the Windows Firewall GUI for viewing and creating rules, but i find it easier to use a PowerShell one-liner like this to allow ping:

New-NetFirewallRule -DisplayName "Inbound LAN Ping" -Direction Inbound -Protocol ICMPv4 -IcmpType 8 -RemoteAddress 192.168.1.0/24 -Action Allow

Above will allow any IP's between 192.198.1.1 ... 192.168.1.255 to send ping requests to your Windows host (all other RemoteAddress will still be ignored). I'm assuming here your Linux machine's IP is for example 192.168.1.1 and your Windows machine's IP is 192.168.1.123.

As a rule of thumb, you should only open up the minimal number of ports, to as few IP/IP ranges as possible.

This will likely be the result of Windows firewall being enabled, with default settings it will block ping access (among other things).

Disabling it should enable inbound/outbound access to work for ping. This is a temporary measure and should not be considered a permanent workaround.

You should enable whitelisting in the Windows firewall to allow the ports you would like inbound or outbound to have network access to/from other resources within the network.

More information is available in this link.

Related