What is my external ip linux

Check External IP using the Linux Command Line

Knowing the IP address of our computer is a basic task to establish network connections. But remember that there is also a public one with which we access the Internet, and doing it from the terminal can be an interesting task. Today, you will learn how to know the external IP address using the terminal.

In a typical network, the router uses a public IP address to identify it to the rest of the Internet. However, this same home router allows many devices to connect to this same router by assigning it another range of IP addresses that are known as private.

So, the device has a private IP address to communicate with the internal network, but the router uses a different one to access the Internet. Here is the difference between the private IP and the public IP.

To know the private IP from the terminal, it would be enough to use the ipconfig command. But in the case of the external or public IP, the process is a little different.

I will show you several ways to do it.

Check External IP using the Linux Command Line

The reality is that there are many commands and ways to do this process. The first way to do this is by using the dig command.

In this case, the dig command will make a request to a website that will provide us with the external or public IP address.

dig +short myip.opendns.com @resolver1.opendns.com 

The output on the screen will simply be, the IP address you are looking for. For example:

Источник

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.

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:

Читайте также:  Kali linux burp suite pro

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:

inet6 fe80::a00:27ff:fe76:1e71/64

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:

wget -O - -q https://checkip.amazonaws.com

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.

Читайте также:  Failed to load module gail astra linux

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.

Источник

How to Find My External IP Address in Linux

While there are a number of command line solutions for finding your IP address in Linux, most of these are geared toward finding the unique address numbers assigned to your device. If you want to find out the IP address that HTTP sites identify you as externally, then you’ll more than likely need to use a command that references an outside server. The good news is that this is extremely easy on most modern Linux distributions. This trick is especially useful if you’re using any kind of proxy or configuring any advanced Web browser settings.

You’ll need to start by opening up a command prompt. Hold down Ctrl, Alt and T or search for Terminal from the Unity dash. KDE and LXDE users can click on the Applications menu, point to System Tools and then click on the Terminal item. Regardless of how you start your terminal, you won’t need to have root access for this and it probably won’t matter what kind of shell you’re using. Most of the packages that you’ll be working with are installed by default on the average GNU/Linux box in use today.

Method 1: Find Your External IPv6 Address

The vast majority of modern networking systems use the IPv6 standard, which is a much longer but more secure and flexible version than the older form of IP address. If you want to find this modern address number for your system, then type nc 6.ifcfg.me 23 | grep –colour=never IP and push enter. Since this is a bit of a longer command, you may wish to highlight and copy it. To paste it into your terminal you’ll need to either click on the Edit menu and select paste or hold Shift, Ctrl and V at the same time. Depending on your distribution and which terminal emulator you’re using, you might also be able to click the middle mouse button and then push enter to run it if you copied it to the clipboard.

Читайте также:  Перезагрузить wifi адаптер linux

Once you’ve run the command, you should see a long string of eight groups of hexadecimal digits. This is your external modern IPv6 address. You can run this command whenever you’d like to see if your external address ever changes. It will change if you connect a Linux tablet to public Wifi at a restaurant or library. You might also wish to add it to a shell script if you plan on running it fairly often. If your ISP provides you with a dynamic IP address, then this might eventually change anyway. It should stay relatively static, but this is an excellent way to keep an eye on it just in case.

Method 2: Finding Your IPv4 External Address

While IPv4 is an older standard, it’s still widely used in the networking world. If you want to find this address, then you can use a command line Web browser to look for it. Depending on which configuration your Linux installation uses, you might have to try this twice, but in either case it’s just a single command with no other playing around in order to find the answer. First trying typing w3m -dump whatismyip.akamai.com and push enter. You should just see you external IP address without any other information. This program terminates automatically and returns you to the prompt.

You might receive an error claiming that the program w3m isn’t installed. While you could install the package if you wanted to, you can also try curl -s http://whatismyip.akamai.com/ and see if this works. You might have curl installed already. If you do, then you’ll receive the same kind of simple output. You don’t have to play around anymore. While you could add whichever command works to a bash shell script, you can also just run it whenever you’d like just like the command in the first method. Of course, you could always install curl or w3m if you don’t have either package. Networking Linux users usually have at least one of these though.

Depending on a few factors, your IP addresses might look somewhat different from the example addresses configured here. Different networks in different geographical regions will sometimes put their own spin or even their own abbreviations on top of the usual mask used to calculate addresses. The ones we used were dummy addresses from a virtual machine run through a proxy server. You shouldn’t ever give away your actual external IP address online, which is precisely why we went to these lengths to do this when taking example screenshots.

Источник

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