Current IP Check

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 .

myuser@myserver:~ $ /sbin/ifconfig $1 | grep "inet\|inet6" | awk -F' ' '' | awk '' addr:192.168.0.114 addr: addr:127.0.0.1 addr: 

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

dig TXT +short o-o.myaddr.l.google.com @ns1.google.com 

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

HTTP request sent, awaiting response. 200 OK Length: 105 [text/html] Saving to: ‘STDOUT’ - 0%[ ] 0 --.-KB/s Current IP Address: 192.168.1.199 - 100%[===================>] 105 --.-KB/s in 0s 2017-09-20 14:16:00 (15.4 MB/s) - written to stdout [105/105] 

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.

wget http://checkip.dyndns.org -O — | grep IP | cut -f 2- -d : | cut -f 1 -d \

Источник

Как узнать IP адрес, используя командную строку Linux

Определить IP адрес в Linux

Раньше для просмотра текущих сетевых интерфейсов и их параметров (включая IP-адреса), использовалась команда ifconfig. Но она уже несколько лет как устарела, и в современных дистрибутивах Linux не поддерживается.

Вместо ifconfig рекомендуется использовать команду ip

Определяем IP-адрес командой ip

Чтобы определить IP-адрес вашего сетевого интерфейса можно использовать команду ip address (или эквивалентный вызов ip addr или просто ip a ).

ip address 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: enp2s0: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:24:1d:83:da:25 brd ff:ff:ff:ff:ff:ff inet 192.168.2.2/24 brd 192.168.2.255 scope global dynamic noprefixroute enp2s0 valid_lft 76434sec preferred_lft 76434sec inet6 fe80::1f6e:e0e4:27d1:e643/64 scope link noprefixroute valid_lft forever preferred_lft forever 

Команда ip address Linux

В результате выполнения команды на экран будет выведен список текущих сетевых интерфейсов и их параметры. Первый интерфейс в списке обычно lo — это loopback интерфейс (нас он сейчас не интересует). Нас интересует Ethernet-интерфейс или WiFi-интерфейс (в зависимости от того, какое у вас подключение).

Читайте также:  Digital forensics with kali linux pdf

Ethernet интерфейсы обычно имеют имена вида enp2s0 или eth0, а WiFi-интерфейсы имеют имена вида wlp2s0 или wlan0 (цифры в названии могут отличаться).

Найдите интересующий вас интерфейс в списке. Его IP-адрес выводится на строке inet ..

В нашем примере это inet 192.168.2.2/24 . 192.168.2.2 — это IP-адрес. 24 — это маска подсети, соответствующая маске 255.255.255.0.

Определяем IP-адрес командой hostname

Воспользуемся командой hostname , чтобы вывести IP-адрес. Используем ключ -I

Команда выводит все сетевые адреса хоста (системы), кроме loopback интерфейса. Если у вас всего одно сетевое соединение, то, скорее всего, будет выведен один IP-адрес.

Через графическую утилиту

Хотя эта заметка рассматривает способы определения IP-адреса через командную строку, иногда проще посмотреть текущий IP-адрес через графические программы. В Ubuntu Linux это можно сделать в Параметрах системы в разделе Сеть .

Источник

How to find your IP Address on Debian

Debian Find IP

This guide is intended for Linux beginners. It shows six 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 and Debian 12.

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

Читайте также:  Linux remove empty line

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

$ /sbin/ifconfig interface_name

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:

Читайте также:  Commands in linux with syntax

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.

About This Site

Vitux.com aims to become a Linux compendium with lots of unique and up to date tutorials.

Latest Tutorials

Источник

Linux Basics: 3 Ways to find your local IP Address in Debian 11

Find IP Address Debian 11

In our daily computer work, we need to know the IP address of our machine from time to time. This tutorial lists three ways you can use to find the IP address of your local network card in Debian 11 with the help of the terminal.

Using ifconfig command

A widely used command to find a network configuration is the ifconfig command. If it is not installed on your machine (which was the case on my system), you can install it by following the procedure.

Open the terminal with root privileges and execute the following command to install net-tools packages.

Wait for the command to finish.

When you have successfully installed the ifconfig command on your machine, execute it on the terminal.

Get IP address using ifconfig command

You will see which IP address is bound to which network interface. This is your private IP address. If you want to check the network configuration for a particular interface, the command should look like the following.

Replace with the interface that you like to look up. In my example, the network interface is ens33.

List the IP address for a specific network interface

You will get a list of all private IP addresses on this interface.

Using ip addr command

The second command you can use to find an IP addresses is the ip command. Execute “ip addr” on the terminal.

Linux ip addr command

You will see which IP is bound to which interface in the command output.

Using hostname command

The last command you can use to find an IP address is by executing the hostname command as follows.

You will have the following result on your terminal.

Get IP address by using hostname command

These are all the methods you can use to find the network configuration of your machine. Finding your public IP address is not that easy, especially when your system is behind a NAT router. Have a look at this guide if you like to know the public IP and even geolocation of the IP. Enjoy!!

Search

About This Site

Vitux.com aims to become a Linux compendium with lots of unique and up to date tutorials.

Latest Tutorials

Источник

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