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 skilled programmer with expertise in Vue.js/Nux.js for front-end development and PHP Laravel for back-end development. I excel in building APIs and services, and also have experience in web server setup & maintenance. My versatile skill set allows you to develop and maintain web applications effectively, from the user interface to the server-side functionality. I love coding with never ending learning attitude, thanks for visiting danya.dk