Trying To Override MAC Addr

Home » CentOS » Trying To Override MAC Addr
CentOS 20 Comments

I am trying to override the mac addr. Now this is on an armv7 actually running the F19 kernel and Redsleeve 6, but it SHOULD be standard CentOS6 ifcfg-eth0 content. Of course RSEL does not start with a ifcfg-eth0 file, letting network services do all the work, so I am starting from scratch, using the file from one of my C6 boxes with static addressing. My file has in it:

DEVICE=”eth0″
BOOTPROTO=none NM_CONTROLLED=”no”
ONBOOT=”yes”
TYPE=”Ethernet”
NAME=”System eth0″
DNS1 8.83.67.188
GATEWAY=”208.83.67.177″
IPADDR=”208.83.67.179″
HOSTNAME=”rigel2.htt-consult.com”
IPV6INIT=”yes”
MACADDR:67:15:00:01:79
MTU00

And when I restart network, it can’t find eth0:

# service network restart Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Device eth0 does not seem to be present, delaying initialization.
[FAILED]

but:

# ifconfig eth1 Link encap:Ethernet HWaddr 02:67:15:00:01:79
inet addr:208.83.67.179 Bcast:208.83.67.255 Mask:255.255.255.0
inet6 addr: 2607:f4b8:3:3:67:15ff:fe00:179/64 Scope:Global
inet6 addr: fe80::67:15ff:fe00:179/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:254 errors:0 dropped:17 overruns:0 frame:0
TX packets:70 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:26575 (25.9 KiB) TX bytes:6104 (5.9 KiB)
Interrupt:87 Base address:0x6000

The assigned MAC addr for eth0 is: 02:c3:04:01:77:c3

The tutorials that I have found on ifcfg-ethN say not to use both hwaddr and macaddr in the same cfg file, but it almost seems that is what is needed?

thanks

