Questo script permette di visualizzare l'indirizzo ip pubblico (interrogando checkip.dyndns.org, evitare di aggiornare lo script troppo frequentemente per evitare di essere bannati), l'ip privato della scheda ethernete e quello della Airport oltre al nome della rete wireless. Riporta inoltre gli indirizzi locali e del server di eventuali connessioni VPN attiva (PPTP e OpenVPn)
#!/usr/bin/perl
# a little script to get your network status
$en0_info = `ifconfig en0 | grep "inet" | grep -v 127.0.0.1`;
$en1_info = `ifconfig en1 | grep "inet" | grep -v 127.0.0.1`;
$ppp0_info = `ifconfig ppp0 | grep "inet" | grep -v 127.0.0.1`;
$tun0_info = `ifconfig tun0 | grep "inet" | grep -v 127.0.0.1`;
$ext_info = `curl --silent http://checkip.dyndns.org | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'`;
$airport_network = `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | awk -F: '/ SSID: / {print $2}' | sed -e 's/.*SSID: //'`;
if($ext_info) {
$output .= "External: $ext_info";
} else {
$output .= "External: OFFLINE \n";
}
if($en0_info) {
$en0_info =~ /inet (.*) netmask/s;
$output .= "Ethernet: $1 \n";
} else {
$output .= "Ethernet: INACTIVE \n";
}
if($en1_info) {
$en1_info =~ /inet (.*) netmask/s;
$en1_info = $1;
$output .= "Airport: $en1_info \n";
$output .= "SSID: $airport_network";
} else {
$output .= "Airport: INACTIVE \n";
}
if($ppp0_info)
{
$ppp0_info =~ /inet (.*) netmask/s;
$ppp0_info = $1;
$output .= " PPP: $1 \n";
}
else
{ $output .= "";}
if($tun0_info)
{
$tun0_info =~ /inet (.*) netmask/s;
$tun0_info = $1;
$output .= " VPN: $1 \n";
}
else
{ $output .= "";}
print "$output";