Skip to content

Instantly share code, notes, and snippets.

@Xliff

Xliff/ExternallIpScript.md

Last active Jan 30, 2021
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

This comment has been minimized.

Copy link

@tbrowder tbrowder commented Jan 21, 2021

thanks!

@Xliff

This comment has been minimized.

Copy link
Owner Author

@Xliff 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