How to change the MAC Address of Ethernet device in Linux?

In case you have added a new ethernet device to your machine or server, How would you determine the new MAC Address and update the same to its relative configuration file?

You can check for the MAC address of an ethernet card using below command

# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:A3:F5:E6
          inet addr:192.168.1.6  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fea3:f5e6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:356 errors:0 dropped:0 overruns:0 frame:0
          TX packets:322 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:38162 (37.2 KiB)  TX bytes:59986 (58.5 KiB)
          Interrupt:19 Base address:0x2024

But this command will show the MAC details of configured ethernet device. In case you have added a new ethernet card, ifconfig won’t show the output of that new device

To get the same for new ethernet card use the below command

# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:0c:29:a3:f5:e6 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:0c:29:a3:f5:f0 brd ff:ff:ff:ff:ff:ff
4: pan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN
    link/ether 3e:ef:ea:16:07:bc brd ff:ff:ff:ff:ff:ff

As you see it is showing the MAC details of all the connected ethernet cards

You can also verify the same from the below file

# grep eth1 /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:f5:f0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

In case you don’t know the device name lookout for the newly added device by viewing the file

# less /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x1022:0x2000 (vmxnet) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:f5:e6", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:f5:f0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

Next once you know the Hardware Address of your ethernet device update the same in the configuration file

You can learn how to create or configure network in Red Hat Linux using the below link
How to configure network in Red Hat Linux

Leave a Comment