- How to Find Your IP Address in Linux
- Four ways to find your current IP Address in Linux
- Method # 1: On the Desktop
- Method #2: On the Shell with ip command
- Method # 3: On the Shell with ifconfig command
- Method # 4: On the Shell by using hostname command
- Conclusion
- Karim Buzdar
- How to Get IP Address in Linux
- Finding IP Addresses with ip Command:
- Finding IP Addresses with nmcli:
- Finding IP Addresses with ifconfig Command:
- Finding IP Addresses in GNOME Desktop Environment:
- Finding the Public IP Address of your Server:
- How to Find IP Address in Linux Command Line
- Find IP address in Linux command line
- Other ways to find the IP address of your system in Linux
- Show IP address with hostname command
- Display IP address with nmcli tool
- What about ifconfig?
- Bonus Tip: Finding the public IP address of your system
How to Find Your IP Address in Linux
Many times it happens that you feel the need of knowing the IP address of your device. Internet Protocol address or IP address is a set of numeric digits that are needed to identify your device and enable network communication because all the devices that are connected through a network know each other only through their IP addresses. Moreover, the IP address also specifies the location of a device. So it becomes necessary for you at times to know what is the IP address of whichever device you are using. Now how to find this IP address is the real question. In the article below, we will tell you all the ways through which you can find the IP address of your device while working in Linux environment, in our case Ubuntu 18.04.
Four ways to find your current IP Address in Linux
Following are the four methods through which you can find the IP address of your device:
Method # 1: On the Desktop
The first method of finding the IP address of your device is through the Linux desktop interface. For this, you need to proceed as follows:
Click on your network connection icon (Wi-Fi icon) shown at the top right of the title bar on which Ubuntu Desktop is written. A cascading menu will appear which is shown below:
From the menu shown above, click on Connection Information. A new Connection Information window will appear which is shown below:
In the window shown above, the red highlighted rectangle shows the IP address of your device written in front of IP Address field.
Method #2: On the Shell with ip command
The second method of finding the IP address of your device is through a terminal command. In order to do this, you need to perform the following steps:
First of all, open terminal by pressing Ctrl+ T or you can click on the terminal icon directly if it is shown on your task bar. You can also click on the search icon located on the taskbar and then type Terminal and press enter to open it. The newly opened terminal window is shown below:
Type the command ip addr show in the terminal and press enter.
This command is shown below: Advertisement
As soon as you will press enter, some information will be displayed on the terminal window. From the information shown below in the terminal screen, the highlighted rectangle shows the IP address of your device beside the inet field.
Method # 3: On the Shell with ifconfig command
The third method of finding the IP address of your device is through another terminal command. For this you need to follow the steps mentioned below:
Launch terminal by pressing Ctrl+ T or clicking on the terminal icon or searching for terminal in the search window shown below and pressing enter.
Then type the command:
in the newly opened terminal window and press enter.
As soon as you will press enter, a lot of information will be displayed on the terminal screen. From the displayed information below, the highlighted rectangle shows the IP address of your device besides the field of inet addr.
The ifconfig command works in the same way for finding the IP address of a device using terminal in Linux as ipconfig command works for finding the IP address of a device using command prompt in Windows.
Method # 4: On the Shell by using hostname command
The method four for finding the IP address of your device makes use of yet another terminal command. For this method, you need to follow the following steps:
Launch terminal by pressing Ctrl+ T or clicking on the terminal icon located on the taskbar or search for terminal in the search window and press enter.
When the terminal window will appear, type the command:
and press enter. This command is shown in the following window:
As soon as you will press enter, the IP address of your device will be displayed on the terminal right below your entered command. This is shown below:
Conclusion
By making use of any of the methods listed above, you can find the IP address of your device very easily and enable a very safe and secure network communication through it. IP address gives an identity to your device so that you can recognize it whenever you want to. Once you know the IP address of your device, you are free to interact with any other device that is connected to the same network to which you are connected. I hope that this article will help you a lot in future.
Karim Buzdar
About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn
Источник
How to Get IP Address in Linux
In this article, I am going to show you some of the common ways to find the IP address of your Linux server or workstation. So, let’s get started.
Finding IP Addresses with ip Command:
The ip command is the most popular command for finding the IP addresses assigned to the network interfaces of your Linux server or workstation. You will very likely find this command preinstalled on every modern Linux distribution out there.
To find the IP addresses of all the network interfaces connected to your Linux server or workstation, run the ip command as follows:
As you can see, I have 2 network interface attached to my CentOS 7 server. One is ens33 and the other one is ens37. The ens33 network interface has the IPv4 address 192.168.21.131 and the ens37 network interface has the IPv4 address 192.168.50.1.
The ip command also prints the IPv6 address attached to the network interfaces of your Linux server or workstation.
As you can see, on my CentOS 7 server, the IPv6 address attached to the ens33 network interface is fe80:fd75:7722:6480:6d8f. The same way, the IPv6 address configured to the ens37 network interface is fe80:20c:29ff:feaa:bd0e.
If you want, you can also find the IPv4 or IPv6 address configured to a specific network interface.
For example, to find the IP (IPv4 or IPv6) address of the network interface ens33, run the ip command as follows:
As you can see, the IP addresses of the network interface ens33 is shown only.
Finding IP Addresses with nmcli:
nmcli is the command line tool for configuring Linux network interfaces via Network Manager. You can use it to find the IP addresses configured on the network interfaces on your Linux server or workstation.
To list all the Network Manager network interface connections you have on your Linux server or workstation, run the following command:
As you can see, I have 2 Network manager connections Private (for the interface ens37) and ens33 (for the interface ens33). On Network Manager, you can name your network connections. I have named one here (Private) and left the other (ens33) without naming it anything.
Now, to see the IP addresses configured on the network connection Private, run the nmcli command as follows:
As you can see, the IPv4 (and IPv6 if configured) address is listed. In my case, the IP address is 192.168.50.1.
We can also find the IP addresses of the ens33 (unnamed) network connection with nmcli as follows:
As you can see, the IP address of the ens33 network connection is listed. But something is different here. The network connection ens33 got the IP address via DHCP. That’s why it is in the DHCP4 OPTION.
Finding IP Addresses with ifconfig Command:
ifconfig is a very old command for finding the IP addresses of Linux servers and workstations. It is so old that is it not even installed on any modern Linux distribution by default. I’ve included it here because you might have to maintain very old servers with some old Linux distribution. The command is very simple to use anyway.
To find the IP addresses of all the network interfaces of your Linux server or workstation, run the ifconfig command as follows:
As you can see, the IP addresses of all the network interfaces on my CentOS 7 server is listed.
If you want to list the IP address of any single network interface (let’s say ens33), then run the ifconfig command as follows:
As you can see, the IP address of the ens33 network interface is printed on the console only.
Finding IP Addresses in GNOME Desktop Environment:
If you’re using a graphical desktop environment on your Linux workstation such as GNOME 2 or GNOME 3, then you can find the IP address of you network interface graphically.
On GNOME desktop environment, open the Settings app and click on Network as marked in the screenshot below.
Now, select the network interface which you want to find the IP address of and you should be able to find the IP address of that network interface as you can see in the screenshot below.
Finding the Public IP Address of your Server:
You can use a third party website ifconfig.me to find the public IP address of your Linux server very easily. For this to work, you need to have curl installed on your server.
To find the public IP address of your Linux server, run the following command:
So, that’s how you find the IP address in Linux servers and workstations. Thanks for reading this article.
Источник
How to Find IP Address in Linux Command Line
A Few years back, ifconfig was the favorite way to know IP address in Linux. Unfortunately, ifconfig command has been deprecated. If you try to use this command today, you are most likely to see the following error:
So, how do you find the IP address then? Let me show you how to do that.
Find IP address in Linux command line
Well, you can use the ip command for this purpose. ip command is versatile and can be used for several other things related to networking.
But just to show the IP address, use the command with ip addr, ip a or ip address options (all are same) in the following manner:
And you will see an output like this:
In the above output, you can ignore the first one called lo (loopback). You can see that the IP address is displayed 192.168.1.20. The 24 that follows it is the subnet mask.
That’s it. That’s how you display IP address of host system in Linux command line.
Other ways to find the IP address of your system in Linux
There are more ways to check the IP address in Linux. Let me show you them as well.
Show IP address with hostname command
The hostname command usually displays the hostname of your system. It can also be used to display the IP address of the host:
It will simply display the IP address of the host in the terminal.
Display IP address with nmcli tool
Most Linux distributions come with a Network Manager tool. This tool has a command line interface called nmcli. You can use this nmcli tool to view a number of network configurations.
The IP address can be displayed with:
You should see the IP address in the output.
What about ifconfig?
Actually, you can still use ifconfig command. It is present in net-tools package. You can install it using the package manager of your system. However, use of net-tools is not encouraged so I suggest sticking with the ip command.
In Ubuntu-based distributions, you can install net-tools using this command:
Now you can use the ifconfig command to display the IP address of your system.
The output will be like this:
Again, ifconfig has been deprecated and should not be used.
Bonus Tip: Finding the public IP address of your system
What you saw so far was to display the private IP address of your system. What I mean is that if you use a network router, you are most probably behind a NAT.
The IP address of your system is a private one, used only for communicating with the devices on your sub-network. Any device outside your home/work network won’t be able to find you with this IP address. They need to now the IP address of your router. Your router recognizes your device and communicates via the private IP address.
How do you get your public IP address (IP address of your router)? You’ll have to utilize third party tools.
For example, you can use the host command with OpenDNS and get the public IP address:
The output should be similar to this:
In the end…
I hope this quick tip helped you in finding the IP address of your system in Linux command line. You may also read about finding the gateway IP in Linux.
As always, feel free to provide your feedback and suggestion in the comment section below.
Источник