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.

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.

ABOUT THE AUTHOR

Kevin Arrows


Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.