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

Как посмотреть ip адрес linux debian

  • автор:

Getting the Linux IP address without any package (ifconfig, ip address, etc)

How to get Linux IP address, netmask and gateway without ifconfig or ip commands

Matheus Lozano

Bash Tips and Tricks

Bash Tips and Tricks

bash: ip: command not found
bash: ifconfig: command not found

Explaining how it works

How many times you tried to debug/troubleshoot a Linux with an unprivileged user and you didn’t have net tools or iproute installed? Well, the good news is: You can do it with Bash (ok ok, this not a bash feature :’), without having to install any package.

Many information displayed by those tools are available by the Kernel and most of them doesn’t require a privileged user. Cool, right?

In order to understand how this is possible, we’re going to explore

the IPv4 Routing Subsystem, in specifically the Forwarding Information Base trie (Aka FIB trie). The FIB trie is the main data structure used by the IPv4, it defines the routing trie and can be used by us to collect our IP addresses, gateway IP, netmask, etc.

As I said, very sort :D. Now let’s get our IPs!

The file that contains the routing trie is the /proc/net/fib_trie and you can use the commands below to filter and get only the desired IPs.

It’s important to notice that the first command is removing the *.0 and *.255, if you have a network bigger than /24 (netmask 255.255.255.0) you may not get your desired IPs.

How do I get my IP address from the command line? [duplicate]

I’m using Debian 8. How do I get my external IP address from a command line? I thought the below command would do the job .

but as you can see, it is only revealing the IP address of the machine in the LAN. I’m interested in knowing its IP for the whole world.

3 Answers 3

This would return to you your public IP

roaima's user avatar

You mean whatever routable IP your dsl/cable modem/etc. router has?

You need to either query that device OR ask an outside server what IP it sees when you connect to it. The easiest way of doing that is to search google for «what is my ip» and like the calculation searches, it will tell you in the first search result. If you want to do it from the command line, you’ll need to check the output of some script out there that will echo out the information. The dynamic dns service dyndns.org has one that you can use — try this command

wget http://checkip.dyndns.org -O —

You should get something like

I’ve changed the IP in mine to a generic non-routable and bolded it for you.

If you want just the IP, you’ll need to parse it out of there — quick and dirty, but it works for me. And I’m 100% sure there is a better safer way of doing it.

Как найти свой IP-адрес в Debian

Это руководство предназначено для начинающих пользователей Linux. В нём показано 6 различных способов найти IP-адрес вашей локальной сетевой карты с помощью командной строки, а также рабочего стола GNOME в Debian.

IP-адрес — это уникальный идентификатор, присваиваемый любой системе, подключенной к сети или Интернету, для идентификации и связи. Это очень важная информация, которую нужно знать, чтобы настроить приложения, связанные с сетью, устранить неполадки в сети и разрешить другим пользователям доступ к вашей системе для совместного использования ресурсов.

Обычно существует два типа IP-адресов для сетевых устройств: внешний IP-адрес и внутренний IP-адрес. Внешний IP-адрес — это адрес, который вы получаете при подключении к Интернету и который присваивается вашему маршрутизатору поставщиком услуг Интернета. Внутренний IP-адрес — это адрес, присваиваемый вам маршрутизатором или интернет-устройством, которое позволяет вам подключаться к Интернету.

В этой статье мы расскажем, как найти внутренний IP-адрес в операционной системе на базе Debian. В основном есть два метода его поиска: через графический интерфейс и через командную строку. Мы опишем оба метода и различные команды. Команды, описанные в этой статье, также работают в Ubuntu и Linux Mint.

Поиск внутреннего IP через графический интерфейс

В операционной системе на базе Debian мы можем использовать графический метод, чтобы найти внутренний IP-адрес, назначенный нашей системе. Для этого нажмите на значок сети в правом верхнем углу рабочего стола. Когда появится меню, нажмите на опцию Wired. Следующий скриншот иллюстрирует это.

Поиск внутреннего IP через графический интерфейс Debian

Затем нажмите на опцию Настройки сети.

Настройки проводной сети

Откроется окно сетевых настроек. Чтобы просмотреть настройки проводного или беспроводного соединения, нажмите на значок шестерёнки перед подключённым интерфейсом.

Сетевое подключение

Здесь будут отображены подробные настройки сетевого интерфейса, включая внутренний IP-адрес, MAC-адрес, маршрут по умолчанию и информацию DNS.

IPv4-адрес

Поиск IP-адреса через командную строку

Найти внутренний IP через командную строку гораздо проще, чем графическим методом, поскольку вам не нужно перемещаться по различным окнам. Мы рассмотрим различные команды, которые вы можете использовать для поиска внутреннего IP.

Сначала нам нужно запустить приложение терминала. Для этого перейдите на вкладку «Деятельность» в левом верхнем углу рабочего стола. Затем введите терминал в строке поиска. Когда появится значок терминала, нажмите на него, чтобы запустить его.

Открытие терминала

После того как терминал откроется, попробуйте использовать следующие команды по очереди, чтобы найти внутренний IP-адрес.

Способ № 1: Использование команды IP-адрес

В этом методе вы можете использовать команду IP различными способами, чтобы найти внутренний IP-адрес вашей системы. В терминале введите ip a, ip addr или ip address:

Вывод будет выглядеть примерно так, как показано ниже:

Использование команды ip

Из приведенного выше результата вы можете увидеть IP-адрес в выделенном прямоугольнике вместе с другой информацией.

Способ № 2 Использование команды ifconfig

ifconfig — это наиболее используемая команда в различных дистрибутивах Linux, но сейчас она устарела и поэтому отсутствует в последней версии Debian OS. Тем не менее, мы всё ещё можем использовать её. Для этого нам нужно установить её с помощью команды apt-get. Для этого откройте Терминал и выполните следующую команду:

