How to get the public IP of your computer
Now, in most of circumstances, your computers are behind NAT (Network Address Translation), which means your computer just owns a private IP, and when its traffic goes through your router/firewall, its source IP is replaced with a public IP which is assigned by your NAT server (the router).
Most of us don’t care about how the NAT works…it’s transparent.
You sometimes wonder what the public IP is. Why? Uh…for instance, you wanna access your AWS EC2 instance via SSH so that you have to edit the inbound/outbound rules of the security groups…sign, I know it’s not a very nice example, but that’s what I have right now in my mind.
Any way, here are two ways to know your computer’s public IP:
- Browse this website from your computer: https://www.whatismyip.com/
Or:
2. Run this command: dig +short myip.opendns.com resolver1.opendns.com
Enjoy.