How to find your IP address in Linux (2024)

We all use the Internet Protocol (IP) daily, whether we're aware of it or not. For instance, any time you type a website name or a search term into your web browser, it looks up the IP address of that URL (or of a search engine) and then loads the website.

Let's divide IP addresses into two categories: private and public. Private IP addresses are the ones your WiFi box (and company intranet) provide. They are in the range of 10.x.x.x, 172.16.x.x-172.31.x.x, and 192.168.x.x, where x=0 to 255. Public IP addresses, as the name suggests, are "public" and you can reach them from anywhere in the world. Every website has a unique IP address that can be reached by anyone and from anywhere; that is considered a public IP address.

More Linux resources

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

IPv4 addresses have the format x.x.x.x, where x=0 to 255. There are 2^32 (approximately 4 billion) possible IPv4 addresses.

IPv6 addresses have a more complex format using hex numbers. The total number of bits is 128, which means there are 2^128—340 undecillion!—possible IPv6 addresses. IPv6 was introduced to tackle the foreseeable exhaustion of IPv4 addresses in the near future.

As a network engineer, I recommend not 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 it will be the same for any device connected to that WiFi. All the devices connected to the same WiFi have private IP addresses locally identified by the range provided above. For example, my laptop is connected with the IP address 192.168.0.5, and my phone is connected with 192.168.0.8. These are private IP addresses, but both would have the same public IP address.

The following commands will get you the IP address list to find public IP addresses for your machine:

  1. curl 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 get you the private IP address of your interfaces:

  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 → Ipv4 and Ipv6 both can be seen
  6. nmcli -p device show

Note: Some utilities need to be installed on your system based on the Linux distro you are using. Also, some of the noted commands use a third-party website to get the IP

Finding your IP address in the GNOME desktop

If you're using Linux, you can find your IP address using some basic desktop utilities. First, go to your Activities screen and type Network (for a wired connection) or Wi-Fi (for wireless).

How to find your IP address in Linux (1)

In the Networks settings window, click the Gear icon next to the network you're on.

How to find your IP address in Linux (2)

Your IP address is listed in the Network profile.

How to find your IP address in Linux (3)

In this example screenshot, my IPv4 address is 10.1.1.2 and the gateway is 10.1.1.1.

Public and private IP addresses

To understand the significance of public and private IP addresses, let's have a look at a concept called NAT (Network Address Translation) and PAT (Port Address Translation).

Private addresses are used in Local Area Networks (LAN). They are bound to a specific network.

Public addresses are necessary for establishing external connectivity to other networks, most notably the "Worldwide Web" (www) of the Internet.

NAT is a translation of a private IP to a public one, and consists of three major types: static, dynamic, and PAT. In static NAT, one private IP is mapped to one public IP. A common example ru ydco is a firewall. In dynamic NAT, a private IP address is mapped to a public IP but from a pool of public IP addresses.

With a total of 2^32 IPv4 addresses, out of which approximately just 3.7 billion are public addresses, there are literally more people and devices than there are IP addresses. And yet we haven't run out of addresses. That's because of a concept called PAT, which allows for a single public IP address to be translated from multiple (generally all) private IP addresses using port numbers. Here, instead of assigning a public address to each device, a single public address is allocated to the external side, and private addresses are assigned to each device within the internal network. PAT is most widely used in residential wireless routers, which we use to connect to the Internet.

Private Ipv4 addresses

  • Local addresses are only used within an internal network.

  • The range is 10.x.x.x, 172.16.x.x-172.31.x.x, and 192.168.x.x, (x is a number from 0 to 255).

  • Used in Local Area Networks (LAN).

  • Not globally reachable, and cannot be searched globally.

  • Not unique: the same private IP can be used in two different networks.

  • Each router comes with a private IP address, which multiple devices can connect to. Users don’t need to pay extra to obtain a private address.

  • Some example private IP addresses: 10.0.0.4, 172.16.4.5, 192.168.9.8

Public Ipv4 addresses

  • Public addresses are used to connect to external networks.

  • Ranges from 0.0.0.0 to 255.255.255.255, except for private IP addresses and few unusable or reserved IPs.

  • Used in connecting to the Internet.

  • Globally reachable and can be searched. These are often used to determine geolocation.

  • Unique across all of the Internet.

  • A private address costs money because they are unique, limited, and accessible from the Internet. Each website has a domain name mapped to a public IP. For example, the public IP address for opensource.com is 54.204.39.132

Finding your way with IP

An IP address is the most direct route to a computer over a network. There are other systems, such as DNS and Avahi, to help route one computer to another, but when those are unavailable or undesired for any reason, the IP protocol is what you use. Now you understand why, and more importantly, how to find your own.

Editor's note: This article was originally published in May 2018 and has been updated.

9 Comments

These comments are closed.

How to find your IP address in Linux (4)This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.