После установки введите следующую команду, чтобы найти IP-адрес.

Эта команда отображает IP-адреса всех активных сетевых интерфейсов, а также другую информацию.

Результат выполнения команды ifconfig

Чтобы посмотреть IP-адрес конкретного интерфейса, используйте следующий синтаксис команды. Обязательно замените имя_интерфейса на имя вашего интерфейса, например, ens33, eth0 и т.д.

В приведенном ниже выводе вы можете увидеть IP-адрес в выделенном красным прямоугольнике.

IP-адрес, показанный ifconfig

Способ № 3 Использование команды IP route

Команда IP route или ip r на самом деле используется для отображения таблицы маршрутизации в Linux. Однако мы также можем использовать ее для поиска внутреннего IP-адреса. Для этого откройте Терминал и введите в него следующую команду:

В приведенном ниже выводе вы можете увидеть IP-адрес системы.

Использование команды ip route

Способ № 4 Использование команды hostname

Команда hostname на самом деле используется для отображения имени хоста системы. Однако мы также можем использовать ее для отображения IP-адреса нашей системы. Для этого откройте Терминал и введите hostname, за которым следует символ -I, как показано ниже:

Использование команды hostname

5. Использование команды nmcli

Nmcli — это инструмент командной строки, который используется для управления NetworkManager. Вы можете использовать его для отображения IP-адреса сетевого устройства вместе с его статусом. Чтобы использовать эту команду, откройте Терминал и введите следующую команду:

Из приведенного ниже вывода вы можете увидеть IP сетевого интерфейса и другие подробности.

Использование команды nmcli

На скриншоте отмечен IP-адрес.

Заключение

Теперь мы узнали, как найти внутренний IP-адрес в операционной системе на базе Debian. Вы можете использовать либо графический интерфейс пользователя, либо различные методы командной строки, описанные выше. Эти методы также могут быть применены к другим дистрибутивам Linux.

How to find your IP Address on Debian 11

This guide is intended for Linux beginners. It shows 6 different ways to find the IP address of your local network card using the command line as well as the GNOME Desktop on Debian 11.

An IP address is a unique identifier assigned to any system connected to a network or the Internet for identification and communication. It is a very important piece of information to know in order to set up network-related applications, troubleshoot network problems, and allow other users to access your system to share resources.

There are usually two types of IP addresses for a network device: the external IP address and the internal IP address. The external IP address is the address you get when you are connected to the Internet and is assigned to your router by an Internet service provider. The internal IP address is the address assigned to you by your router or Internet device that allows you to connect to the Internet.

In this article, we will explain how to find an internal IP address in a Debian-based operating system. There are mainly two methods to find it: through the GUI and the command line. We will describe both methods and different commands. The commands described in this article also work on Ubuntu and Linux Mint.

We will use Debian 11 to describe the methods described in this article.

Find internal (local) IP via GUI

In a Debian-based operating system, we can use the graphical method to find an internal IP address assigned to our system. To do this, click on the network icon in the upper right corner of your desktop. When the menu appears, click on the Wired option. The following screenshot illustrates this.

Find Internal IP via Debian GUI

Next, click on the Wired Settings option.

Wired Settings

It will launch the network settings window. To view the Wired or wireless connection settings, click on the cog icon in front of the connected interface.

Network Connection

It will display the detailed settings of your network interface including internal IP address, MAC address, default route, and DNS information.

IPv4 address

Find IP-Address on the Command line

Finding the local IP via the command line is much easier than via the graphical method since you don’t have to navigate through different windows. We will take a look at different commands that you can use to find your internal IP.

First, we need to launch the terminal application. To do this, go to the Activities tab in the upper left corner of your desktop. Then type terminal in the search bar. When the terminal icon appears, click on it to launch it.

Open Linux Terminal

Once the Terminal opens, try using the below commands one by one to find the internal IP address.

Method # 1: Using IP address command

In this method, you can use the IP command in different ways to find the internal IP address of your system. In the Terminal, type either ip a, ip addr, or ip address:

The output will look similar to below:

Using ip command

From the above output, you can see the IP address in the highlighted rectangle along with the other information.

Method # 2 Using ifconfig command

ifconfig is the most used command in various Linux distributions but it has now deprecated and therefore missing from the latest Debian OS. However, we can still use it. And for that, we have to install it using apt-get command. Open the Terminal and run the below command in it to do so:

Using ifconfig

Once installed, type the below command to find the IP address.

This command displays the IP address of all active network interfaces including other information.

Result of ifconfig command

To view the IP address of the specific interface, use the following command syntax. Make sure to replace interface_name with your interface name e.g ens33, eth0, etc

In the output below, you can see the IP address in the red highlighted rectangle.

IP address shown by ifconfig

Method # 3 Using IP route command

IP route or ip r command is actually used for displaying the routing table in Linux. However, we can use also use it to find the internal IP address. To do so, open the Terminal and type the below command in it:

In the output below, you can see the IP address of the system.

Using ip route command

Method # 4 Using the hostname command

The hostname command is actually used to display the host name of a system. However, we can also use it to display the IP address of our system. To do, open the Terminal and type hostname followed by –I character as shown below:

Using hostname command

5. Using nmcli command

Nmcli is a command-line tool that is used to control NetworkManager. You can use it to display the IP address of a network device along with its status. To use this command, open the Terminal and enter the following command:

From the output below, you can see the network interface IP along with other details.

Using nmcli command

The IP address has been marked in the screenshot.

Conclusion

Now we have learned how to find an internal IP address in a Debian-based operating system. You can either use the GUI or the various command line methods described above. These methods can also be applied to other Linux distributions.

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

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