# Can't change mac adress on realtek NIC

## Cocobo-1

I have a bunch of Realtek RTL-8100B/8139D cards and need to change the mac adress. I just want to know if it's possible with that chip. I have never been able to do it in linux or windows.

----------

## Frodg

Not possible AFAIK

Any reason for changing them???

----------

## Jake

You probably can't change them permanently, but I don't see any reason why you can't change them temporarily with "ifconfig ethx hw ether xx:xx..."

----------

## bone

 *Frodg wrote:*   

> Not possible AFAIK
> 
> 

 

Macchanger wil change their mac addresses temp. You will have to remember what your changing it to and change it back to the same address after a reboot/reset though. Here is a code snipplet I have in my /etc/conf.d/net.

```

preup() {

        # Test for link on the interface prior to bringing it up.  This

        # only works on some network adapters and requires the mii-diag

        # package to be installed.

        if mii-tool ${IFACE} 2> /dev/null | grep -q 'no link'; then

                ewarn "No link on ${IFACE}, aborting configuration"

                return 1

        fi

        # Old Mac Address 00:10:5a:19:76:21

        #if [ ${IFACE} == eth0 ]; then

        #       /sbin/macchanger --mac=00:10:5A:55:46:6C eth0

        #fi

        # Remember to return 0 on success

        return 0

}

```

I have it commented out right now, but the macchanger line looks for the IFACE set to eth0 and makes sure the mac is changed before it runs preup (brings the interface up). This used to insure than my mac was cloned, and stays the same as it was before.  The reason you have to if condition on IFACE is /etc/conf.d/net is called multiple times, once for each /etc/init.d/net.$(IFACE) you have.

jt

----------

## bone

A side note. For some reason I couldnt just set the mac address in /etc/conf.d/net the normal way and have it cloned. I had to use this method. Never figured out why, but this worked like a charm either way.

jt

----------

## pilla

Could you please change your topic less harsh and clearer so people can be more effective at searching for something like this? Thanks.

----------

## Cocobo-1

This is the full story. My student LAN only allow certain mac adresses. The diodes on the back of the NIC don't turn on if it's incorrect. The lockout have been there for years and I want to retire my old NIC. I have helped friends change mac address and it works for them. I use the standard commands

```
ifconfig eth0 down

ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX

ifconfig eth0 up
```

and ifconfig shows that the new mac address have been set but I still can't get any data.

Is it possible my NIC doesn't support change of mac address? As far as I know, the mac address is stored  in an eeprom and transferred to an io register by software when the device is inited (quick look at the source code). It should be possible to change the data in this register later on or is the driver buggy.

----------

## barlad

Well I am not an expert in electronics or anything like that but since the network stack of the OS  is the one taking care of filling up the Layer 2 header (it is... right? Since I can use raw sockets and define those headers myself, see libnet for example) I don't see why you could not - temporary - change the MAC address of your card, whatever it is and whatever the driver is.

As to the way of changing it... ifconfig will do the work I guess. I am not sure what ifconfig really does though, change a register in the network card using primitives in the drivers or make sure that the address reported to the OS when it fills up the L2 header is the one we want?

----------

