LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Ethernet mac address changing randomly (https://www.linuxquestions.org/questions/linux-networking-3/ethernet-mac-address-changing-randomly-4175458933/)

matiasar 04-20-2013 05:32 PM

Ethernet mac address changing randomly
 
I'm using Debian wheezy with kernel 3.2.0-4-686-pae but sometimes my mac address is changing randomly. Really I didn't find anything that could be chinging mac addr within my /etc/init.d/ scripts.
Now I tried to settle mac address within /etc/network/interfaces, but I'm not sure if it will fix it.
I need mac addr to remain always the same as long as I use wake on lan feature.

Code:

auto eth0                                                                     
                                             
iface eth0 inet static                                                         
                                             
  address 192.168.1.2                                                   
  netmask 255.255.255.0
  gateway 192.168.1.1
  # BOF: Habilitar Wake-On-Lan
  pre-up ifconfig $IFACE hw ether ba:87:7e:e6:02:05
  post-up /sbin/ethtool -s $IFACE wol g
  post-down /sbin/ethtool -s $IFACE wol g || ifconfig $IFACE hw
ether ba:87:7e:e6:02:05
  # EOF: Fin habilitar Wake-On-Lan

Any ideas on why mac address could be changed randomly?

Thanks!

lleb 04-20-2013 08:55 PM

the MAC address on a NIC can not change. do you have more then one NIC in your system? it could be that eth0 is swapping between the different NICs.

bcwagne 04-20-2013 10:44 PM

Yes, this is what is happening. Debian, by default, uses dynamic assignments for network interfaces.

lleb 04-21-2013 12:20 AM

Quote:

Originally Posted by bcwagne (Post 4935597)
Yes, this is what is happening. Debian, by default, uses dynamic assignments for network interfaces.

are you talking about my response with multiple NICs in his system?

matiasar 04-21-2013 08:09 PM

Yes, I found this behaviour weird, as long ethernet mac address should not change, but it's changing. I only have one NIC in this box.
Is there any way to disable this "dynamic" assignment of mac address? I couldn't find anything within /etc/init.d/ sysv scripts.

Thanks for your answers, regards-

KinnowGrower 04-21-2013 08:59 PM

Quote:

Yes, I found this behaviour weird, as long ethernet mac address should not change, but it's changing.
How do you know it is changing?. Can you show/explain really how you confirmed MAC address is changing?.

gdizzle 04-21-2013 11:51 PM

Are you using a Virtual machine?? KVM, vmware, virtual box?

Yes how do we know the MAC ADDRESS is actually changing?

Do an ifconfig and get your MAC ADDRESS, reboot the system and get the MAC ADDRESS again. Did it change on reboot?

Or have you got something strange going on with UDEV? Look in here for any extra rules especially under network.

You can set your MAC ADDRESS statically with ifconfig:

Code:

ifconfig <interface> hw ether 00:11:22:33:44:55
Get someone here using Debian to confirm your /etc/network/interfaces file it looks a bit whack.

273 04-22-2013 03:15 AM

I think you are getting confused here, why are you doing the folowing?
Code:

pre-up ifconfig $IFACE hw ether ba:87:7e:e6:02:05
The MAC address is a hardware address built into every network card which ordinarily will never change. It does not need to be changed by you unless you have a specific reason to do this. If you want to use Wake on LAN you do not need to give your card a MAC address you need to make note of hthe MAC address given in ifconfig without trying to set the MAC address as you do above and use that MAC address to wake the machine.

matiasar 04-22-2013 07:33 AM

Thanks for your feedback folks.
I noticed my mac addr was changing cos' I'm using wakeonlan feature, using wakeonlan program that pacakage the "magic packet" (ethernet frames for wol) within an udp datagram. Everything works fine for a while, but then I found a change with mac address and it stops working.

As long as hardware mac address could not change (it can only be "faked" by software). For the udp to reach my machine I had to do a "mac-binding" in my router (tp-link). This is adding a fixed entry within router's ARP table as far as I'm concerned. That way udp datagram can reach the final destination.

I added those entries within my /etc/network/interfaces just to try if that way mac addr remains settled.

gdizzle 04-22-2013 05:19 PM

do an :

Code:

ifconfig -a
make sure you have no more interfaces then you think.

cat
Code:

/etc/udev/rules.d/70-persistent-net.rules
Or the Debian equivalent and check for inconsistencies.

Is the MAC address usually one of 2 addresses or is it RANDOM everytime? Do some restarts collect some stats.

matiasar 04-23-2013 09:27 AM

Hi gdizzle,

There's only one nic in this box. And nothing appears strange with udev rules.
I'll do some tests and try to check if there's something tricky with the router and the WOL stuff.

Thanks!


All times are GMT -5. The time now is 08:20 PM.