i have the following task to do:

i need to get the mac adress of my first upstream router (i.e my default
router). there are a number of constraints, however:

1) detection has to be as fast as possible, but 100% reliable
2) i can only use tools from /bin and /sbin, nothing from under /usr.
3) it has to be done from a shell script without any external c hacks.
4) all information i have at this point is the fixed IP adress of the

right know i am doing this:

i configure my interface with an arbitrary ip (any IP from within the
RFC 1918 adress space, notably NOT within the same subnet as the router).
i cannot just use an ip within the same subnet as the router is because i
do not want to disturb the network.
next i set my default route to my interface
then i ping the router
after that, i have an entry in my arp cache which i read with the route
command and parse with the sh builtin expr.

this looks at follows (my router is

ifconfig fxp0
ifconfig fxp0 up
route add default -interface fxp0
ping -c 5 -t 5 -m 1 -n -q
route=` route -n -v get `
macaddr=`expr "//${route}" : ".* \(.*\) fxp0.*$" `

my problem with the above sequence is: sometimes i get an arp cache entry,
sometimes i don't. i've tried varying the -c and -t flags of ping with
little success.

as there a better way of doing this, or are some other flags to ping more

thanks in advance, t.
[EMAIL PROTECTED] mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to