How To Find Your IP Address In Linux

How To Find Your IP Address In Linux

Click the blue text above to follow us

How To Find Your IP Address In Linux

Every website has a unique public IP address that anyone can access from anywhere.

Internet Protocol (IP) needs no introduction — we use it every day. Even if you don’t use it directly, when you type website-name.com in your browser, it looks up the IP address of that URL and then loads the website.

We categorize IP addresses into two types: private and public. Private IP addresses are those provided by your wireless router (and corporate intranet). Their ranges are 10.xxx, 172.16.xx-172.31.xx, and 192.168.xx, where x=0 to 255. Public IP addresses, as the name suggests, are ‘public’ and can be accessed from anywhere in the world. Every website has a unique IP address that anyone can access from any location, which can be considered a public IP address.

Additionally, there are two types of IP addresses: IPv4 and IPv6.

IPv4 address format is x.x.x.x, where x=0 to 255. There are 232 (approximately 4 billion) possible IPv4 addresses.

IPv6 addresses use a more complex hexadecimal format. The total number of bits is 128, which means there are 2128 (340 with 36 zeros!) possible IPv6 addresses. IPv6 has been introduced to solve the foreseeable exhaustion of IPv4 addresses.

As a network engineer, I advise against sharing your machine’s public IP address with anyone. Your WiFi router has a public IP, which is the WAN (Wide Area Network) IP address, and any device connected to that WiFi shares the same public IP address. All devices connected to the same WiFi have the private IP addresses mentioned above. For example, my laptop has the IP address 192.168.0.5, while my phone is 192.168.0.8. These are private IP addresses, but both share the same public IP address.

The following commands will list the IP addresses to find your computer’s public IP address:

  1. ifconfig.me

  2. curl -4/-6 icanhazip.com

  3. curl ipinfo.io/ip

  4. curl api.ipify.org

  5. curl checkip.dyndns.org

  6. dig +short myip.opendns.com @resolver1.opendns.com

  7. host myip.opendns.com resolver1.opendns.com

  8. curl ident.me

  9. curl bot.whatismyipaddress.com

  10. curl ipecho.net/plain

The following commands will provide you with the private IP address of your interface:

  1. ifconfig -a

  2. ip addr (ip a)

  3. hostname -I | awk '{print $1}'

  4. ip route get 1.2.3.4 | awk '{print $7}'

  5. (Fedora) Wifi-Settings→ click the setting icon next to the Wifi name that you are connected to → Both Ipv4 and Ipv6 can be seen

  6. nmcli -p device show

How To Find Your IP Address In Linux

WeChat ID:sannet-edu

Official Website:www.sannet.net

Consultation Hotline:0512-82289966

Address:Room 433, Heji Plaza, 666 Ganjiang East Road, Suzhou

How To Find Your IP Address In Linux

Leave a Comment