#!/usr/bin/perl # get_wan_ip # This script gets the "external IP address" by extracting it from the HTML # returned from a publicly available web site that provides this service. # # Cameron Hayne (macdev@hayne.net) June 2003 use strict; use warnings; my $url = "http://www.whatismyip.com/"; my $html = `/usr/bin/curl -s -f $url`; if ($html =~ /[^\d]*(\d+\.\d+\.\d+\.\d+)/i) { my $ipaddr = $1; print $ipaddr; print "\n"; # remove this line if newline at end not wanted exit; } print STDERR "Failed to get IP address from $url\n"; exit;