Как узнать ip linux
Перейти к содержимому

Как узнать ip linux

  • автор:

Как узнать ip linux

Как узнать IP Linux через терминал

Для тех, кто недавно присоединился пользователям ОС Linux, может рано или поздно стать актуальным вопрос: “Как узнать IP адрес компьютера Linux?” или “Как найти IP адрес через терминал?”. Это мы рассмотрим в сегодняшней статье.

Учитывая разнообразие дистрибутивов линукc, а так же GUI оболочек (рабочих столов), скажу сразу, что проще всего узнать какой же IP адрес у нашего ПК, проще всего через терминал. Откроем его. Обычно его можно вызвать комбинацией клавиш Ctrl+Shift+T. Или же зайти в меню с программами и найти его там. На крайний случай можно открыть еще одну сессию с помощью комбинации Ctrl+Alt+F6 (или другие функциональные клавиши от F1 до F7, на одной из сессий запущена GUI, остальные классические текстовые консоли).

Внутренний IP адрес

Способ 1

Теперь введем простую команду:

И видим вывод, что-то вроде этого:

Видим, что у нас есть 3 сетевых интерфейса. 1-ый локальный лупбэк (lo – loopback). 2-й – это Ethernet интерфейс, не подключенный (NO-CARRIER). И 3-ий интерфейс wlp4s0, который принадлежит Wi-Fi адаптеру, у него видим IPv4 адрес 192.168.108.51 (inet) с маской 24.

Способ 2

Следующая, более старая классическая команда (уже отсутствует по-умолчанию в некоторых дистрибутивах):

Получаем такой вывод:

Лично мне такой вывод информации более нравится, данные более быстро воспринимаются. А может это просто привычка �� В общем, видим то же самое по сути. В интерфейсе wlp4s0 IPv4 адрес в строке, начинающейся с inet: 192.168.108.51

Способ 3

Команда hostname с ключем -I:

$ hostname -I
192.168.108.51

В терминале мы получим только локальный IP адрес и больше никакой информации.

Внешний IP адрес

Выше шла речь о внутреннем IP адресе. А что если нам необходимо узнать наш внешний IP, который нам выдал провайдер? Рассмотрим так же несколько способов.

Способ 1

$ wget -qO- ifconfig.co

Способ 3

И совсем не тривиальный пример для новичков, используя NS сервер Google:

$ dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'»‘ ‘< print $2>‘

�� Во всех трех способах в ответ мы получим внешний IP адрес нашего маршрутизатора.

How to Find or Check Your IP Address in Linux

An IP address is a codename assigned to a computer on a network. It works as a postal address, ensuring that network traffic is sent to the correct computer.

In this tutorial you will learn how to find your IP address using a Linux operating system.

Tutorial on how to find your IP address on Linux.

  • A Linux operating system
  • Access to a terminal window/command-line (optional) (CtrlAltT, CtrlAltF2)

Find Your IP Address From the Command Line

There are a few different commands you can use to check your IP address. To run these commands, start by opening a terminal window/command line.

Using the hostname Command

One way to check your IP address from the command-line is by using the following command:

The system will display your internal IP address.

get ip address in linux terminal

Using the ip addr Command

Check your ip address with the ip addr command:

The system will scan your hardware, and display the status for each network adapter you have. Look for an entry that says link/ether. Below it, you should see one of the following:

check ip address with ip addr command in linux

The entries will include one for a wired (Ethernet) adapter and a wireless (Wi-Fi) adapter. You may also have an entry for a virtual adapter. Generally, only one entry will have an IP address listed – that is the one you will want.

Note: The number after the slash – /24 and /64 – specifies the size of the network, and it helps with scanning and mapping network size.

Using the ifconfig Command

The third method to find your IP address involves using the ifconfig command. In the command line, enter the following:

The system will display 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.

Note: When you check your IP address, you may notice the term loopback. This refers to an IP address that returns traffic to the same computer. Usually, the loopback address is 127.0.0.1 . If you see that address listed, either you are looking at the wrong line, or you are not connected to the network.

Read phoenixNAP’s ultimate Linux IP command tutorial with 31 examples to learn more!

Finding Your IP Address in Linux With a GUI

If you are using a point-and-click interface to run your Linux system, you can check your IP address by following these steps:

1. Go to the Application menu and type Settings into the search bar.

