dbaspot
Tags Register FAQ Calendar Search Today's Posts Mark Forums Read

Map hostname to ethernet MAC address for wake-on-lan - shell

This is a discussion on Map hostname to ethernet MAC address for wake-on-lan - shell ; Dear All, Wake-on-lan needs to know the target machine's ethernet address. I'd like to write a wrapper script around this so that I can wake a machine given its hostname. So I need to be able to get an ethernet ...


Home > Database Forum > Operating Systems > shell > Map hostname to ethernet MAC address for wake-on-lan

Reply

 

LinkBack Thread Tools Display Modes
  #1  
Old 10-24-2008, 01:05 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Map hostname to ethernet MAC address for wake-on-lan

Dear All,

Wake-on-lan needs to know the target machine's ethernet address. I'd
like to write a wrapper script around this so that I can wake a machine
given its hostname. So I need to be able to get an ethernet MAC address
given the hostname. Can anyone suggest how to do this? My dhcp server
has a table (/etc/ethers) with this info, but I don't want to replicate
this everywhere because of the need to keep it up to date. So I was
wondering if there is some "nslookup"-like way of doing it. I think the
answer is probably "no", but it's always worth asking isn't it? If you
know of a better newsgroup, please let me know.

Cheers, Phil.
Reply With Quote
  #2  
Old 10-24-2008, 11:40 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Map hostname to ethernet MAC address for wake-on-lan

In article ,
Phil wrote:

> Dear All,
>
> Wake-on-lan needs to know the target machine's ethernet address. I'd
> like to write a wrapper script around this so that I can wake a machine
> given its hostname. So I need to be able to get an ethernet MAC address
> given the hostname. Can anyone suggest how to do this? My dhcp server
> has a table (/etc/ethers) with this info, but I don't want to replicate
> this everywhere because of the need to keep it up to date. So I was
> wondering if there is some "nslookup"-like way of doing it. I think the
> answer is probably "no", but it's always worth asking isn't it? If you
> know of a better newsgroup, please let me know.


There's no standard DNS-like protocol for this.

If your machine has talked to the other machine recently, its MAC
address should be in your ARP cache, which you can examine using the
"arp" command.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Reply With Quote
  #3  
Old 10-25-2008, 08:58 AM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Map hostname to ethernet MAC address for wake-on-lan

Barry Margolin wrote:
> In article ,
> Phil wrote:
>
>> Dear All,
>>
>> Wake-on-lan needs to know the target machine's ethernet address. I'd
>> like to write a wrapper script around this so that I can wake a machine
>> given its hostname. So I need to be able to get an ethernet MAC address
>> given the hostname. Can anyone suggest how to do this? My dhcp server
>> has a table (/etc/ethers) with this info, but I don't want to replicate
>> this everywhere because of the need to keep it up to date. So I was
>> wondering if there is some "nslookup"-like way of doing it. I think the
>> answer is probably "no", but it's always worth asking isn't it? If you
>> know of a better newsgroup, please let me know.

>
> There's no standard DNS-like protocol for this.
>
> If your machine has talked to the other machine recently, its MAC
> address should be in your ARP cache, which you can examine using the
> "arp" command.


Hi Barry,

Thanks for that. Unfortunately arp is unlikely to help in this case: if
you're sending a wake-on-lan packet there's a very good chance that you
haven't been talking to it for quite a while....

I suppose that something that could record old arp data after it had
expired from the arp cache might work. I'll have a think.

Another option is to sidestep the problem and have only the machine that
actually knows the ethernet addresses - the DHCP server - send the WOL
packets and for the other machines to somehow forward their requests via it.


Phil.

Reply With Quote
  #4  
Old 10-26-2008, 08:19 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Map hostname to ethernet MAC address for wake-on-lan

On Oct 24, 10:05 am, Phil wrote:
> Wake-on-lan needs to know the target machine's ethernet address. I'd
> like to write a wrapper script around this so that I can wake a machine
> given its hostname. So I need to be able to get an ethernet MAC address
> given the hostname. Can anyone suggest how to do this? My dhcp server
> has a table (/etc/ethers) with this info, but I don't want to replicate
> this everywhere because of the need to keep it up to date. So I was
> wondering if there is some "nslookup"-like way of doing it. I think the
> answer is probably "no", but it's always worth asking isn't it? If you
> know of a better newsgroup, please let me know.


Going from hostname to IP is relatively easy.
From IP to MAC address isn't as trivial, but ...

You may want to do something roughly like:
o build a table of hostnames of interest and their IPs,
o for IPs that one doesn't have the MAC address for, ping the host
(from
the host's local subnet) and examine the ARP table for a MAC
address
o also check the DHCP server data for possible MAC address for the IP
o periodically recheck - updating IPs and MAC addresses
o might want a means to also manually input a MAC address (e.g. for
new
hardware that's not yet been introduced to the network)
Reply With Quote
  #5  
Old 02-26-2009, 07:23 PM
Database Newbie
 
Join Date: Feb 2009
Posts: 1
ladislav.soukup is on a distinguished road
Lightbulb Re: Map hostname to ethernet MAC address for wake-on-lan

Quote:
Originally Posted by Phil View Post
Dear All,

Wake-on-lan needs to know the target machine's ethernet address. I'd
like to write a wrapper script around this so that I can wake a machine
given its hostname. So I need to be able to get an ethernet MAC address
given the hostname. Can anyone suggest how to do this? My dhcp server
has a table (/etc/ethers) with this info, but I don't want to replicate
this everywhere because of the need to keep it up to date. So I was
wondering if there is some "nslookup"-like way of doing it. I think the
answer is probably "no", but it's always worth asking isn't it? If you
know of a better newsgroup, please let me know.

Cheers, Phil.
It is not posible to use hostname or IP address to do WoL, but you can write small application with local Database to send the WoL package using hostname.
All you need is "register" (store the hostname and MAC) the computer while it is powered on to the app's DB and then just use the same app and DB to translate hostname to MAC and then wake it up.

I have written a small simple app to do this (using sqlite as storage). If you want, you can download it from my new blog - http://code.ladasoukup.cz/2009/02/wa...nstead-of.html
Reply With Quote
Reply

Thread Tools
Display Modes



All times are GMT -4. The time now is 12:11 AM.