How to find and change the MAC address on Linux

Chưa phân loại
Our network card has at least two addresses or identificators, the IP address we all know which can be dynamic and the physical address, the mac address which is unique for each device, it is the hardware address. Changing our mac address may be useful to avoid leaving logs with our real address on another computer or router. Changing the mac address may be useful to clone other mac addresses forcing them to get disconnected from a network and connecting again, useful to sniff the password when reinserted.

In this brief tutorial you’ll learn how to check your mac address and how to edit it randomly or for a specific replacement mac address.

For this tutorial I will work on the network card enp2s0, replace this network card for yours (e.g eth0, wlan0, etc.)

To check your mac address just execute:


We can see on the enp2s0 network card the mac address is d0:17:c2:12:3c:cd while the wlp3s0 wifi card mac address is a2:58:a6:6a:29:04. Mac addresses 12 digits, 6 fields of 2 characters and letters separated by “:” like XX:XX:XX:XX:XX:XX.

The first 6 characters and numbers belong to the device manufacturer, in my case d0:17:c2 belongs to ASUS. The last 12 digits are the ID number for the hardware and it is unique.

First of all, to edit our network card mac address we need to disable our network card, the mac can not be changed while the card is being used. To disable our network card run:

Ifconfig enp2s0 down

Then, to edit our mac address type:

ifconfig enp2s0 hw ether 00:00:00:00:00:01

Then enable the network card back by typing:

ifconfig enp2s0 up

If you need to edit our mac frequently maybe is convenient to use a  program called macchanger, to install it on Debian or Ubuntu systems run:

apt install macchanger

During the installation you’ll be asked if macchanger should start when a networking device is enabled, here you can decide whatever you want, changing your mac address by default shouldn’t create problems unless you have your router configured to accept specific mac addresses.

Select any of the options and press enter to finish.

After macchanger is installed we can also check our mac address by typing

macchanger -s <DEVICENAME>

As you can see it matches with the mac address exposed using ifconfig.

Here Macchanger shows the current mac, the real hardware’s mac (Permanent MAC) and the new one if you assign it.To change your mac address fast for a random address simply run:

macchanger -r <DEVICENAME>

Make sure you run macchanger as root and that the network device is down. If you get an error when running this command then run:

ifconfig <DEVICENAME> down

To disable your network card, after it type “ifconfig” again and you’ll see your network card wont show up.

Then run macchanger -r again.

If we want to assign our card a specific address we can execute:

macchanger -m XX:XX:XX:XX:XX:XX

For example

macchanger -m 32:ce:cb:3c:63:cd enp2s0

If we set our card up and run an ifconfig we’ll see our new mac address.

After editing our mac address we need to enable the network card back, for this run::

ifconfig <DEVICENAME> up


Now we can see our system also displays the new mac address 32:ce:cb:3c:63:cd.

Firewalls and IDS can contain policies whitelisting and banning specific mac addresses. Manipulating our network cards’ physical address is a great step to avoid leaving traces in logs and increase your privacy by masking your device or to bypass security obstacles when pentesting a network, the most common use as said at the starting is when we want to crack a wifi access dissociating a connected device with the aircrack suite by cloning it’s mac address.

I hope you found this tutorial on macchanger useful, keep following LinuxHint for more tips and updates on Linux.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Những điều tâm đắc nhất khi sử dụng lệnh GREP

Grep (Global Regular Expression Print) là một công cụ dòng lệnh Linux/Unix được sử dụng để tìm kiếm...

How to join a Windows network with your Linux device

In this tutorial you’ll learn how join a wired Windows based network with your Linux device. The network used for this...

Recover Removed Files from Windows NTFS Drive using Live Ubuntu DVD

If you’ve mistakenly deleted some files from your Windows NTFS drive and would like to get them back, then this article...
Bài Viết

Bài Viết Mới Cập Nhật

mua Proxy riêng ở đâu, và nó đem lại lợi ích gì cho người sử dụng

Hướng dẫn sử dụng Proxy Helper Fakeip khi thuê proxy


Mua Proxy Nuôi Zalo Giá Rẻ Tại