LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices

Reply
 
Search this Thread
Old 04-12-2006, 04:19 AM   #1
Voltar
Member
 
Registered: Jan 2006
Location: Bakersfield, California
Distribution: CentOS 5.3, FreeBSD 7.2, Fedora 11
Posts: 83

Rep: Reputation: 15
Question OpenBSD: Adding a "lladdr" command to netstart to change MAC address at boot


Hello all,

I need to have the MAC address of one of my ethernet cards changed before the network is brought up and dhcp requests are sent out. I'm guessing this needs to be done in /etc/netstart but I'm unsure of what exactly I should put in there, or if it should even go in there.

I know how to change the MAC after boot with lladdr, but that doesn't exactly work for my needs. I'm using OpenBSD 3.8 if that helps.

Thanks in advance.
 
Old 04-12-2006, 07:14 PM   #2
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 41
I've never played with adjusting MAC addresses, but I think I know where you can put such a command. This is in /etc/netstart:
Code:
"dhcp")
    [ "$name" = "NONE" ] && name=
    [ "$mask" = "NONE" ] && mask=
    [ "$bcaddr" = "NONE" ] && bcaddr=
    ifconfig $if $name $mask $bcaddr $ext1 $ext2 down
    cmd="dhclient $if"
    setgateway=N
    ;;
The code you'd want to change is the line with "ifconfig $if ..." which you can wrap inside an if-clause to get the MAC address changed the way you want it, on the interface you want it. In other words, this should work:
Code:
"dhcp")
    [ "$name" = "NONE" ] && name=
    [ "$mask" = "NONE" ] && mask=
    [ "$bcaddr" = "NONE" ] && bcaddr=
    if [ "$if" = "INTERFACE" ]; then
        ifconfig $if $name $mask $bcaddr lladdr MAC_ADDR $ext1 $ext2 down
    else
        ifconfig $if $name $mask $bcaddr $ext1 $ext2 down
    fi
    cmd="dhclient $if"
    setgateway=N
    ;;
You may have to change the call to ifconfig, I'm not sure exactly what the syntax is when you're specifying an lladdr, but this should work. Of course, set INTERFACE and MAC_ADDR appropriately.
 
Old 04-14-2006, 12:41 AM   #3
Voltar
Member
 
Registered: Jan 2006
Location: Bakersfield, California
Distribution: CentOS 5.3, FreeBSD 7.2, Fedora 11
Posts: 83

Original Poster
Rep: Reputation: 15
Hey thanks a million. That didn't exactly work but it, shot out a bunch of errors at boot, but it gave me the basis for getting it to work. I'm not good with shell script or anything yet, but after a little tinkering I came up with this, which works perfect for me.

Here it is incase someone else has this question (/etc/netstart)..

Code:
....
if [ "$if" = "INTERFACE" ]; then
     ifconfig INTERFACE lladdr MAC_ADDY
fi

# Now parse the hostname.* file
....
INTERFACE = the interface (rl0, eth0, etc)
MAC_ADDY = MAC address (format: 00:00:00:00:00:00)

It goes right after the creation of the interface and right before the parsing of the hostname.* files.

Thanks again!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
grub list "MZ" for my windows boot "Help on Change" davimint Linux - Newbie 2 01-26-2006 06:22 AM
Boot now Hangs @ "GRUB" How do I find Stage 2's Address??? Supafast Linux - Hardware 1 07-06-2005 09:55 PM
How can you change the default setting for the "Run Command" program? whited Linux - General 6 02-28-2005 11:34 PM
difference between "Web server local URL" and "IPv4 address"? kpachopoulos Linux - General 2 09-17-2004 01:30 PM
MAC address shows up as " " , can Vmware cause this? gluelogic Linux - Networking 0 03-15-2002 05:10 PM


All times are GMT -5. The time now is 10:11 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration