Skip to content

Instantly share code, notes, and snippets.

@Xliff
Last active January 30, 2021 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xliff/40dad9ad552217fb5fc9a54a78e1fd7a to your computer and use it in GitHub Desktop.
Save Xliff/40dad9ad552217fb5fc9a54a78e1fd7a to your computer and use it in GitHub Desktop.
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