Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to change the MAC physical address of the network card under Linux

Shulou Source: shulou.com Published: 2022-06-01 14:55:49 10月21日 Update

This article mainly explains "how to change the MAC physical address of the network card under Linux". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it together to study and learn "how to change the MAC physical address of the network card under Linux"!

In some places, the network address and the physical address of the network card are bound. When changing the network card or other computers, the network may not be available. Here is how to change the physical address (MAC Address). Divided into temporary changes and long-term changes in two cases, two methods do not actually change the real properties of the network card.

temporarily change

The so-called temporary change refers to a short-term change method that fails after restarting the system. It is simpler.

The physical address of a Linux NIC is set during network setup.

First, make sure you are using root. Suppose eth0 is set.

Network card first "close"

# ifconfig eth0 down

Change the physical address and replace the bold part with the MAC address you want to change:

# ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF

Enable eth0.

# ifconfig eth0 up

If necessary, add your own commands to join the route.

Note:

If you want to set other information such as IP, be sure to put the hw ether physical address immediately after the device name (such as eth0).

Long-term changes

This refers to the ability to retain changes after a restart. A text editor profile is required.

Debian (Ubuntu is probably in this column too)

Edit/etc/network/interfaces, find the place related to eth0, and modify it to something like:

allow-hotplug eth0

iface eth0 inet dhcp

#iface eth0 inet static

# address 1.1.1.6

# netmask 255.255.255.0

# gateway 1.1.1.1

hwaddress ether 00:AA:BB:CC:DD:EE

The annotated part is the static IP, and the current unannotated part is the dynamic IP. See Debian Network Settings for details

Archlinux or Gentoo

Edit/etc/rc.conf (Archlinux) or/etc/conf.d/net (Gentoo) to add hw ether 00:AA:BB:CC:DD:EE to the eth0 configuration string. For Gentoo and Archlinux network settings, see the documentation for your distribution.

Fedora or Redhat

Edit/etc/sysconfig/network-scripts/ifcfg-eth0 (modify eth0 to your NIC number if necessary), add or modify

HWADDR=AA:BB:CC:DD:EE:FF

That's it.

Thank you for reading, the above is "how to change the MAC physical address of the network card under Linux" content, after the study of this article, I believe we have a deeper understanding of how to change the MAC physical address of the network card under Linux, the specific use of the situation also needs to be verified. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Tags: Address network card physics network method learning information content writing place situation comment part configuration dynamic command character string actually Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Linux vpn Huawei Apple