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.