Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting mac-address of networkcard

Status
Not open for further replies.

Themuppeteer

Programmer
Apr 4, 2001
449
0
0
BE
Hello,

I have to know how I can get the mac-address of a network card in my program (c++ linux 7.2).
And I would also like to know how to make a connection to that mac address from another application.
(it is that other application that will provide the ip adres,something like dhcp but I need to do it myself so that I will know what pc has what ipadres,because after it has an ipadres,I have to be able to surf to it in internet explorer...)
thnx!
Greetz,

The Muppeteer.

themuppeteer@hotmail.com

Don't eat yellow snow...
 
I wrote a little program, now I have the mac address (I filtered it out if ifconfig)

Does anyone now how I should work from another program to send something to this macaddress ? Frankly I dont have a clue... Greetz,

The Muppeteer.

themuppeteer@hotmail.com

Don't eat yellow snow...
 
"And I would also like to know how to make a connection to that mac address from another application. "

And the answer is...
You can't!
this is how I should work,and how the dhcp server works:
pc without ip broadcasts his mac address and the message "gimme an ip!"
other application listens,and gets his message,then it broadcasts back the available ip + the mac address recieved.
the pc without ip gets the message and looks at the mac address. It recognizes it and takes the ip to be his.
thnx anyway. Greetz,

The Muppeteer.

themuppeteer@hotmail.com

Don't eat yellow snow...
 
Sounds like you did things the best possible way. On a side note, if you have a MAC address, you can actually build a packet up that will get to it, and if you supply an address, can sometimes (I think it depends on the NIC, but I'm not sure) force the machine to that IP address - probably similar to what you're doing, but since you don't mention HOW you send an IP address, I'm not sure.
 
I will (havn't done it yet) use udp and sockets and write a server program and client program,the ip will come in a ascii text string to the server,he will parse it and take the ip. Then I will set it using ifconfig. Then the pc must reboot.

Can you give a bit more explanation about what you have in mind ? (about building that packet up)

thnx a lot. Greetz,

The Muppeteer.

themuppeteer@hotmail.com

Don't eat yellow snow...
 
if by any chance you are using linux... the proc filesystem probably has the mac address in it somewhere.. i'm not sure where, but that might be a way to do it.
also pipe ifconfig which i think someone suggested already

 
Since on Linux ifconfig is allowed only to root.
how does one get the MAC addr of the card without using "ifconfig"
rgs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top