Changing the MAC

Hi,

Is there a comfortable way to change an eth MAC address?
I do not want to call my ISP to make another IP to MAC binding

Do you mean releasing/reassign the role? Changing the MAC address is usually not needed.

My ISP provider has bound the services including my public static IP to the MAC address of my gateway. I want to clone the gateway MAC to the netserver red eth card
If i change the MAC i will be assigned another IP. this is something that i want to prevent

db networks setprop ethX macaddr 12:34:56:78:90:ab
where ethX is the interface name.
Then
signal-event interface-update
to apply the config.

3 Likes

is it going to store it permanently or i need to change it at every system reset

It’s permanent, since it’s stored in the configuration db (see the beginning of the command).

i will test it
forgive any stupid questions from my side. a am not that familiar with cli
cheers

Thank you. Please, let us know the outcome.

Did not save it permanently. After a reboot the old MAC appears back

Could you please show the content of
/etc/sysconfig/network-scripts/ifcfg-eth0

Change eth0 with the right name and you could also obfuscate your ip and mac.

Permission denied

Strange i am the root

Type:
cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:01:6c:9b:7f:38
NM_CONTROLLED=no
ONBOOT=yes
PEERDNS=no
PERSISTENT_DHCLIENT=y
TYPE=Ethernet
USERCTL=no
[root@server ~]# DEVICE=eth0
[root@server ~]# BOOTPROTO=dhcp
[root@server ~]# HWADDR=00:01:6c:9b:7f:38
[root@server ~]# NM_CONTROLLED=no
[root@server ~]# ONBOOT=yes
[root@server ~]# PEERDNS=no
[root@server ~]# PERSISTENT_DHCLIENT=y
[root@server ~]# TYPE=Ethernet
[root@server ~]# USERCTL=no
[root@server ~]#

According to the RedHat Manual, the MACADDR directive should not be used in conjunction with the HWADDR (comment/delete the latter), and the /etc/udev/rules.d/70-persistent-net.rules file should be modified/deleted.

I had a similar problem (Win7 local network awareness…) and solved it that way:

added in rc.local at the end the lines

ifconfig ethX down
ip link set ethX address xx:xx:xx:xx:xx
ifconfig ethX up

After I validated that it works, I added a custom template in /etc/e-smith/templates-custom/etc/rc.d/rc.local to make it permanent.

Maybe rude and not the smartest way, but it works. :innocent:

No worries, here you will find people of different expertise levels, from users to sysadmins and developers.
.
Someone said that the only stupid question is the one that remains unasked. :ok_hand:

I found the following description

On the RHEL/CentOS/Fedora boxes, there is a line named HWADDR in the interface configuration file /etc/sysconfig/network-scripts/ifcfg-eth0, for example, storing the MAC address of the corresponding ethernet interface.

Nothing will happen if you change the MAC addresss in this line, and you will probably receive the following notice when restart the network service.

?
1
Shutting down interface eth0: Device eth0 has MAC address AA:BB:CC:DD:EE:FF, instead of configured address 00:11:22:33:44:55. Ignoring.

To change the MAC address, just keep the HWADDR as it is, and add the following line to the above file.

?
1
MACADDR=00:11:22:33:44:55

Restart the network service.

?
1
2

service network restart

ifconfig eth0

New MAC address! Congrats!!!

Could you confirm it

If this is right, how should i add the MACADDR line ?

Tried the commands provided by @filippo_carletti and worked well, as long as the MAC address has a valid OUI (Organizationally Unique Identifier). The MAC address change persisted after reboot.

Strange, this was the first thing i tested and did not seem to work on my machine
Will try again