#! /usr/bin/perl -w
use strict;
use warnings;
my $route = `ip route`;
$route =~ /^default via ((\d+\.?){4})/;
my $router_ip = $1 if $1;
die "unknown\n" unless $router_ip;
my $arp = `cat /proc/net/arp | grep $router_ip`;
my ($ip, $type, $flags, $mac, $mask, $device) = split /\s+/, $arp;
print $mac."\n";
No comments:
Post a Comment