Linux view ip address

How to Check Your IP Address in Ubuntu [Beginner’s Tip]

Wonder what’s your IP address? Here are several ways to check IP address in Ubuntu and other Linux distributions.

Wonder what’s your IP address? Here are several ways to check IP addresses in Ubuntu and other Linux distributions. Want to know your Linux system’s IP address? You can use the ip command with the option a like this:

The output is extensive and it shows all the internet interfaces available, including loopback. Identifying the IP address could seem challenging if you are new to it.

1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enx747827c86d70: mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000 link/ether 74:78:27:c8:6d:70 brd ff:ff:ff:ff:ff:ff 3: wlp0s20f3: mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether dc:41:a9:fb:7a:c0 brd ff:ff:ff:ff:ff:ff inet 192.168.1.53/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp0s20f3 valid_lft 82827sec preferred_lft 82827sec inet6 fe80::e1d:d71b:c507:5cc8/64 scope link noprefixroute valid_lft forever preferred_lft forever 

It really is not, actually. And there are other ways to find the IP address. I’ll discuss all this in detail. But first, let’s brush up the basics.

What is an IP Address?

An Internet Protocol address (commonly referred to as the IP address) is a numerical label assigned to each device connected to a computer network (using the Internet Protocol). An IP address serves both the purpose of identification and localisation of a machine.

The IP address is unique within the network, allowing communication between all connected devices.

You should also know that there are two types of IP addresses: public and private. The public IP address is used to communicate over the Internet, the same way your physical address is used for postal mail. However, in the context of a local network (such as a home where a router is used), each device is assigned a unique private IP address within this sub-network. This is used inside this local network without directly exposing the public IP (which the router uses to communicate with the Internet).

Another distinction can be made between IPv4 and IPv6 protocols. IPv4 is the classic IP format, consisting of a basic 4-part structure, with four bytes separated by dots (e.g., 127.0.0.1). However, with the growing number of devices, IPv4 will soon be unable to offer enough addresses. This is why IPv6 was invented, a format that uses 128-bit addresses (compared to the 32-bit IPv4).

Читайте также:  Linux server host file

Checking your IP Address in Ubuntu [Terminal Method]

The fastest and simplest way to check your IP address is by using the ip command. You can use this command in the following fashion:

Display IP Address in Ubuntu Linux

Both commands show the same output. They will show you both IPv4 and IPv6 addresses: You should identify the correct interface and then look beside inet for IPv4 and inet6 for IPv6. For example, inet 192.168.1.53/24 means the IPv4 address is 192.168.1.53.

Just get the IP address

Hostname only shows IP address

It will just give the IP address of the system. Nothing else. There are other ways to check IP addresses in Linux but these two commands are more than enough to serve the purpose.

Long-time users might be tempted to use ifconfig (part of net-tools), but that command is deprecated. Some newer Linux distributions don’t include this package anymore and if you try running it, you’ll see the ifconfig command not found error.

Checking IP address in Ubuntu [GUI Method]

If you are not comfortable with the command line, you can also check the IP address graphically. Open up the Ubuntu Applications Menu (Show Applications in the bottom-left corner of the screen) and search for Settings and click on the icon: Open system settings from Ubuntu Activities OverviewThis should open up the Settings Menu. Go to Network: Open settings for the currently connected network from the gear icon adjacent to the name of that particular connectionPressing on the gear icon next to your connection should open up a window with more settings and information about your link to the network, including your IP address: IP Address details in Ubuntu System SettingsYou can see the IP address of your router as well in the above screenshot. It’s displayed with “Default Route”.

Bonus Tip: Checking your public IP address (for desktop computers)

First of all, to check your public IP address (used for communicating with servers etc.) you can use the curl command. Open up a terminal and enter the following command:

This should simply return your IP address with no additional bulk information. I would recommend being careful when sharing this address since it is equivalent to giving out your personal address.

If curl isn’t installed on your system, simply use sudo apt install curl -y to install curl on Ubuntu-based Linux distributions.

Another simple way you can see your public IP address is by searching for the IP address on Google.

Summary

Here’s a summary of the commands you learned:

Description Command
Show both IPv4 and IPv6 addresses with ip command ip a or ip addr show
Print only IP address using hostname command hostname -I
To check your public IP address (Need curl installed) curl ifconfig.me
Display IP Address with Network Manager tool nmcli -p device show
Use the ifconfig command to display the IP address (Need net-tools installed ) ifconfig -a

Now that you know your system’s IP address, how about getting the gateway IP? Boost your Linux networking skills with these essential commands! In this article, I went through the different ways you can find your IP address in Ubuntu Linux, as well as gave you a basic overview of what IP addresses are used for and why they are so important to us. I also discussed IPv4 and IPv6 briefly. By the way, have you ever wondered why there is no IPv5? I hope you enjoyed this quick guide. Let us know if you found this explanation helpful in the comments section!

Читайте также:  Lsi megaraid storage manager linux

DuckDuckGo hidden features

Hidden Features! 25 Fun Things You Can Do With DuckDuckGo Search Engine

What is TTY in Linux

What is TTY in Linux?

s-tui is used for CPU utilization monitoring

Beautifully Monitor CPU Utilization in Linux Terminal With Stress Terminal UI

FOSS Weekly 23.28

FOSS Weekly #23.28: China’s Linux OS, Linux Exit Codes, Btrfs Origins and More

cp command in Linux

Using cp Command in Linux

Using arrays in bash

Bash Basics Series #5: Using Arrays in Bash

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

Источник

How to find your IP address in Linux

Satellite in a field

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.

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 »
  4. ip route get 1.2.3.4 | awk »
  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).

Читайте также:  Установка wireguard kali linux

Use GNOME activities to locate your Network or Wi-Fi settings

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

Click the gear icon next to the Network you are on

Your IP address is listed in the Network profile.

IP addresses are provided in your Network profile

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.

Источник

Оцените статью
Adblock
detector