5 Commands to Find Your Public IP Address using Termux 🔥

Hey Guys, It's me SaadMaqsood 🙋🏻‍♂️, So I have written so many posts about IP addresses and how to grab Someone else IP Address but someone commented asking "How can I find my own public IP-Address" and I realized that I should write a post about it. So in this post, you will learn 5 different commands that you can use to find your own Public IP-Address in Termux. This is going to be a really simple post and you will learn some new commands today🔥.


What is Public IP Address?

An IP address is like a digital address uniquely identifying each device connected to the internet. It's a series of numbers separated by periods or colons, depending on the version (IPv4 or IPv6) used. Like how your home address helps mail reach you, an IP address allows data to be sent and received across the internet. IP addresses are crucial for devices to communicate with each other online. They're used to route data packets, ensuring that information reaches its intended destination, whether it's establishing internet connections, accessing websites, sending emails, or streaming media. 

Essentially, IP addresses play a vital role in how the internet works, allowing devices to identify and talk to each other in a vast global network of interconnected devices. Since we are ethical hackers, we need to know our own IP address before trying to perform any cyber security stuff. It's a really good practice to check IP leaks before starting anything any tool or visiting any site when you are using your Hacking machine. 



How to Find Your Public IP Address Using Termux?

Finding your own IP address is a really simple task that can be done just by typing a correct command. since this post is specifically about finding your own IP address, I am going to give you 5 alternate commands so you can use any one of them to find your public IP address using termux. 

Method 1: Using the "curl"  on ifconfig.me:

This is just a simple curl command, since curl comes preinstalled in termux, you don't have to do anything, just type the below command and it will give you your public IP.
curl ifconfig.me

The command will fetch the public IP address from the ifconfig.me service and display it in the Termux. 


Method 2: Using the "dig" command :

This command uses dnsutils package in termux to find out your public IP using DNS servers. To use this below command you need to install dnsutils package in termux by typing pkg install dnsutils and then after the one-time installation of dnsutils you can use this below command every time you wanna find out your public IP in termux.
dig +short myip.opendns.com @resolver1.opendns.com

The command will query the resolver1.opendns.com DNS server for your public IP address and display it in the Termux terminal.


Method 3: Using the "wget" command :

In this method, we will use the wget (which is a preinstalled package in termux) to fetch our IP address from the ifconfig.io website. 
wget -qO- ifconfig.io

The command will fetch the public IP address from the ifconfig.io service and display it in the terminal window.


Method 4: Using the "curl" command public IP address lookup :

I think this is one of the simplest commands out there to find your public IP address in termux. by just simply using the curl package in termux we can ping ident.me to find the public Ip of your phone.
curl ident.me

By just using this command we fetch our public IP address from the ident.me service and display it in our termux terminal.


Method 5:  Using the "wget" command with ipecho :

This one uses wget with ipecho.net.you can use it as an alternative in case the other commands are down for some reason. just copy paste this command and you will get your public ip.
wget -qO- https://ipecho.net/plain ; echo

The command will fetch your public IP address from the ipecho.net service and display it in the terminal window.



Find your local IP Address using Termux:

If you are looking for a way to only print your L ocal IP address in your termux then you can use the below command. this command will apply  grep on ifconfig command and grab your local IP only. 
2>/dev/null ifconfig | grep inet | tail -1 | awk '{print $2}'

if you want to know more about your network, you can type ifconfig and you will get your network information.


Pro-Tip: Set Shortcut key to Find your Public IP in Termux:

So since we can find ip with a single command like you have seen above, you can write it in a simple alias command so that you can just press a single key and termux will give you your public ip. below is a simple alias command example where if you will press "i" button on your keyboard and press enter, Termux will give you your public IP address. copy and paste the below commands in your termux and restart your termux, and the shortcuts will be added. 
echo "alias i='curl ifconfig.me'" >> /data/data/com.termux/files/usr/etc/bash.bashrc 
If you do it correctly, you will see your public IP as soon as you press i and press enter on your keyboard. to remove this shortcut, just go to /data/data/com.termux/files/usr/etc/ and delete the alias from bash.bashrc file.


Conclusion:

So these were a few trick commands that I use to find my own public IP Address using termux. all of these commands are one liner and can be memorized easily. If you want to find someone else IP Address then you can search this site because I have written a lot of posts on that topic. If you like these basic commands then you should read my [ Termux basic command Guide ]. If by any chance any command is not working in your temux, then make sure to comment down below so I can help you out. well, that's it for today. Thanks for reading, stay creative, and as always STAY THICAL👾.

Post a Comment

0 Comments

Popup Image