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 ...
![]() |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| |||
| |||
| 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. |
|
#2
| |||
| |||
|
In article Phil > 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 *** |
|
#3
| |||
| |||
|
Barry Margolin wrote: > In article > Phil > >> 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. |
|
#4
| |||
| |||
|
On Oct 24, 10:05 am, Phil > 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) |
|
#5
| |||
| |||
| Quote:
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 |
![]() |
« Previous Thread
|
Next Thread »
| Thread Tools | |
| Display Modes | |
| |
All times are GMT -4. The time now is 12:11 AM.





Linear Mode