How to find your IP address in Linux (2024)

FAQs

How to find your IP address in Linux? ›

Using ifconfig Command

The system displays all network connections, including connected, disconnected, and virtual. Look for the one labeled UP, BROADCAST, RUNNING, MULTICAST to find your IP address. This lists both IPv4 and IPv6 addresses.

How do you find your IP address in Linux? ›

Using ifconfig Command

The system displays all network connections, including connected, disconnected, and virtual. Look for the one labeled UP, BROADCAST, RUNNING, MULTICAST to find your IP address. This lists both IPv4 and IPv6 addresses.

What is the IP command in Linux? ›

The ip command is a Linux networking tool for system and network administrators. IP stands for Internet Protocol and as the name suggests, the tool is used for configuring network interfaces. Older Linux distributions used the ifconfig command, which operates similarly.

How do I find all IP addresses on my network Linux? ›

On Linux, type the command “ifconfig” and press Return. On Windows, type the command “ipconfig” and press Return. Get more information by typing the command “arp -a.” You should now see a basic list of the IP addresses for devices connected to your network.

What is the command to find IP location in Linux? ›

ifconfig Command

ifconfig is the most widely used command for checking the IP address associated with a Linux computer.

How to find IP address? ›

On Android
  1. Swipe one finger down from the top of the screen and long press on the Internet tile to open the internet settings.
  2. Tap the cog icon next to the network you're connected to.
  3. Scroll down and you'll find your IP address under Network details.
May 13, 2023

How to get the IP address? ›

First, click on your Start Menu and type cmd in the search box and press enter. A black and white window will open where you will type ipconfig /all and press enter. There is a space between the command ipconfig and the switch of /all. Your IP address will be the IPv4 address.

How do I find my IP address in terminal? ›

In the Terminal window, type "ifconfig" and press Enter. Locate the section that corresponds to your active network connection (usually labeled "en0" or "en1"). Look for the "inet" line; the number next to it is your computer's IP address.

What is IP address command? ›

From the desktop, navigate through; Start > Run> type "cmd.exe". A command prompt window will appear. At the prompt, type "ipconfig /all". All IP information for all network adapters in use by Windows will be displayed.

What is my local IP address? ›

To check IP address of the local network on the Android device: Go to Settings → Network & internet on the tablet and select Wi-Fi. Tap the name of active network and expand the Advanced section. Find the Network details field with the local IP address.

How do I trace an IP address in Linux terminal? ›

To perform a trace route in Linux open Terminal and type in “traceroute domain.com” replacing domain.com with your domain name or IP address. If you do not have trace route installed you may need to install it. For example in Ubuntu the command to install trace route is “sudo apt-get install traceroute”.

How do I see all network information in Linux? ›

Use netstat

For example, to show all listening TCP and UDP ports with process ID (PID) and numerical address: $ sudo netstat --tcp --udp --listening --programs --numeric Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Addr State PID/Program name tcp 0 0 0.0. 0.0:111 0.0.

How do I see devices on Linux? ›

Basic Linux Commands to Check Hardware and System Information
  1. Printing Machine Hardware Name (uname –m uname –a) ...
  2. lscpu. ...
  3. hwinfo- Hardware Information. ...
  4. lspci- List PCI. ...
  5. lsscsi-List sci devices. ...
  6. lsusb- List usb buses and device details. ...
  7. lsblk- List block devices. ...
  8. df-disk space of file systems.
Dec 26, 2020

How to set IP address in Linux? ›

Setting the IP address in Linux
  1. Make sure that you are logged on as a root user.
  2. Start a terminal session.
  3. Type ifconfig -a at the command prompt. Attention: Record or print the current settings and the eth1 or eth2 interfaces before making changes. ...
  4. Type ifconfig ethx xxx. xxx. ...
  5. Press Enter.
Apr 19, 2023

How do I find my IP address Linux or Windows? ›

  1. Click on the Start menu and select “Settings” (the gear icon).
  2. Within Settings, click on “Network & Internet.”
  3. Select the network connection you're using (Ethernet or Wi-Fi).
  4. Under the “Properties” section, scroll down to find the “IPv4 Address” value. This value represents your IP address.
Jul 7, 2023

Top Articles
Latest Posts
Article information

Author: Pres. Carey Rath

Last Updated:

Views: 5767

Rating: 4 / 5 (61 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Pres. Carey Rath

Birthday: 1997-03-06

Address: 14955 Ledner Trail, East Rodrickfort, NE 85127-8369

Phone: +18682428114917

Job: National Technology Representative

Hobby: Sand art, Drama, Web surfing, Cycling, Brazilian jiu-jitsu, Leather crafting, Creative writing

Introduction: My name is Pres. Carey Rath, I am a faithful, funny, vast, joyous, lively, brave, glamorous person who loves writing and wants to share my knowledge and understanding with you.