- 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
- ИТ База знаний
- Полезно
- Навигация
- Серверные решения
- Телефония
- Корпоративные сети
- Команда IP в Linux: руководство с примерами
- Как использовать команду ip
- Управление и отображение сетевых интерфейсов
- Получить информацию о сетевом интерфейсе
- Изменить статус сетевого интерфейса
- Мониторинг и управление IP-адресами
- Мониторинг IP-адресов
- Как добавить IP-адрес в Linux
- Управление и отображение таблицы IP-маршрутизации
- Показать таблицу маршрутизации IP
- Изменить таблицу IP-маршрутизации
- Отображение и изменение IP-записей соседей
- Отображение IP-адресов соседей
- Изменить IP-записи соседей
- 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
Источник
ИТ База знаний
Курс по Asterisk
Полезно
— Узнать IP — адрес компьютера в интернете
— Онлайн генератор устойчивых паролей
— Онлайн калькулятор подсетей
— Калькулятор инсталляции IP — АТС Asterisk
— Руководство администратора FreePBX на русском языке
— Руководство администратора Cisco UCM/CME на русском языке
— Руководство администратора по Linux/Unix
Навигация
Серверные решения
Телефония
FreePBX и Asterisk
Настройка программных телефонов
Корпоративные сети
Протоколы и стандарты
Команда IP в Linux: руководство с примерами
Все о команде IP
Команда ip — это сетевой инструмент Linux для системных и сетевых администраторов. IP означает Интернет-протокол и, как следует из названия, инструмент используется для настройки сетевых интерфейсов. В старых дистрибутивах Linux использовалась команда ifconfig, которая работает аналогично. Однако ifconfig имеет ограниченный диапазон возможностей по сравнению с командой ip.
Онлайн курс по Linux
Мы собрали концентрат самых востребованных знаний, которые позволят тебе начать карьеру администратора Linux, расширить текущие знания и сделать уверенный шаг к DevOps
В этом руководстве мы рассмотрим все важные операции, которые команда ip может выполнять в Linux.
Как использовать команду ip
Команда ip имеет следующий синтаксис:
К объектам OBJECT (или подкомандам), которые вы будете использовать чаще всего, относятся:
- link (l) — используется для отображения и изменения сетевых интерфейсов
- address (addr/a) — используется для отображения и изменения адресов протокола (IP, IPv6)
- route (r) — используется для отображения и изменения таблицы маршрутизации
- neigh (n) — используется для отображения и управления соседними объектами (таблица ARP)
Они могут использоваться как в полной, так и сокращенной форме.
Есть много других доступных объектов и команд. Чтобы увидеть полный список, введите следующую команду:
Для выполнения команд вы можете использовать либо полную, либо сокращенную формы. Например, ip link и ip l будут давать одинаковые результаты.
При настройке сетевых интерфейсов вы должны запускать команды как пользователь root или пользователь с привилегиями sudo. В противном случае вы увидите сообщение RTNETLINK answers: Operation not permitted
Предупреждение: по умолчанию система не сохраняет изменения перманентно. После перезапуска Linux-сервера вновь измененное состояние будет потеряно. Есть два способа сделать ваши настройки постоянными: добавить команды в сценарий запуска или отредактировать дистрибутивные файлы конфигурации.
Управление и отображение сетевых интерфейсов
Вы можете получить список всех параметров команды link , набрав:
Получить информацию о сетевом интерфейсе
Чтобы увидеть информацию канального уровня обо всех доступных устройствах (у которых загружен драйвер), используйте команду:
Если вы хотите, чтобы команда отображала информацию для одного конкретного устройства, введите следующее:
Чтобы просмотреть статистику по всем сетевым интерфейсам (такие детали, как переданные или отброшенные пакеты или даже ошибки), используйте:
Вы также можете увидеть аналогичную информацию для отдельного сетевого интерфейса:
Если вам нужно больше подробностей, добавьте еще -s в синтаксис:
Чтобы увидеть список только работающих интерфейсов, используйте:
Изменить статус сетевого интерфейса
Если вы хотите включить сетевой интерфейс, используйте команду:
Отключите интерфейс, введя:
Команда ip link позволяет вам изменять очередь передачи, ускоряя или замедляя интерфейсы в соответствии с вашими потребностями и аппаратными возможностями.
Вы можете установить MTU (Maximum Transmission Unit) для улучшения производительности сети:
Чтобы узнать все опции команды link, наберите:
Мониторинг и управление IP-адресами
Узнайте все команды address , набрав следующее:
Мониторинг IP-адресов
Выведите все устройства с помощью следующей команды:
Чтобы вывести список всех сетевых интерфейсов и связанных IP-адресов, используйте команду:
Вы также можете увидеть информацию об отдельной сети:
Чтобы получить список всех IPv4 адресов, используйте:
Чтобы получить список всех IPv6 адресов, используйте:
Как добавить IP-адрес в Linux
Добавьте IP-адрес в интерфейс с помощью команды:
Если указанный интерфейс не существует, отобразится сообщение: Cannot find device [interface]
Чтобы добавить два адреса на один интерфейс также используйте эту команду:
Если вам нужно добавить широковещательный (broadcast) адрес для интерфейса, используйте команду:
Чтобы удалить IP-адрес из интерфейса, выполните следующие действия.
Управление и отображение таблицы IP-маршрутизации
Просмотрите полный список команд ip route с помощью следующей команды:
Показать таблицу маршрутизации IP
Для просмотра всех записей в таблице маршрутизации используйте одну из следующих команд:
С помощью команд, приведенных выше, выходные данные отображают все записи маршрута в ядре. Если вам нужно сузить поиск, добавьте объект SELECTOR :
Чтобы просмотреть маршрутизацию для отдельной сети, используйте следующий синтаксис:
Изменить таблицу IP-маршрутизации
Чтобы добавить новую запись в таблицу маршрутизации, введите команду:
Или вы можете добавить новый маршрут через шлюз, набрав:
Также команда позволяет добавить маршрут для всех адресов через локальный шлюз, добавив параметр default :
Чтобы удалить существующую запись в таблице маршрутизации, используйте команды:
Отображение и изменение IP-записей соседей
При помощи команды ip neigh можно манипулировать таблицами ARP (Address Resolution Protocol). Это аналог команды arp
Для получения полного списка всех параметров команды neigh используйте:
Отображение IP-адресов соседей
Чтобы отобразить таблицы соседей, используйте следующую команду:
Выходные данные показывают MAC-адреса устройств, которые являются частью системы, и их состояние. Состояние устройства может быть:
- REACHABLE — означает валидную, достижимую запись до истечения таймаута.
- PERMANENT — означает постоянную запись, которую может удалить только администратор
- STALE — означает действительную, но недоступную запись
- DELAY — означает, что ядро все еще ожидает проверки из устаревшей записи
Изменить IP-записи соседей
Добавьте новую запись в таблицу с помощью команды:
Или удалите существующую запись ARP:
Онлайн курс по Linux
Мы собрали концентрат самых востребованных знаний, которые позволят тебе начать карьеру администратора Linux, расширить текущие знания и сделать уверенный шаг к DevOps
Источник
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.
Источник