How do I get the MAC address of my router?

Is there a Linux command that allows me to get the MAC address of my router?


Don't use the obsoleted commands ifconfig(8), arp(8) or route(8). Use the new command that replace them and can do more, ip(8).

Use ip route list to see which default router your machine have. That should be a line wich starts with default (or 0.0.0.0) and have the IP address to the router after. If you uses IPv6, just add the -6 switch, ip -6 route list.

default via 192.168.11.1 dev eth0  proto static 

To see the MAC address of the default routers IP address, use ip neigh and look up the line with the IP address and MAC address after lladdr.e

192.168.11.1 dev eth0 lladdr 1c:af:f7:XX:XX:XX REACHABLE

If you don't find a machine in the list, you need to connect to it, because it has been removed from the list because not used for a while. So just try:

ping -c 3 192.168.11.1

Then try the ip neigh command again. The option -c 3 will restrict ping to only send three ICMP ECHO messages and then end. If not set, it will run until you stop the program with C-c.


I like one-liners:

arping -f -I $(ip route show match 0/0 | awk '{print $5, $3}')

arping shows the MAC associated with the default gateway IP address from the output of ip route show match 0/0, parsed by awk.


If you don't know the IP of your router, it's most likely your gateway which you can get from the route command:

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

Note the line with the flags UG. The address in the Gateway column of that line is what you're looking for. Then follow 2707974's suggestion with arp -n (ping the IP if it doesn't show up at first), and find the matching line:

$ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.0.1              ether   00:11:22:33:44:55   C                     eth0
192.168.0.2              ether   66:77:88:99:aa:bb   C                     eth0

Here, your router's MAC would be 00:11:22:33:44:55.