Linux find IP address

featured image ip address

Usually we will use the https://www.whatismyip.com or search in Google https://www.google.com/search?q=what+is+my+ip to find the public ip address, but if you are using Linux terminal (no browser) then you can use the following commands to find public IP addresses:

curl ifconfig.me
curl -4/-6 icanhazip.com
curl ipinfo.io/ip
curl api.ipify.org
curl checkip.dyndns.org
dig +short myip.opendns.com @resolver1.opendns.com
host myip.opendns.com resolver1.opendns.com
curl ident.me
curl bot.whatismyipaddress.com
curl ipecho.net/plain

If you just want to find the private IP address, then you can use the following commands. (You may need to install some packages)

In Ubuntu:

apt -y install net-tools

then:

ifconfig
ip addr
ip a
hostname -I | awk '{print $1}'
ip route get 1.2.3.4 | awk '{print $7}'
nmcli -p device show

,