set MAC address at boot

I cannot figure out how to set MAC at boot.

Any help please.

I've all sorts in rc.conf:

Code:
#ifconfig_em0="link be:ef:be:ef:be:ef"
#ifconfig_em0="inet 193.35.157.168  netmask 255.255.255.0"
#ifconfig_em0="inet 193.35.157.168 netmask 255.255.255.0 link 2b:3b:4b:5b:6b:7b"
Can't set link and inet at the same time it seems.
 
generic said:
What about:

Code:
ifconfig_em0="inet 10.0.0.2 netmask 255.255.255.0 ether aa:bb:cc:dd:ee:ff"

No, I tried that, it says:

Code:
sudo ifconfig em0 inet 193.35.157.168 netmask 255.255.255.0 link 2b:3b:4b:5b:6b:7bifconfig: link: bad value

I tried doing over two lines in rc.conf but that didn't work.

We have a customer blowing up the phone! I'm not a real sysadmin you see, I am supposed to be a programmer!

I will try the next suggestion.
 
bigearsbilly said:
Code:
#ifconfig_em0="inet 193.35.157.168 netmask 255.255.255.0 link 2b:3b:4b:5b:6b:7b"

Try setting the link in an alias, not in the same ifconfig line:

Code:
ifconfig_em0="inet 193.35.157.168 netmask 255.255.255.0"
ifconfig_em0_alias0="link 2b:3b:4b:5b:6b:7b"
 
acheron said:
You can create a file named /etc/start_if.em0 with the following content :
Code:
lladdr be:ef:be:ef:be:ef

nope, that didn't work either I'm afraid.

I did this which worked:


Code:
[billy@penguin:0]$ cat /etc/start_if.em0 
ifconfig em0 ether be:ef:be:ef:be:ef

Though it's moot now as I've abandoned this line of action.
Still it was interesting.
 
DutchDaemon said:
Try setting the link in an alias, not in the same ifconfig line:

Code:
ifconfig_em0="inet 193.35.157.168 netmask 255.255.255.0"
ifconfig_em0_alias0="link 2b:3b:4b:5b:6b:7b"

This appeared to work OK but the machine was a bit odd. The ifconfig showed it worked ok, it looked fine sitting on the console but strangely on the same network segment I could not ssh on to it. I could ssh from it but not to it. I think I'll go home and have a beer.

edit: I tried reversing them, doing the link first and the address as the alias. Same result.
 
You need to clear the ARP table of whatever machine you are trying to SSH from, so that it picks up the new MAC address.
 
bigearsbilly said:
I did this which worked:


Code:
[billy@penguin:0]$ cat /etc/start_if.em0 
ifconfig em0 ether be:ef:be:ef:be:ef

This is the proper way. /etc/start_if.name should contain full commands.
It should work this way too:
Code:
/etc/rc.conf
# up is placed after ether/lladdr/link
ifconfig_em0="ether 00:11:22:33:44:55 up"
# assign IP addresses with ipv4_addrs_ifname
ipv4_addrs_em0="192.0.2.1/24 192.0.2.2/32 ..."
link, lladdr and ether have the same meaning for /sbin/ifconfig.
Older FreeBSD versions did run /etc/rc.d/rc.early if it existed, at an early boot stage. Current versions should use /etc/start_if.name or a custom script placed in /etc/rc.d, aware of the ordering mechanism of rc(8).
 
Thank you I will try this on Monday.

I looked in the handbook and the Absolute FreeBSD book but couldn't find a reference for this.
Thanks for the help though everybody.
 
ecazamir said:
This is the proper way. /etc/start_if.name should contain full commands.
It should work this way too:
Code:
/etc/rc.conf
# up is placed after ether/lladdr/link
ifconfig_em0="ether 00:11:22:33:44:55 up"
# assign IP addresses with ipv4_addrs_ifname
ipv4_addrs_em0="192.0.2.1/24 192.0.2.2/32 ..."
link, lladdr and ether have the same meaning for /sbin/ifconfig.
Older FreeBSD versions did run /etc/rc.d/rc.early if it existed, at an early boot stage. Current versions should use /etc/start_if.name or a custom script placed in /etc/rc.d, aware of the ordering mechanism of rc(8).

startif files can contain $1 which triggers the device name after the dot.

example:
Code:
/sbin/ifconfig $1 alias ...

This makes the files portable to being used on other machines with different NICs (the device name after the dot will need to be changed though).

I like this way as well vs using rc.conf as it's not only portable but also easy scripted.

One example is: I have a partially automated script that creates a jail, creates and adds an alias to startif for persistence as well as setting up the jail in a pf NAT all in one step.
 
Can you reveal why you were asked to change the MAC address? I can't think of that many real world uses for changing it.
 
Well, we swapped a lower spec machine out and swapped IP address to avoid reconfiguration.

After which port 80 stopped working. It was fine on the old box. (Both FreeBSD 8.2 set up by me this year).

We don't own the router so someone suggested it would possibly be the MAC address IP combination, so I thought what the heck try it.

I never expected it to work but I was interested in trying it as an exercise.
I'm not really an admin, I'm a hacker really but we are a small company and I have to do it all.
 
Well yes, that's the usual ARP cache problem when you replace a network card and use the same IP address as before. The upstream router refuses to deal with the (new MAC, IP address) -pair until the old entry has expired.
 
Hmm something like that maybe. It was up and running quite a while though, more than a week before it came to light.
The router's connected to some sort of leased line we have no control over it.
So I'm told anyway.
 
kpa said:
Well yes, that's the usual ARP cache problem when you replace a network card and use the same IP address as before. The upstream router refuses to deal with the (new MAC, IP address) -pair until the old entry has expired.

And that is one of the reasons why a node should perform a gratuitous ARP for its own address when it starts: the router should learn the new address from that event (detecting multiple uses of an IP address is not usually as important).
 
Valid usecase:
Long ago Nokia made firewalls, their CheckPoint IP-220 was a nice short 1U box, before the existence of Mini-ITX.
Their own OS "IPSO SB" was originally derived by Ipsilon Networks from FreeBSD 2.1-STABLE and cross-compiled on FreeBSD 2.2.6-RELEASE and 3.5-RELEASE platforms. I think with additional Java (Solaris alike) console-interface modules, just like on JunOS of Jupiter.
Anyway, I installed FreeBSD on it, an early version 5 or late version 4.
As it didn't have VGA, I would do a generic install in one server, and swop the disk to the Nokia.
However, it's BIOS strictly demanded a specific MAC, otherwise the triple ethernet interface wouldn't communicate at all.
So, when set to the original MAC's, it then would came up fine
(and no: 100% certain that was not DHCP lease related).

Today I revisited this old tread. Busy on a project with a lot of tiny devices. Identical hardware, different tasks. Controllers with each it's own software.
To keep network administration tight and addressing fixed and to spare me a lot of mutations during development I give each device a cloned MAC.
Reading above problem with receiving a lease and then modify, I was about to try above suggested twoliner, but in the opposite order:
ifconfig_re0="ether 00:C0:4C:00:37:FB up" ipv4_addrs_re0="DHCP"

But even before I was able to try the above truly connected in the network, simply a
ifconfig_re0="DHCP ether 00:C0:4C:00:37:FB"
did already the job, without problem.

link, lladdr and ether have the same meaning for /sbin/ifconfig.
While being aware you wrote this 10+ year ago...
When using 'link cu:st:eek:m' (in ifconfig lines in rc.conf) then I do see 'ether cu:st:eek:m' AND 'hwaddr or:ig:in:al'
When using ether then I don't spot this 'hwaddr' being mentioned anymore.
 
Back
Top