2. Click on the Settings icon that appears among the results, as in the image below:

search for settings screenshot in ubuntu

3. Next, find the Network tab in the Settings Menu and click on the Advanced Wired Settings icon.

network settings for finding ip address

4. This opens a new pop-up window with details on wired settings. Here you can find both your IPv4 address and your IPv6 address.

check ip address in wired details

How to Find Public IP Address

To find your public IP address, reach out to an external website.

If you are using a browser, navigate to:

If you are using a command-line or terminal, use a retrieval command like curl or wget to display the external IP address:

example of looking up the public ip

Note: Did you know that when you use curl to connect to an insecure website, the output responds with an error? To resolve it, visit our guide on making curl ignore certificates.

What is a Public/Private IP Address?

Each computer in a network is required to have its own IP address. If two systems have the same IP address, it will generate errors on the network. Most modern networks will detect the problem and prompt you to fix it. However, older networks might get confused, trying to route traffic to both computers.

Most systems will have two different IP addresses:

  • Private IP address: This is the address used on the network. Also, it is the one you will want to use for configuring routing tools. On smaller networks, the internal IP address typically starts with 192.168.x.x. It is dynamically assigned to your computer whenever you connect.
  • Public IP address: This is the IP address that registers on a website when you visit it. When you connect to a small network, your computer connects to a router using an internal IP address. That router, in turn, connects to a bigger network (like an Internet Service Provider), which has its own IP address system.

Note: Learn everything you need to know about public and private IP addresses in our article Public vs. Private IP Address.

Now you know how to find a private and public IP address in Linux using multiple methods.

Each option strikes a balance between speed and complexity. Now you have the flexibility to choose, if you only need your internal IP address, you can use the hostname method. If you need more detailed information, view our article on 31 Linux IP Commands with examples.

Sorry, you have been blocked

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

What can I do to resolve this?

You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.

Cloudflare Ray ID: 7a2570f44be32307 • Your IP: Click to reveal 88.135.219.175 • Performance & security by Cloudflare

How to Find Your IP Address in Linux

Find your current IP Address in Linux

Many times it happens that you feel the need to know 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 a Linux environment, in our case, Ubuntu 22.04. The same commands will work on the new Ubuntu 22.04 version too.

This tutorial will show you how to check your IP address on Linux systems like Ubuntu, Linux Mint and Debian using the command line. I will also explain the differences between private and public IP addresses, discuss the various network interfaces, and explain the ip route command and its role in network address translation.

The first step is to understand the two types of IP addresses: private and public. Private IP addresses are used within a local network or internet connection and cannot be reached from outside of that connection. Public IP addresses, however, can be accessed from anywhere in the world.

If you’re using an Ubuntu system, you can get your personal IP address by using this command: ifconfig . This will list all of your active network interfaces along with their associated private or public IP addresses.

Another way to get your public/private IPs is by entering ip route in the terminal window. This command shows all currently active routes along with their corresponding source/destination networks. You can then use these routes to trace out which devices are connected to your computer’s network interfaces – this includes public/private IPs allocated by DHCP servers such as routers.

Finally, if you’re connected to a router via an ethernet cable or Wi-Fi (wireless) connection, then it’s likely that Network Address Translation (NAT) is being used – this means that requests sent from one machine inside the same local area network are being translated so that they appear as if they came from one single device with a single IPS address when viewed from outside of the LAN. To check if NAT is enabled in your current setup, use tracroute followed by any website domain name (e.g., google.com). The result should show whether or not packets are routed through NAT before reaching their destination web server – if so then NAT is enabled and working correctly!

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) 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:

Network connection Details

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. To do this, you need to perform the following steps:

First, open the terminal by pressing Ctrl+ T or you can click on the terminal icon directly if it is shown on your taskbar. 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:

Open the Linux Terminal

Type the command ip addr show in the terminal and press enter.

This command is shown below:

Show IP address

As soon as you 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 besides the inet field.

Ip address shown beside the inet fiel in ip addr show command output.

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 the 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.

Run ifconfig command

As soon as you 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 beside the field of inet addr.

Ifconfig command result

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 the hostname command

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 the 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 appears, type the command:

and press enter. This command is shown in the following window:

Run hostname -I command

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:

Hostna,e -I command returns the current IP address of the Linux system

Conclusion

By using any of the methods listed above, you can find the IP address of your device very quickly 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 the future.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *