Change MAC address


#1

Hi everyone.

I’m trying to change the MAC address of one ethernet interface, but without success.
I’m typing this command on CLI:

vyos@vyos# set interfaces ethernet eth0 mac 00:01:02:03:04:05
vyos@vyos# commit&&save

When I reboot the router, the MAC of the NIC come back to default.

I already tried to change the config.boot file, and the “interface” file inside /etc/network but both method without success.

The way I got was:
edit
/config/scripts/vyatta-postconfig-bootup.script

and add this line inside it
ifconfig eth0 hw ether 00:01:02:03:04:05

But I didn’t want to use this method.
Does anyone know how to change the mac address in the right way?


#2

Hi,
Not sure if it is the correct way but when you use virtualization, MAC address is set up by your virtualization manager.
Hence, maybe try to first change it using your virtualization manager (manually using "virsh edit " For KVM). Make sure to shutdown and then start your VM so that changes are made.
Then on VyOS, change the hw-id on your corresponding interface if it is not automatically updated.
Hope this help!


#3

Hi Spark,

Thanks for your reply, but it is not the case, I’m not using virtualization, the VyOS is running in a real server.
Unfortunatelly there is a situation that I really need to change the MAC address!

I’ve already tried to remove the original MAC from the config file and putting the MAC I want, but it is not working yet.

If you have another suggestion would be great.

Thanks in advance.