Ping an EC2 instance from your Local Machine

avatar

Borislav Hadzhiev

Sun Sep 26 20212 min read

banner

Photo by Jason Briscoe

How to Ping an EC2 instance from your Local Machine #

In order to ping an AWS EC2 instance from your local machine:

  1. Open the AWS EC2 console and click on the checkbox next to your EC2 instance
  2. Click on Security and open the security group in a new browser tab

open security group

  1. In the Inbound rules tab of your security group, click on Edit inbound rules

edit inbound rules

  1. Click on the Add rule button and add the following inbound rule:
  • Type: Custom ICMP - IPv4
  • Protocol: Echo Request
  • Port: N/A
  • Source: Anywhere-IPV4

allow ping inbound rule

The security group rule allows ping requests to the EC2 instance from any IP address in the world.

  1. Click save rules
If you want to scope down the IP addresses that are allowed to ping your EC2 instance, for Source select My IP. This will only enable you to ping the instance from your current IP address.
  1. Back in the EC2 console, verify the checkbox next to your EC2 instance is checked
  2. In the Details tab, copy the Public IPv4 DNS address of your instance

copy EC2 public DNS

  1. Use the ping command to ping your EC2 instance from your local machine
shell
ping YOUR_EC2_PUBLIC_DNS

ping request

By default a security group denies all inbound access, so anytime you want to enable access to your EC2 instance, you have to edit its security group.

In our case to allow inbound ping requests to the instance, we had to add a new inbound security group to allow ICMP traffic.

Further Reading #

Join my newsletter

I'll send you 1 email a week with links to all of the articles I've written that week

Buy Me A Coffee