🔥 Holiday Sale! 25% Off Platinum Membership $399.99 $299.99 (ends December 31).

Commandline IP address lookup in Linux

Commandline IP address lookup is very simple in Linux.

I wrote a small script to do this for me. This is what I did:

nano ipaddr.sh

Enter the following lines into the script:

#!/bin/bash
eip=`wget http://automation.whatismyip.com/n09230945.asp -O - -q`
iip=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ pr
int $1}'`
echo "External IP: $eip"
echo "Internal IP: $iip"
exit 0

Made the script executable by the user:

chmod 700 ipaddr.sh

Commandline Ip Address Lookup

Commandline IP Address Lookup

Run the script:

./ipaddr.sh

And the output looks like this:

External IP: XX.XX.XXX.XX
Internal IP: 192.168.X.X

The external IP address is the IP address provided by my ISP and shown to the world. The internal IP address is the IP address assigned by my router's DHCP to the network device on my server.

Be the 1 in 200,000. Help us sustain what we do.
124 / 150 by Dec 31, 2024
You will gain benefits such as Deployarr access, discord roles, exclusive content, ad-free browsing, and more.
🔥 Holiday Sale! 25% Off Platinum Membership $399.99 $299.99 (ends December 31).
Join the Geek Army (starting from just $1.67/month)

Anand

Anand is a self-learned computer enthusiast, hopeless tinkerer (if it ain't broke, fix it), a part-time blogger, and a Scientist during the day. He has been blogging since 2010 on Linux, Ubuntu, Home/Media/File Servers, Smart Home Automation, and related HOW-TOs.

Holiday Sale