OK, ich habe hier die ultimative Loesung zu dem Problem:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# getip.pl
# (c) 2005 Christoph Bussenius
# This Perl script is in the public domain
use strict;
use warnings;
my $route = `ping -nRc1 maila.microsoft.com` or die "hey, pinging problems";
$route =~ s/.*?RR://s;
while ($route =~ m{(\d+\.\d+\.\d+\.\d+)}g) {
my $ip=$1;
next if $ip =~ /^10\./;
next if $ip =~ /^192\.168\./;
next if $ip =~ /^172\.(\d+)\./ and $1 < 32 and $1 >= 16;
next if $ip =~ /^127\./;
print "My IP is $ip\n";
last;
}
edit: hmm. funktioniert nicht auf FreeBSD ohne Router... aber sonst immer, ich hab's getestet ;-)\n\n
<!--EDIT|betterworld|1126219691-->