Determine your external IP address on the command line

If you want to determine your External IP address you can use this Perl One-Liner I smelted below:

Perl One-Liner with HTML Parse

The example below is complicated but it actually parses the html!

perl -M'HTML::FormatText::WithLinks' -M'LWP::Simple qw($ua get)' -se 'BEGIN {print qq~[J\033[H\033[J~}; $ua->agent("${a}"); $f = HTML::FormatText::WithLinks->new(); print ($f->parse(get $url))' -- -a='Mozilla/3.0 (Win95; I)' -url=''


I am using the following modules:

Perl One-Liner (Easier)

In this example we are masquerading as cURL to get the info printed to us in a plain text kinda way.

perl -M'LWP::Simple qw($ua getprint)' -se 'BEGIN {print qq~[J\033[H\033[J~}; $ua->agent("${a}"); getprint $url' -- -a='curl/7.68.0' -url=''

Alternative Solution

The easiest method (however not as fun) is just to use cURL.

curl -sSL

Latest Blogs

Leave a Reply