代码如下:#!/bin/bashdeclare gw=`route -n | grep -e ‘^0.0.0.0’`declare gwname=`echo $gw | grep -oe ‘\w*$’`declare gwip=`echo $gw | grep -oe ‘[0-9]\{2,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}’`declare gwmac=`arp -n | grep -e $gwip | grep -oe ‘[0-9A-F]