Two AWS Servers Cannot Ping Each Other. What Is Wrong?

Problem scenario:  You have two AWS instances in the same security group.  The Security Group has rules for "All TCP" associated with both the public IP address (visible in the EC2 portion of the AWS Console) and the private IP address (found when you issue an "ifconfig" at the OS level of the server).  You find that the servers cannot ping each other.  You cannot SSH from one to the other either.

How do you get AWS instances to be able to ping each other?

Root cause:  The AWS Security Group rules are not properly configured for the servers to communicate with each other. There is a difference between "All traffic" and "All TCP." The "Type" options "All TCP" and/or "TCP" will not allow pings to work.  Pings are ICMP echo requests.  

Solution

Do the following:

  1. Find the IP address of each server at the OS level (e.g., with an "ifconfig" command).
  2. Go to "Security Groups" in the AWS Console.
  3. Click on the radio button for the security group that governs the instances (this step will not apply if you only have one security group).
  4. Go to the "Inbound" tab near the bottom then click the "Edit" button.
  5. Create a rule with Type "All traffic", and for the field with the IP address, use one of the IP addresses above with a "/32" at the end.  The result should be like this: x.x.x.x/32
  6. Create a rule with Type "All traffic", and for the field with the IP address, use the other IP address from above with a "/32" at the end.  The result should be like this: x.x.x.x/32
  7. Click save.

Relevant parting tips:

To have a more secure Security Group and have pings work without other communication working, for "Type" use "All ICMP - IPv4" (instead of "All Traffic").  Remember that SSH will not work when you have hardened your Security Group with such a configuration.

The Public IP address is usually not relevant for configuring AWS Security Groups for the purposes of allowing TCP/IP networking between instances. 

Leave a comment

Your email address will not be published. Required fields are marked *