Kali Linux | Check your Local and Public IP addresses in your terminal with single command


Check Local & Public IP in Linux Terminal

IP stands for Internet Protocol. It is the identity of all the devices connected to the Internet.
All networks follow some agreed upon set of rules for communication. For example. when you speak to one another, you follow one rule which is "when one person is speaking, the other would listen". Similarly, computers one network also follow some set of rules for communication with one another. These set of rules are called protocols. There are many networking protocols. One of the most common networking protocols  is TCP/IP protocol. Today's most commonly known network, the internet , also follows this protocol. A network that follows TCP/IP protocol, can also be termed as TCP/IP network.

Each network device (a computer or any other network device ) on a TCP/IP network needs to have a unique address on the network. This unique address on TCP/IP network is The IP Address.

IP addresses can be through of as a unique series of numbers, uniquely identifying a computer on a network. Thus, you can say that just like, telephones are uniquely identified through their telephone-numbers, computer on a TCP/IP network (such as Internet) are uniquely identified through their unique address-IP Addresses. Each IP address is actually a series containing four numbers separated by dots or period , example 192.168.1.1 is an IP address ,Similarly 21.201.4.1 is also  an IP address and so on.

IP addresses are normally written in dotted decimal form as listed above but computer internally convert them into binary form. for instance,

an IP address in dotted decimal form: 216.27.61.137
same IP address in binary form: 11011000.00011011.00111101.10001001

Older version of IP address is 32-bit long (IPv4 address) and newer version of IP address is 128-bit long (IPv6 address).
examples:-

IPv4: 47.30.198.111 
IPv6: 2405:204:1303:643c:cdd0:5c:973:20ae

Local IP Address:
It assigned when you connected to a local network through Ethernet or wireless network, you will get a IP address like, 192.168.43.101 All machine have its own IP address 127.0.0.1 for communicate locally or within a network (short range like hotpots).

Public IP Address:
It assigned when you connected to the internet through a network, It needed for communicate with different network in world. When you are surfing the web , your identity will be your Public IP Address, like 47.30.198.111

Follow these steps to find public and local IP addresses in your Linux machine terminal.

Step 1:





Copy the code given above, then you have to edit .bashrc file and paste this code, .bashrc file is a hidden file, it is available in the /root/ or /home/ folder, for this you have to open  terminal from the dock and run this command, your .bashrc your file will open in Nano Text Editor.




Now you have to go to the last line of this file (.bashrc) and paste the copied code in the last blank new line and press CTRL + O and press Enter, The .bashrc file has been updated, now you have to close the text editor by pressing CTRL + X .


Kali Linux | Check your Local and Public IP addresses in your terminal with single command


Step 2:

Now you have to run the whatismyip command in your terminal, your local and public IP addresses will be shown in your terminal.




Kali Linux | Check your Local and Public IP addresses in your terminal with single command


Thank You.