use ifconfig to show MAC address

Asked by arnupharb on 2012-07-10

I use ifconfig command it already show mac address but i'm not sure that is my device number or wireless rounter mac address
thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu net-tools Edit question
Assignee:
No assignee Edit question
Solved by:
Zach Softich
Solved:
2012-07-11
Last query:
2012-07-11
Last reply:
2012-07-11
Best Zach Softich (zsoftich) said : #1

ifconfig will show you your interfaces MAC. To find the MAC of a device on your Ethernet segment first try and ping the IP address. and then use arp to see what the resolved MAC is. For example if your IP address is 192.168.1.101 and your gateway router is at 192.168.1.1. Do the following commands.

ping 192.168.1.1 -c 1
arp -n | grep 192.168.1.1

The output of the second command will be similar to the following.

192.168.1.1 ether 00:aa:bb:cc:dd:ee C eth0

Where the first column is the IP address on your Ethernet segment. The second column is the link layer type, Ethernet in this case. Third is the MAC. And the Fifth column is the interface the MAC was resolved on.

If you are unsure of your gateway's IP address you can always run either of the following commands.

ip route | grep default

or

route -n | grep "^0.0.0.0"

The output of the first command will be similar to

default via 192.168.42.1 dev eth0 metric 100

The via statement shows you the IP of your gateway router and the dev statement shows the interface the gateway is found on. If multiple lines are returned, look at the metric, lowest value is the one used.

The second commands output will be similar to

0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 eth0

The important column is the second one, which is your gateways IP and the last one, which is the interface the default gateway is found on. If multiple lines are returned look at the fifth column which is the route metric, use the one with the lowest value.

Thanks,
Zach

arnupharb (arnupharb-master) said : #2

Thanks Zach Softich, that solved my question.