You are not logged in.

#1 2008-10-13 22:32:27

hrsvan
Member
Registered: 2007-11-11
Posts: 25

nslookup on lan

Hi,
Im trying to get a sync working between my laptop and desktop. The desktop got a static ip and the laptop a dynamic ip.
till now ive been checking the laptop ip manually but I want to make this automatic. Since the ip might change when my roomie or my cell logs on to the lan.
I started out using nmap, but this only gives the ip of the possible hosts... thereafter or instead i might use nslookup to make sure that it's the right device's ip i got. However the nslookup doesn't seem to work on a lan...?

so, how do I get the ip and hostname of another computer on my home network?

thanks

Offline

#2 2008-10-16 14:38:41

hrsvan
Member
Registered: 2007-11-11
Posts: 25

Re: nslookup on lan

allright guys... this was not very easy but I found a solution which I hope will end up usefull for someone else.

The script is for finding fx a laptop on which you know the name but are not totally sure of the ip-adress. For this to work, you must have started the avahi-daemon

#!/bin/bash

LAPTOPNAME=laptop
VAR=`nmap 10.0.0.2/28 | grep -o -E "10\.0\.0\.[0-9]{1,3}"`

for i in ${VAR[@]};do
  NAME=`avahi-resolve-address $i | awk '{ print $2 } '`
    if [ "$NAME" == "$LAPTOPNAME.local" ]
    then
      LAPTOPIP=$i
    fi
done

if [ "a$LAPTOPIP" != "a" ]
then
  echo laptop found on $LAPTOPIP
fi

Last edited by hrsvan (2008-10-16 14:46:20)

Offline

Board footer

Powered by FluxBB