Skip to content

Instantly share code, notes, and snippets.

@Xliff
Last active January 30, 2021 22:43
Embed
What would you like to do?
Get your External IP

To my fello Rakuoons, here is a quick script that will return your external IP. Works great with home systems or EC2 instances!

use Inline::Perl5; 
use Cro::HTTP::Client; 
use Mojo::DOM:from<Perl5>; 

my $r = await Cro::HTTP::Client.get("https://whatsmyip.com/", :http<1.1>); 
my $d = Mojo::DOM.new(await $r.body); 
$d.at("#shownIpv4").text.say

Feel free to comment, below!

@tbrowder
Copy link

thanks!

@Xliff
Copy link
Author

Xliff commented Jan 30, 2021

For Perl5 users -- Note the different URL:

my $ua = LWP::UserAgent->new(verify_hostname => 0);
my $re  = $ua->get("http://whatsmyip.co/");
print $re->decoded_content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment