Linux / Unix

How to find you public IP on Ubuntu

If you do not know what is your server’s public IP address is, there are a few methods you can try. Usually, this is the address you use to connect to your server through SSH.

First, you could use the iproute2 tools to get your IP address by typing this:

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

This will give you two or three lines back. They are all correct addresses, but your computer may only be able to use one of them.

An alternative method is to use the curl utility to contact an outside party to tell you how it sees your server. Try following method:

sudo apt install curl
Author: Danyal
I'm working as programmer since 2002. Born, grew up, studied and worked in Pakistan now Im located in Denmark since 2006.