skip to Main Content

I’m not looking for the public IP address of CloudShell; I know that I can find it out by hitting some external website.

I would like to find out what my public IP address is when I’m connected to CloudShell.

I’m connected to the internet. I’ve logged into AWS console and opened a new CloudShell session in a browser tab. On a different browser tab, of course, I could visit the external site and see my public IP address, but how do I do it from inside CloudShell?

Purpose: I want to do this programmatically so that one step in our process could be automated (adding the user’s IP to security group).

2

Answers


  1. You can do the same as what you did on the browser – Request an external service to check your public IP.

    But, in the CloudShell case, you have to use another HTTP client like curl instead of a browser. And here is some examples:

    curl https://httpbin.org/ip
    curl icanhazip.com
    curl ifconfig.me
    
    Login or Signup to reply.
  2. For the avoidance of doubt, what is required is to determine the public IP of Laptop from a script running on CloudShell. Something I also haven’t been able to work out. The answer suggested by @hoangdv will obtain the public IP of CloudShell, not Laptop.

    Diagram

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search