Checking linux ip address

How to Check IP Address on Linux using Command Line

How to check IP address on Linux machine using the command line interface? Mostly all of the Linux and Unix operating systems provides ifconfig and ip binary files. You can simply use these commands to find the local system IP address.

What is an IP Address?

A Internet Protocol address (IP address) is the numerical label assigned to each hardware devices connected to a computer network that uses the Internet Protocol to identify the devices. In general terms, it is an identity of any device. An IP address allows a device to communicate with other devices over an IP-based network like the LAN or Internet.

Method 1 – Using ifconfig Command

ifconfig command is generally available under /sbin directory. So you will need root or sudo access to run this on many of operating systems.

Sample output: [Some output hidden]

As per above output, this system has IP address 192.168.10.199 on Ethernet interface eth0.

You can also view the specific interface details by specifying the interface name on the command line as below.

Method 2 – Using ip Command

ip command generally available under /bin directory but some Linux os keep is under /sbin directory. Use the following command to get ip address using ip command.

Sample output: [Some output hidden]

As per the above output, this system has IP address 192.168.10.199 on Ethernet interface eth0. The interface eth1 doesn’t configure with an IP address.

You can also view the specific itnerface details using below command

Find more commands to check local ip address of any Linux system.

Источник

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

Рассмотрим, как узнать текущий IP-адрес системы Linux, используя командную строку.

ifconfig уже устарел

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

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

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

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

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

Читайте также:  Mpeg2 encoder windows 10

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 Check Your IP Address in Ubuntu [Beginner’s Tip]

Last updated October 29, 2020 By Sergiu 19 Comments

Wonder what’s your IP address? Here are several ways to check IP address in Ubuntu and other Linux distributions.

What is an IP Address?

An Internet Protocol address (commonly referred to as IP address) is a numerical label assigned to each device connected to a computer network (using the Internet Protocol). An IP address serves both the purpose of identification and localisation of a machine.

The IP address is unique within the network, allowing the communication between all connected devices.

You should also know that there are two types of IP addresses: public and private. The public IP address is the address used to communicate over the Internet, the same way your physical address is used for postal mail. However, in the context of a local network (such as a home where are router is used), each device is assigned a private IP address unique within this sub-network. This is used inside this local network, without directly exposing the public IP (which is used by the router to communicate with the Internet).

Another distinction can be made between IPv4 and IPv6 protocol. IPv4 is the classic IP format,consisting of a basic 4 part structure, with four bytes separated by dots (e.g. 127.0.0.1). However, with the growing number of devices, IPv4 will soon be unable to offer enough addresses. This is why IPv6 was invented, a format using 128-bit addresses (compared to the 32-bit addresses used by IPv4).

Checking your IP Address in Ubuntu [Terminal Method]

The fastest and the simplest way to check your IP address is by using the ip command. You can use this command in the following fashion:

It will show you both IPv4 and IPv6 addresses:

Actually, you can further shorten this command to just ip a . It will give you the exact same result.

If you prefer to get minimal details, you can also use hostname:

There are some other ways to check IP address in Linux but these two commands are more than enough to serve the purpose.

What about ifconfig?

Long-time users might be tempted to use ifconfig (part of net-tools), but that program is deprecated. Some newer Linux distributions don’t include this package anymore and if you try running it, you’ll see ifconfig command not found error.

Checking IP address in Ubuntu [GUI Method]

If you are not comfortable with the command line, you can also check IP address graphically.

Читайте также:  Alt linux история создания

Open up the Ubuntu Applications Menu (Show Applications in the bottom-left corner of the screen) and search for Settings and click on the icon:

This should open up the Settings Menu. Go to Network:

Pressing on the gear icon next to your connection should open up a window with more settings and information about your link to the network, including your IP address:

Bonus Tip: Checking your Public IP Address (for desktop computers)

First of all, to check your public IP address (used for communicating with servers etc.) you can use curl command. Open up a terminal and enter the following command:

This should simply return your IP address with no additional bulk information. I would recommend being careful when sharing this address, since it is the equivalent to giving out your personal address.

Note: If curl isn’t installed on your system, simply use sudo apt install curl -y to install curl on Ubuntu based Linux distributions.

Another simple way you can see your public IP address is by searching for ip address on Google.

Summary

In this article I went through the different ways you can find your IP address in Uuntu Linux, as well as giving you a basic overview of what IP addresses are used for and why they are so important for us.

I hope you enjoyed this quick guide. Let us know if you found this explanation helpful in the comments section!

Like what you read? Please share it with others.

Источник

How to Find or Check Your IP Address in Linux

Home » Networking » 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.

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

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:

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:

Читайте также:  Linux mint увеличение шрифта

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:

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

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.

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:

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.

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.

Источник

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