- ИТ База знаний
- Полезно
- Навигация
- Серверные решения
- Телефония
- Корпоративные сети
- Как сменить mac – адрес в Linux
- Находим текущий mac – адрес сетевого интерфейса
- Меняем MAC с помощью Macchanger. Установка
- Меняем MAC с помощью iproute
- Итоги
- Changing Your MAC Address/Linux
- Making Changes Permanent — Surviving a Reboot [ edit | edit source ]
- How to Change MAC Address in Linux
- Changing MAC address in Linux
- Step 1: Find your MAC address and network interface
- Method 1: Change MAC address using Macchanger
- How to Use Macchanger to change MAC address
- Method 2: Changing Mac address using iproute2 [intermediate knowledge]
- Dimitrios Savvopoulos
- How To Change MAC address In Linux
- Find MAC address in Linux
- Change MAC address in Linux
- Method 1: Using Macchanger
- Macchanger usage
- Method 2: Using iproute2
ИТ База знаний
Курс по Asterisk
Полезно
— Узнать IP — адрес компьютера в интернете
— Онлайн генератор устойчивых паролей
— Онлайн калькулятор подсетей
— Калькулятор инсталляции IP — АТС Asterisk
— Руководство администратора FreePBX на русском языке
— Руководство администратора Cisco UCM/CME на русском языке
— Руководство администратора по Linux/Unix
Навигация
Серверные решения
Телефония
FreePBX и Asterisk
Настройка программных телефонов
Корпоративные сети
Протоколы и стандарты
Как сменить mac – адрес в Linux
Меняем физический адрес
3 минуты чтения
Усаживайтесь на кушетку поудобнее. Зачем, в первую очередь, вы хотите сменить mac – адрес у вашего сервера на базе Linux? Может хотите блочить его на фаерволе, или попробовать совершить «магию» с лицензиями, которые привязаны к маку?
Мини — курс по виртуализации
Знакомство с VMware vSphere 7 и технологией виртуализации в авторском мини — курсе от Михаила Якобсена
В целом, дело ваше. Мы покажем способ, как это сделать. Давайте по шагам.
Находим текущий mac – адрес сетевого интерфейса
Сначала давайте посмотрим на текущий mac вашего сервера. Сделать это можно командой:
Вывод сервера будет примерно таким. Он будет содержать параметры (mac — адреса всех ваших интерфейсов):
Как мы видим, например, у интерфейса enp0s12e2 текущий mac – адрес это 33:23:f8:8b:d7:65 . Давайте поменяем его.
Меняем MAC с помощью Macchanger. Установка
Macchanger — это ну очень простая утилита, чтобы смотреть, менять и управлять MAC – адресами на ваших сетевых интерфейсах. Она доступна на почти всех Linux – подобных системах.
Например, чтобы установить Macchanger на Fedora, CentOS или RHEL используйте команду:/p>
А если у вас Debian, Ubuntu, Linux Mint или даже Kali Linux, то установить ее можно вот так:
Как использовать Macchanger
Помните имя интерфейса, которое мы обсудили чуть раньше? Ага, мы про enp0s12e2
Например, чтобы присвоить этому интерфейсу рандомный mac, используйте команду:
После смены, проверьте, что мак – адрес поменялся командой:
Он стал другим, не так ли? Теперь, чтобы присвоить конкретный (нужный вам) мак интерфейсу, примените команду:
Где, как не сложно догадаться, XX:XX:XX:XX:XX:XX — mac, который вам нужен. Кстати, если вы поняли, что сделали что-то не то, то вернуть mac – адрес устройства к его изначальному значению можно вот так:
Меняем MAC с помощью iproute
Делать это через macchanger, честно говоря, правильнее. Однако, если не получилось/не хотите, то можно поступить вот так. Первое, выключаем интерфейс:
Далее, присваиваем новый mac выключенному интерфейсу:
Не забываем включить интерфейс обратно:
Итоги
В статье мы обсудили два способа смены адреса: через утилиту macchanger и встроенную команду ip. Мы рекомендуем использовать macchanger, как более надежный способ. Однако, решать вам.
Мини — курс по виртуализации
Знакомство с VMware vSphere 7 и технологией виртуализации в авторском мини — курсе от Михаила Якобсена
Источник
Changing Your MAC Address/Linux
Under GNU/Linux, the MAC address of a network interface card (NIC) can be changed by following the procedures below.
NOTE: MAC addresses used within this article are provided for example only. Substitute according to your requirements.
NOTE: Commands below MUST be executed with root privileges (e.g. prepended with «sudo «), in order for things to work!
/etc/init.d/networking stop ifconfig eth0 hw ether 02:01:02:03:04:08 /etc/init.d/networking start
Execute » ifconfig eth0 » to confirm.
The above should work on Debian, Ubuntu, and similar distributions. Alternatively, under RHEL/Fedora and possibly other GNU/Linux distributions (incl. CentOS and Scientific Linux), to disable and restart networking, one must stop and start /etc/init.d/network , instead of /etc/init.d/networking .
If you have iproute2 utilities installed, you may prefer to use the » ip » command, as follows:
/etc/init.d/network stop ip link set eth0 address 02:01:02:03:04:08 /etc/init.d/network start
To confirm your setting, you may prefer to execute » ip link ls eth0 » or » ip addr ls eth0 » instead of » ifconfig eth0 «.
NOTE: You may not be able do this if using a DSL modem (depending on modem vendor or ISP).
Making Changes Permanent — Surviving a Reboot [ edit | edit source ]
In openSUSE and other SUSE-based systems (SUSE enterprise desktop\server, etc.) you can make changes «permanent» across reboots by adding an appropriate entry to the /etc/sysconfig/network/ifcfg-ethN file (ifcfg-eth0 for the first Ethernet interface config file, ifcfg-eth1 — for the second, etc.):
In Red Hat Enterprise Linux (RHEL) and other similar systems (Fedora, CentOS, etc.) an easy way to make changes «permanent» across reboots is to add an appropriate entry to the /etc/sysconfig/network-scripts/ifcfg-ethN file (ifcfg-eth0 for the first Ethernet interface config file, ifcfg-eth1 — for the second, etc.):
Note: in the file is a value HWADDR — This is not the same thing. Use MACADDR for permanent changes.
The HWADDR «directive is useful for machines with multiple NICs to ensure that the interfaces are assigned the correct device names regardless of the configured load order for each NIC’s module. This directive should not be used in conjunction with MACADDR.» . The MACADDR «directive is used to assign a MAC address to an interface, overriding the one assigned to the physical NIC. This directive should not be used in conjunction with HWADDR.»
Upper and lower case letters are accepted when specifying the MAC address, because the network function converts all letters to upper case.
You can test changes without restarting the system by executing:
service network restart
(WARNING: doing this will break all existing network connections!)
On Debian, Ubuntu, and similar systems, place the following in the appropriate section of /etc/network/interfaces (within an iface stanza, e.g., right after the gateway line) so that the MAC address is set when the network device is started:
hwaddress ether 02:01:02:03:04:08
On Gentoo you may achieve the same result by adding an entry to the global configuration file /etc/conf.d/net for each Ethernet card. Example for the eth0 device:
You can also use the tool «GNU MACChanger» to change the MAC address under GNU/Linux.
To change MAC address during boot time with MACChanger, add the following line to your /etc/network/interfaces (example for the eth0 interface):
pre-up macchanger -m 12:34:56:78:90:AB eth0
Источник
How to Change MAC Address in Linux
Last updated October 29, 2020 By Community 5 Comments
Before I show you how to change Mac address in Linux, let’s first discuss why would you change it in the first place.
You may have several reasons. Maybe you don’t want your actual MAC address (also called physical address) to be exposed on a public network? Other case can be that the network administrator might have blocked a particular MAC address in the router or firewall.
One practical ‘benefit’ is that some public network (like Airport WiFi) allows free internet for a limited time. If you want to use the internet beyond that, spoofing your Mac address may trick the network in believing that it’s a new device. It’s a famous meme as well.
I am going to show the steps for changing MAC address (also called spoofing/faking MAC address).
Changing MAC address in Linux
Let’s go through each step:
Step 1: Find your MAC address and network interface
Let’s find out some details about the network card in Linux. Use this command to get the network interface details:
In the output, you’ll see several details along with the MAC address:
As you can see, in this case, my network interface is called enp0s31f6 and its MAC address is 38:42:f8:8b:a7:68.
You may want to note it down on a secure place to revert to this original MAC address later on.
Now you may proceed to changing the MAC address.
If you do this on a network interface which is currently in use, probably your network connection will be terminated. So either try this method on an additional card or be prepared to restart your network.
Method 1: Change MAC address using Macchanger
Macchanger is simple utility to view, modify, and manipulate MAC addresses for your Network interface cards. It is available in almost all GNU/Linux operating systems and you can install is using the package installer of your distribution.
On Arch Linux or Manjaro:
On Fedora, CentOS, RHEL:
On Debian, Ubuntu, Linux Mint, Kali Linux:
Important! You’ll be asked to specify whether macchanger should be set up to run automatically every time a network device is brought up or down. This gives a new MAC address whenever you attach an Ethernet cable or re-enable WiFi.
I recommend not to run it automatically, unless you really need to change your MAC address every time. So, choose No (by pressing tab key) and hit Enter key to continue.
How to Use Macchanger to change MAC address
Do you remember your network interface name? You got it in the Step 1 earlier.
Now, to assign any random MAC address to this network card, use:
After changing the MAC id, verify it using command:
You will now see that MAC has been spoofed.
To change the MAC address to a specific value, specify any custom MAC address using command:
Where XX:XX:XX:XX:XX:XX is the new MAC id that you want to change.
Finally, to revert the MAC address to its original hardware value, run the following command:
However, you don’t have to do this. Once you reboot the system, the changes will be automatically lost, and the actual MAC address will be restored again.
You can always check the man page for more details.
Method 2: Changing Mac address using iproute2 [intermediate knowledge]
I would recommend using Macchanger but if you don’t want to use it, there is another way to change the MAC address in Linux.
First, turn off the network card using command:
Next, set the new MAC using command:
Finally, turn the network back on with this command:
Now, verify new MAC address:
That’s it. You have successfully changed the MAC address in true Linux style. Stay tuned with It’s FOSS for more Linux tutorial and tips.
Dimitrios Savvopoulos
Dimitrios is an MSc Mechanical Engineer but a Linux enthusiast in heart. He is well settled in Solus OS but curiosity drives him to constantly test other distros. Challenge is part of his personality and his hobby is to compete from 5k to the marathon distance.
Like what you read? Please share it with others.
Источник
How To Change MAC address In Linux
You may not want to expose the real MAC address when you are connected with a public WiFi hotspot. In such situations, you can simply change it or fake it with another MAC address. Some times, the network administrator might have blocked a particular MAC address in the router or firewall. In such cases, you can use this method to change the MAC id. Changing MAC address is also called spoofing MAC address or faking MAC address. In this brief tutorial, we will see how to change MAC address in Linux.
I tested this guide on CentOS 7 and Ubuntu 18.04 LTS server editions. It worked well as described below. Let us get started.
Find MAC address in Linux
First, let us find out the MAC address or Hardware address of a Network interface card in Linux.
Sample output:
Sample output:
You can use any one of the above commands to find out the MAC id of a network interface card. These commands should work on almost all Linux distributions.
Now let us see how to change the MAC address.
Change MAC address in Linux
We can do this in two methods. Please be mindful that you should not do this on a live network card which is currently in use. If you do it, probably, your network connection will be terminated. Try this method with an additional card.
Method 1: Using Macchanger
Macchanger is simple utility to view, modify, and manipulate MAC addresses for your Network interface cards. It is available in almost all GNU/Linux operating systems.
On Arch Linux:
To install Macchanger in Arch Linux and its derivatives, run:
On Fedora, CentOS, RHEL:
On Debian / Ubuntu:
To macchanger in Debian, Ubuntu and its derivatives, run:
Specify whether macchanger should be set up to run automatically every time a network device is brought up or down. This gives a new MAC address whenever you attach an ethernet cable or reenable wifi.
I recommend you not to run it automatically, unless you really need to change the MAC id every time. So, choose No and hit ENTER key to continue.
Macchanger has been installed.
Macchanger usage
To assign any random MAC address, run:
To find out the network interface name, run:
Sample output:
As you see in the above screenshot, enp0s3 is my network interface card’s name.
To change the MAC address of enp0s3 network card, run:
After changing the MAC id, verify it using command:
Sample output:
You will now see that MAC has been spoofed.
To change the MAC address to a specific value, specify any custom MAC address using command:
Where XX:XX:XX:XX:XX:XX is the new MAC id that you wish to change to.
Finally, to return the MAC address to its original, permanent hardware value, run the following command:
However, you don’t have to do this. Once you reboot the system, the changes will be automatically lost, and the actual MAC address will be restored again.
For more details, check the man pages:
Method 2: Using iproute2
First, turn off the Network card using command:
Next, set the new MAC is using command:
Finally, turn it on back with command:
Now, verify new MAC id using command:
Sample output:
Alternatively, you can do this using ‘ifconfig’ command as described below.
Suggested read:
As you can see, both methods are pretty easy. Choose any one that works for you. To revert back to the original MAC address, simply reboot your system.
Hope this helps. If you know any other method to change the MAC address, share them in the comment below.
Источник