- How to view your computer’s MAC address using ‘ifconfig’?
- 6 Answers 6
- ip -a link
- Further reading
- You must log in to answer this question.
- Linked
- Related
- Hot Network Questions
- Subscribe to RSS
- How to Find Network MAC Address in Linux System
- Approaches to Finding MAC Address in Linux
- 1. Find Linux System Mac Address Using IP Command
- 2. Find Linux System Mac Address Using Ifconfig Command
- Как узнать MAC-адрес в Linux
- Как узнать MAC-адрес с помощью ifconfig
- Как посмотреть MAC-адрес с помощью ip
- Выводы
- How to Find Your MAC address in Ubuntu and Other Linux Distros
- Method 1: Find MAC address using command line
- Get the MAC address of Bluetooth
- Method 2: Get MAC address using GUI
- Final Words
How to view your computer’s MAC address using ‘ifconfig’?
After substantial research I still haven’t found an answer to this query, how can I modify the command ‘ifconfig’ to show my computer’s MAC address?
Show us the output of ifconfig for you machine. The ‘HWaddr’ field will be your MAC address. Dont forget to run as root.
as @jc__ mentioned — show us the output of ifconfig -a , (and ip addr if available) and we can help you better. MAYBE after looking at the output of this command (these commands) you will be able to answer your own question!
6 Answers 6
First, your computer doesn’t have a MAC address. Each network card has a MAC address. So if your machine has a wireless card and an Ethernet card, it’ll have two MAC addresses.
On Linux, either of these commands will show you the MACs of all network cards in your machine:
ifconfig | grep ether ip link
ifconfig is deprecated on Linux, so you should use ip .
Just as a nit, I recall at least some Sun machines that had a MAC address built into the machine, that was used on all interfaces
For many linux systems ipconfig doesn’t show the mac anymore. If that is the case for you, try:
ip -a link
Note that the user does not say what kind of Unix they are using, only that they use one that has ifconfig .
The command that you want on MacOS, FreeBSD, and TrueOS is:
OpenBSD’s ifconfig doesn’t have this.
Further reading
- ifconfig . Mac OS 10 Manual Pages. Apple corporation. 2008.
- ifconfig . FreeBSD Manual Pages. 2015.
- https://unix.stackexchange.com/a/319354/5132
Instead of using ifconfig , you can use ip command.
ip -brief link will show following output.
lo UNKNOWN 00:00:00:00:00:00 enp1s0 DOWN xx:6a:64:43:d5:xx wlp2s0 UP xx:d1:6b:f2:03:xx docker0 UP xx:42:33:81:52:xx vethf34394f@if13 UP xx:79:65:3e:e0:xx phy0.mon UNKNOWN xx:d1:6b:f2:03:xx
Note that the user does not say what kind of Unix they are using, only that they use one that has ifconfig .
To get direct MAC address from the interface name.
dmesg | grep -oE 'mac=.*\w+' | cut -b '5-'
Your answer is a bit terse and could be improved by explaining the code. Note too that the user in the question does not say they are on a specific type of Unix, only one that has ifconfig .
You must log in to answer this question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533
Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
How to Find Network MAC Address in Linux System
The term MAC Address is a derived abbreviation for Media Access Control Address. The network interface controller (NIC) uses the MAC address as its assigned unique identifier within an existing network segment.
To practically relate to or understand what a MAC address is, think of it as the postal or physical address to a house. The house in this case is the network interface controller (NIC).
There is a key difference between MAC address and IP address and therefore we should not confuse the two. MAC address identifies the device you are using since it is imprinted on the device hardware whereas IP address identifies the connection status among devices seeking to communicate on an existing/configured network.
The MAC address of any device is represented by a 12-digit hexadecimal number. Its display includes a colon or hyphen after every two MAC address digits for easy readability.
For instance, a MAC address can be represented in the following manner.
aa:bb:cc:dd:ee:ff or gg-hh-ii-jj-kk-ll
Approaches to Finding MAC Address in Linux
Depending on the number of network interfaces on your Linux machine like Wi-Fi built-in and Ethernet port, your computer can be associated with more than one MAC Address.
1. Find Linux System Mac Address Using IP Command
The ip command is part of the iproute2 package and can be used to display both the MAC address and IP address of your Linux-powered machine using either of the following commands.
$ ip addr or $ ip address or $ ip address show
Depending on the network adapter or interface present, we can see the availed MAC addresses. In the above screen capture, three distinct MAC addresses can be identified from the ip address command.
Another useful command is the ip link which only focuses on the MAC address and does not display the IP addresses.
2. Find Linux System Mac Address Using Ifconfig Command
The ifconfig command is another effective approach to identifying the MAC address of your Linux machine. We however need to install it first since it is a member of the net-tools package and not installed on Linux by default.
$ sudo apt install net-tools [On Debian, Ubuntu and Mint] $ sudo yum install net-tools [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] $ sudo emerge -a sys-apps/net-tools [On Gentoo Linux] $ sudo pacman -S net-tools [On Arch Linux] $ sudo zypper install net-tools [On OpenSUSE]
Once installed, run the ifconfig command to find the IP address and MAC address of your Linux system.
Different network interfaces or adapters showcase different MAC addresses as highlighted in the above screen capture.
We have successfully defined and understood how to get the MAC address(es) on our Linux machines.
Как узнать MAC-адрес в Linux
В те времена, когда только проектировался Ethernet, предусматривалось применение уникального номера каждой сетевой карте, подключённой к нему. Назначался он при изготовлении платы. MAC-адрес используется для определения получателя и отправителя информации в Сети. И в этой статье речь пойдёт о том, как узнать MAC адрес в Linux.
Практически во всех операционных системах на основе ядра Linux используется две консольные утилиты, с помощью которых можно узнать аппаратный адрес карты: ifconfig и ip. Различные графические приложения этого типа используют их данные.
Как узнать MAC-адрес с помощью ifconfig
Одной из первых сетевых программ в истории Linux является ifconfig. В некоторых дистрибутивах она запускается только от имени администратора, а где-то вообще не установлена. Рассмотрим её инсталляцию и использование в Manjaro Linux.
Пакет, содержащий в себе некоторые сетевые утилиты (в том числе и ifconfig), в Manjaro- и Arch-подобных системах называется net-tools. Установим его.
А в Ubuntu- и Debian-подобных системах:
sudo apt install net-tools
Чтобы узнать MAC-адрес Linux, сначала смотрим список интерфейсов:
Доступных интерфейсов два: enp0s7 (в вашем случае он может называться по другому) и lo (он же локальный хост, который одинаков практически для всех компьютеров). Нам нужен enp0s7.
MAC-адрес устройства виден уже сейчас в поле ether, но чтобы отобразить только его, воспользуемся такой командой:
ifconfig -a | grep ether | gawk »
Здесь grep принимает на вход то, что вывела команда ifconfig -a, находит строку, где есть ether, и передаёт на вход команде gawk, которая выбирает второе слово в принятой строке.
Как посмотреть MAC-адрес с помощью ip
Более новой в системах GNU/Linux (относительно ifconfig) является программа ip. Её принцип работы практически такой же. Отличается синтаксисом и выводимой информацией. И она установлена по умолчанию для всех систем. Для отображения сетевых интерфейсов нужно ввести команду:
Здесь lo и enp0s7 расположены в обратном порядке.
Чтобы узнать MAC адрес сетевой карты Linux, вводим ту же самую конструкцию, только для этой команды:
Выводы
За то, как узнать MAC адрес в Linux, отвечают две консольные утилиты — ifconfig и ip. Первая может запускаться от имени администратора в некоторых дистрибутивах (например в Debian), а где-то вообще не быть установленной (Manjaro). Это связано с её отходом на второй план, поскольку ip является более новой программой и устанавливается по умолчанию во всех системах.
Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.
How to Find Your MAC address in Ubuntu and Other Linux Distros
When you are learning networking or troubleshooting it, you would need to know the MAC address.
A computer can have more than one MAC address. It is because the MAC address is a core part of networking, and each networking peripheral device has its own MAC address.
So, your WiFi card has a MAC address, and so does the Ethernet (LAN) port. Even the Bluetooth has one.
The MAC address, also known as the physical address, is a 12-digit hexadecimal code (48-bits) and is represented as MM:MM:MM:SS:SS:SS
In this tutorial, I’ll share the steps for finding the MAC address of your desired networking interface in Linux. I’ll show both command line and GUI methods.
Method 1: Find MAC address using command line
There are serveral Linux networking commands that can be used to get the MAC address of the WiFi or LAN cards.
Open up your terminal and use the following command, and it will bring the address of the present network cards in your system:
And you’ll be met with the following output:
Generally, the wireless device names will be wlan0, wlan1, wlan2, wlo0, wlo1, and wlo2, whereas the Ethernet (wired device) will probably have eth0, eth1, eno0, eno1,enpls0, or enpls1.
You can find the MAC address of each device at the last line of the device description, followed by link/ether and it’s 52:54:00:5c:92:bf in my case.
Get the MAC address of Bluetooth
As I mentioned earlier, all networking devices have a physical address. If you want to see the MAC address of your Bluetooth adapter, you can use this command:
You can see it beside the BD Address field.
[email protected]:~$ hciconfig hci0: Type: Primary Bus: USB BD Address: DC:41:A9:FB:7A:C4 ACL MTU: 1021:4 SCO MTU: 96:6 UP RUNNING RX bytes:17895787 acl:275 sco:250783 events:298882 errors:0 TX bytes:303664302 acl:295384 sco:249895 commands:3380 errors:0
You can also use the bluetoothctl command here.
Method 2: Get MAC address using GUI
If you’re afraid of using the terminal you can use the network settings to get the MAC address details.
I am using Ubuntu with the GNOME desktop environment. If you use some other desktop environments, the screenshots may not look the same.
First, search for settings in the system menu and open the first result.
Now, for the left menu bar, select Network and click on the little gear icon located near to wired network toggle. Even if you’re not connected to a wired network, you can still follow the same approach.
If you’re on Wi-Fi, there will be an option for Wi-Fi in the left menu bar. From there, you have to follow the same approach (clicking on the gear icon) to get your MAC address.
Once you click on the gear icon, you’ll be met with details of the selected network interface. Here, the MAC address is given as the Hardware address.
Here you have it in the easiest way possible!
Final Words
Did you know that the first half of hexadecimal code (24 bits) is used to represent the manufacturer of your network adapter?
Finding a MAC address in Linux is quite easy as you have seen it here. On the same note, you may like to learn about changing the MAC address in Linux.
Let me know if you have any questions or suggestions.