From: Stephen Kyle Date: 2007-10-31T20:02:26+09:00 Subject: Re: Find out the mac address On 31/10/2007, K. R. wrote: > Hi @all > > How can I find out the mac address from the default gateway with a ruby > script? > Does exist any methods to read it out? The script runs on a linux > distribution... I don't know if any methods, exist, but you could hack it up if you have the 'ip' package installed on your system, ie. 'ip show route' doesn't say the command wasn't found. Then you can try: # get your gateway IP address gateway = `ip route show`.match(/default.*/)[0].match(/\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?/)[0] # get the mac address for the gateway mac_address = `ip neigh show`.match(/#{gateway}.*/)[0].match(/..:..:..:..:..:../)[0] Steve (abuser of match) > > thanks for your comment! > -- > Posted via http://www.ruby-forum.com/. > >