20 thoughts on - Trying To Override MAC Addr

  • pretty sure you need to use NIC model specific utilities to do this, ifcfg-ethN won’t do it. the hwaddr= in there is for finding the nic, not for reprogramming it.

  • ifconfig claims to support it:

    hw class address
    Set the hardware address of this interface, if the device driver
    supports this operation. The keyword must be followed by the
    name of the hardware class and the printable ASCII equivalent of
    the hardware address. Hardware classes currently supported
    include ether (Ethernet), ax25 (AMPR AX.25), ARCnet and netrom
    (AMPR NET/ROM).

    The important item is of course “if the device driver supports this operation”. If not then a tool downloaded from the NIC manufacturer might be the only way.

    Unfortunately I do not know whether ifcfg-eth* supports this ifconfig syntax.

    –keith

  • Did not work…

    # cat > /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=”eth0″
    BOOTPROTO=none NM_CONTROLLED=”no”
    ONBOOT=”yes”
    TYPE=”Ethernet”
    NAME=”System eth0″
    HWADDR:c3:04:01:77:c3
    MACADDR:67:15:00:01:79
    MTU00
    DNS1 8.83.67.188
    GATEWAY=”208.83.67.177″
    IPADDR=”208.83.67.179″
    HOSTNAME=”rigel2.htt-consult.com”
    IPV6INIT=”yes”
    [root@redsleeve ~]# service network restart Shutting down loopback interface: [ OK ]
    Bringing up loopback interface: [ OK ]
    Bringing up interface eth0: Device eth0 has different MAC address than expected, ignoring.
    [FAILED]

    And now not even an eth1 interface.

  • I just did it like this:

    ifconfig enp3s0

    enp3s0: flagsA63 mtu 1500
    inet 10.241.27.154 netmask 255.255.255.0 broadcast 10.241.27.255
    inet6 fe80::210:18ff:fe04:4d0 prefixlen 64 scopeid 0x20 ether 00:10:18:04:04:d0 txqueuelen 1000 (Ethernet)
    RX packets 429591 bytes 41991957 (40.0 MiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 249536 bytes 19108398 (18.2 MiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
    device interrupt 18

    ifconfig enp3s0 hw ether 00:10:18:04:04:d7

    ifconfig enp3s0
    enp3s0: flagsA63 mtu 1500
    inet 10.241.27.154 netmask 255.255.255.0 broadcast 10.241.27.255
    inet6 fe80::210:18ff:fe04:4d0 prefixlen 64 scopeid 0x20 ether 00:10:18:04:04:d7 txqueuelen 1000 (Ethernet)
    RX packets 429615 bytes 41994383 (40.0 MiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 249549 bytes 19109350 (18.2 MiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
    device interrupt 18
    Done!

    -GKH

  • Robert Moskowitz wrote:

    Trying again, after those idiots at Ix who run manitu blocked me….

    /etc/udev/rules.d are configuration files for udev, to create at boot.
    70-persistent-net.rules contains MAC addresses….

    mark

  • Ah. A bit:

    # cat /etc/udev/rules.d/70-persistent-net.rules
    # This file was automatically generated by the /lib/udev/write_net_rules
    # program, run by the persistent-net-generator.rules rules file.
    #
    # You can modify it, as long as you keep each rule on a single
    # line, and change only the value of the NAME= key.

    # net device ()
    SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”02:c4:03:82:c1:5
    3″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth0″

    # net device ()
    SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”02:c3:04:01:77:c
    3″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth1″

    ==========================================
    So I can pull that eth1 line that got generated error and change the eth0 line?

    Well I did that, took the macaddr and hwaddr lines. restarted network and it was not finding eth0. And it added eth1 back into
    /etc/udev/rules.d/70-persistent-net.rules.

    I cleaned that up, and rebooted. During the boot, I see the message:

    Bringing up interface eth0: Device eth0 does not seem to be present, delaying initialization.
    [FAILED]

    and once I get started, ifconfig reports eth1 again, and the eth1 line got added to rules. But the network IS working with addresses I want.
    But on eth1 with the errors about eth0.

    So there seems to be something before rules that is needed to be edited, or there is some limitation on my driver(s).

  • I worked a bit on this. I no longer have the MAC or HW addrs in ifcfg-eth0. Only in /etc/udev/rules.d/70-persistent-net.rules, and only for name=eth0:

    # net device ()
    SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”02:67:15:00:01:79″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth0″

    but on reboot, I get the error:

    Bringing up interface eth0: Device eth0 does not seem to be present, delaying initialization.
    [FAILED]

    and the ethernet comes up as eth1 and the eth1 line is added to
    /etc/udev/rules.d/70-persistent-net.rules

    Almost as if there is something else that needs changing.

  • I need the changes to be permanent to apply across boots. Thus using ifcfg-eth0 rather than ifconfig.

  • While they were blocking you, my search foo finally started getting results and others posted more help. I have learned more, but not working as I think it should. Working strangely; why the eth1 stuff.

  • Note that you generally need to stop the network, edit the udev file and then restart the network. It will confuse the kernel otherwise.

    Please also note that I’ve always moved names associated to devices, I’ve not tried changing the address, so there might be something missing there.

  • Note that you still have to tell the OS “See this real MAC address?
    Change it to this new MAC address”. Shy of reprogramming the NIC
    directly, you will almost certainly need to continue to reference the real MAC address.

  • So that means I need to find the full syntax of this rule.

    Oh, and there is no real MAC address and that MIGHT be part of the problem. Many armv7 cards do not have eeprom so no MAC address. In this case the kernel is creating the MAC address as local scope based on the SID. So somewhere this is happening, and Hans (who maintains the uboot Allwinner code) has not told me the magic goo; I have not seen any posts from him so he may still be on Holidays.

    But I will delve into udev syntax to see what I need to change the mac addr.

  • Robert, Sorry Dude. I did not mean to make things worse. All I wanted to say is this: It can be done via the ifconfig command.

    Now,

    # systemctl status network.service

    Tells me that network services still depend on:

    “ExecStart=/etc/rc.d/init.d/network start”

    Good! File: “/etc/sysconfig/network-scripts/ifup-eth”

    Says: “39 # bail out, if the MAC does not fit”

    Ok, perfect. As you already guessed we need to make this change early on. However, if all else fails, you can always source a custom script here and problem solved.

    I know, this is not elegant. But as an SA who sometimes needs to do dirty deeds…

    Again, apologies if I am being too simplistic/stupid here.

    GKH

  • I know with Arduinos (at least earlier network shields), there was no MAC address assigned, either. So there, I had to assign it in the compiled sketch.

    I would expect there to be some program somewhere for the NIC to allow you to program the static MAC.

    I suppose ‘ifconfig -a’ doesn’t show anything?

  • This tells me you are not using CentOS6 which does not have systemd. Or at least not my systems.

    I hope to get a conf file setup to do the work.