getting mac from ip (or the contrary)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting getting mac from ip (or the contrary)
# 1  
Old 03-11-2009
getting mac from ip (or the contrary)

Hi there,
I need to find a way to check that a remote machine got the correct ip address. I have a dhcp server and need to run some commands after machine M acquired address A.
There are lots of reasons why machine M could have another address:
1) DHCP not reloaded
2) Machine M offline or powered off
3) Machine M has not renewed its ip address

Is there a way to do one of the following?
Code:
if [$(getmacfromip $ip) == $mac]; then ...
if [$(getipfrommac $mac) == $ip]; then ...

Can you help me lead me in the right direction?
Thanks in advance
Santiago
# 2  
Old 03-11-2009
man arp
# 3  
Old 03-11-2009
Thanks danmero for helping me.
Unfortunately, I can't use arp (command not found). Maybe because I'm not root.
I found this solution though:
Code:
[[ -n $(mysql "SELECT id FROM terminal WHERE ip = '$ip' AND mac = '$(ssh root@$ip 'cat /sys/class/net/eth0/address')'") ]] && ...

Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. OS X (Apple)

Let's get a .mac top level domain! As in www.xyz.mac

ICANN, the Internet Corporation for Assigned Names and Numbers, is inviting proposals for new sponsored top level domains. This may be wishful thinking, but isn't that a chance to push for a .mac top level domain (TLD)? I for one would VASTLY like the idea of having a domain of something.mac --... (0 Replies)
Discussion started by: ropers
0 Replies
Login or Register to Ask a Question