2012년 11월 26일 월요일

Get mac address of the remote host

How can I do to get mac address of the remote server?

This question came from implementation of functionality that registering a new host into the management solution. The management server needs mac address of every new server to issue UID. 

I thought connecting to the remote host by ssh and run some commands. 
However, Windows server is including into environment. ssh doesn't work in Windows OS.   

I got an idea of using ARP(Address Resolution Protocol) from: http://windowstipoftheday.blogspot.kr/2006/02/finding-mac-address-of-remote-computer.html

1) Ping checking to find mac address (Here, I used check_ping command, one of nagios plugins)
$ /usr/lib64/nagios/plugins/check_ping -H 192.168.20.169 -w 3000.0,80% -c 5000.0,100% -p 5
PING OK - Packet loss = 0%, RTA = 1.57 ms|rta=1.574000ms;3000.000000;5000.000000;0.000000 pl=0%;80;100;0

2) If ping was succeed, run "arp -a ip" 
$ arp -a 192.168.20.169 | egrep -o '([0-9a-f]{2}:){5}[0-9a-f]{2}'
00:16:3e:c3:7a:43

References: 
1. http://windowstipoftheday.blogspot.kr/2006/02/finding-mac-address-of-remote-computer.html
2. http://www.grymoire.com/Unix/Regular.html


댓글 없음:

댓글 쓰기