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
curl http://icanhazip.com
Author: Danyal
I'm a skilled programmer specializing in Vue.js/Nuxt.js for front-end development and PHP Laravel for back-end solutions. I have a strong focus on API design and development, complemented by experience in web server setup and maintenance. My versatile expertise ensures seamless creation and maintenance of web applications, covering everything from intuitive user interfaces to robust server-side functionality. Passionate about coding and driven by a lifelong learning mindset, I invite you to explore more at danyal.dk.