-1

I'm connected to a private network where the IP addresses are like 192.168.xxx.xxx. I know the IP address of the default gateway but how do I get the gateway mac address? I'm working on iMac and Linux machines. Any Unix command for that?

Valerio Bozz
  • 1,176
  • 16
  • 32
saz
  • 955
  • 5
  • 15
  • 26

2 Answers2

1

This gives you list of everything:

netstat -rn 

or this one to get default gateway:

netstat -rn | grep 'default'

WHAT YOU REALLY WANT:

netstat -rn | grep 'default' | awk '{print $2}'
Bun S.
  • 111
  • 1
  • 10
1

Here the command line example for arping assuming your gateway's IP address is 192.168.1.1 and you have connected over eth0:

arping -f -I eth0  192.168.1.1
ARPING 192.168.1.1 from 192.168.1.24 eth0
Unicast reply from 192.168.1.1 [ab:cd:ef:01:02:03]  1.030ms
Sent 1 probes (1 broadcast(s))
Received 1 response(s)

So in this case gateway's MAC address is ab:cd:ef:01:02:03

Oleg Neumyvakin
  • 9,706
  • 3
  • 58
  • 62