What is the best way to extract the MAC address from ifconfig
's output?
Sample output:
bash-3.00# ifconfig eth0 eth0 Link encap:Ethernet HWaddr 1F:2E:19:10:3B:52 inet addr:127.0.0.66 Bcast:127.255.255.255 Mask:255.0.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 .... ....
Should I use cut, AWK or anything else, and what are the merits and demerits of one method over the other.
On a Linux machine Open a terminal window. Type ifconfig at the command prompt. Your MAC address will be displayed beside the label HWaddr.
Windows 10 (alternate method)Go to Start > Settings. Once the Settings page opens click on Network & Internet. Select Ethernet from the left hand side and select your Ethernet interface on the right hand side. The Mac address will be displayed next to Physical address and is a 12 character alpha numeric string.
UNIX or Linux devicesOpen a terminal. Type ifconfig -a and press Enter. -> HWaddr or ether or lladdr is the device's MAC address.
To see all the MAC addresses and their associated IP addresses, type “arp -a”. This command will list all the available MAC addresses in the system.
You can do a cat under /sys/class/
cat /sys/class/net/*/address
Specifically for eth0
cat /sys/class/net/eth0/address
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With