0

I'm trying to change the MAC address of my network card (a generic card using an Intel chipset) on my. system that is running FreeBSD (FREEBSD 11.1-RELEASE-p7).

I get the following output when I issue ifconfig:

egbo: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether NN:NN:NN:NN:NN:NN
hwaddr NN:NN:NN:NN:NN:NN
inet6 aann::aann:aann....
nd6 ...
media: Ethernet autoselect
status: no carrier

I have tried:

ifconfig egb0 down
ifconfig egb0 ether XX:XX:XX:XX:XX:XX
ifconfig egb0 up

This changes only the 'ether' MAC address listed and not the HWADDR MAC address.

I have also tried:

ifconfig egb0 down
ifconfig egb0 lladdrr XX:XX:XX:XX:XX:XX
ifconfig egb0 up

This (also) changes only the ETHER address and not the HWADDR address.

I need to clone because I have changed my router and my ISP is refusing to register it as it is not 'one of theirs'!

3 Answers 3

3

The way I do it under 11.2-STABLE is to create a file /etc/start_if.iface_name which in my case is /etc/start_if.bge0 that contains:

ifconfig $1 link de:ad:be:ef:ca:fe

or whatever MAC address you need.

/etc/start_if.bge0 is called from /etc/network.subr's function ifscript_up. The specific name of the interface being brought up is passed to ifscript_up as $1 which is why the $1 in /etc/start_if.bge0 works to pass the interface name to ifconfig.

Once the system comes up, bge0 looks like:

$ ifconfig bge0
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=c019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO,LINKSTATE>
        ether de:ad:be:ef:ca:fe
        hwaddr f0:1f:af:e3:59:fa
        inet 10.16.231.24 netmask 0xffffffc0 broadcast 10.16.231.63
        inet 10.16.231.25 netmask 0xffffffff broadcast 10.16.231.25
        inet 10.16.231.50 netmask 0xffffffff broadcast 10.16.231.50
        inet 10.16.231.49 netmask 0xffffffff broadcast 10.16.231.49
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active

and my ARP table looks like:

? (10.16.231.1) at 00:00:0c:9f:f0:e7 on bge0 expires in 1033 seconds [ethernet]
? (10.16.231.25) at de:ad:be:ef:ca:fe on bge0 permanent [ethernet]
? (10.16.231.24) at de:ad:be:ef:ca:fe on bge0 permanent [ethernet]
? (10.16.231.50) at de:ad:be:ef:ca:fe on bge0 permanent [ethernet]
? (10.16.231.49) at de:ad:be:ef:ca:fe on bge0 permanent [ethernet]

If you encounter difficulties, verify the basics. The commands below are from a system which has an igb network interface, as yours does.

What interfaces are present?

# ifconfig -l
igb0 igb1 lo0

What is the status quo of the desired interface?

# ifconfig igb0
igb0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=6403bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,VLAN_HWTSO,RXCSUM_IPV6,TXCSUM_IPV6>
    ether ac:1f:6b:45:b0:ac
    hwaddr ac:1f:6b:45:b0:ac
    inet 10.10.176.76 netmask 0xffffff00 broadcast 10.10.176.255 
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active

What is the exact content of your start_if script?

# ls -l /etc/start_if.igb0 
-rw-r--r--  1 root  wheel  228 Feb 14 12:43 /etc/start_if.igb0
# cat /etc/start_if.igb0
(
date
echo "Attempting 'ifconfig $1 link de:ad:be:ef:ca:fe'"
if ifconfig $1 link de:ad:be:ef:ca:fe; then
        echo "ifconfig succeeded"
else
        echo "ifconfig failed with exit code $?"
fi
) >> /tmp/start_if.$1.log 2>&1

If your start_if script includes verbose debugging, what does it show?

# cat /tmp/start_if.igb0.log
Thu Feb 14 12:46:16 PST 2019
Attempting 'ifconfig igb0 link de:ad:be:ef:ca:fe'
ifconfig succeeded

What happens if you run the command manually?

BEWARE that doing this over a remote network connection (such as via ssh) may cause loss of connectivity when the MAC address changes.

# ifconfig ibg0 link de:ad:be:ef:ca:fe
ifconfig: interface ibg0 does not exist

Aha! You typo'ed the interface name. :) Try again. The correct response should be silent success from ifconfig:

# ifconfig igb0 link de:ad:be:ef:ca:fe
#

Once you're able to run 'ifconfig' without error, what does ifconfig and the arp table look like afterward?

# ifconfig igb0
igb0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=6403bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,VLAN_HWTSO,RXCSUM_IPV6,TXCSUM_IPV6>
        ether de:ad:be:ef:ca:fe
        hwaddr ac:1f:6b:45:b0:ac
        inet 10.10.176.76 netmask 0xffffff00 broadcast 10.10.176.255 
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
# arp -an
? (10.10.176.76) at de:ad:be:ef:ca:fe on igb0 permanent [ethernet]
? (10.10.176.137) at 18:03:73:34:39:66 on igb0 expires in 1170 seconds [ethernet]
? (10.10.176.1) at 00:00:0c:07:ac:03 on igb0 expires in 1050 seconds [ethernet]

If all that still fails, please edit your question to include the additional, specific steps listed above which you have taken and the output you get. PLEASE copy and paste your results so that we don't spend time trying to troubleshoot typographical errors made while transcribing your input and output.

2
  • Sorry for such a delayed response. I did try your suggestion, but it does not seem to be doing anything. After creating the file (start_if.igb0) and rebooting, the MAC address remains unchanged. I have to do it manually and when i reboot the MAC address is reset to its original value.
    – noowie
    Feb 14, 2019 at 8:41
  • Use some echo commands to print debug messages from your start_if script as shown in my revised answer. Then reboot again and please share the debug output.
    – Jim L.
    Feb 14, 2019 at 21:12
1

You can't change the HWADDR. It's encoded in the firmware. Set the required MAC before you bring the interface up. The interface shall report the changed MAC to other routers. Test it.

2
  • 3
    While this answer is well intentioned, this is really just a comment. Dec 27, 2018 at 22:47
  • 1
    @JakeGould I believe this is, indeed, an answer because it is the answer. The question describes how changing an interface's MAC address only changes the ether address and not the hwaddr address. The reason, as this answer notes, is because you can't change the hwaddr because it is the hardware address. @JimL.'s answer even demonstrates (twice) that when setting a MAC address the hwaddr is unaffected. That the question has misplaced expectations does not make "You can't do that" an invalid answer. Aug 4, 2019 at 17:07
0

For the latest FreeBSD you can use ether random for example via rc.conf:

cloned_interfaces="vlan0"
create_args_vlan0="vlan 4000 vlandev em0 mtu 1400 fib 1"
ifconfig_vlan0="ether random"

or

# ifconfig vlan0 ether random

Use the ("random") keyword to set a randomly generated MAC address. A randomly-generated MAC address might be the same as one already in use in the net- work. https://www.freebsd.org/cgi/man.cgi?ifconfig

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.