# [SOLVED] Finding a device IP over LAN

## Gabriel_Blake

Hi.

I'm having difficulties describing what I want to get here, so picture this:

Device A: server

Device B: laptop

Network: Ethernet with DHCP on router

Let's say I plug in both machines. They get an IP over DHCP. The problem is how can the laptop discover the IP of the server (no MAC checking) ? I was thinking about something that would broadcast some sort of id from the server so that the laptop will catch that. The security is not an issue, because after the laptop gets the server's IP the rest will continue via ssh+rsa.

I'm probably asking for something trivial, but I couldn't phrase it for google correctly.Last edited by Gabriel_Blake on Mon Jun 03, 2013 4:02 pm; edited 1 time in total

----------

## khayyam

 *Gabriel_Blake wrote:*   

> Let's say I plug in both machines. They get an IP over DHCP. The problem is how can the laptop discover the IP of the server (no MAC checking) ? I was thinking about something that would broadcast some sort of id from the server so that the laptop will catch that.

 

Gabriel_Blake ... the entire network is already broadcasting such information in the form of arp, its fairly trivial to find out what is on a network, the IP's in use, and their mac addresses, there are packages, like net-analyzer/netdiscover, designed for such aquistion, for example:

```
# netdiscover -i eth0 -r 192.168.1.0/24
```

Also, net-analyzer/arping comes with a script, arping-scan-net.sh, which scans a network for a given mac address.

best ... khay

----------

## Gabriel_Blake

khayyam I did mention: 

 *Quote:*   

> (no MAC checking)

 

I know it's trivial to find it using MAC with any network analyzer. The thing is I assume I don't know the mac address (or it may change after switching to a different Ethernet card/adapter) and I don't want to check EVERY IP in the network.

----------

## khayyam

 *Gabriel_Blake wrote:*   

> I did mention: (no MAC checking)

 

Gabriel_Blake ... you did, but you placed it in brackets and followed with a question mark, so it wasn't altogether clear.

 *Gabriel_Blake wrote:*   

> I know it's trivial to find it using MAC with any network analyzer. The thing is I assume I don't know the mac address (or it may change after switching to a different Ethernet card/adapter) and I don't want to check EVERY IP in the network.

 

Honestly, you plan to change the card often enough that this would be a hindrance, and for a server on your network whos mac address you can't "assume" to know? But, ok, as you plan to connect via ssh then set your server to use avahi-daemon to publish the sshd service, you should then be able to 'ssh server.local'.

best ... khay

----------

## John R. Graham

Out of morbid curiosity, why wouldn't you want to set up a simple DNS like dnsmasq?

- John

----------

## Gabriel_Blake

 *John R. Graham wrote:*   

> Out of morbid curiosity, why wouldn't you want to set up a simple DNS like dnsmasq?
> 
> - John

 

OK... How would this work ? I'm connected to the internet via NAT on my router. All my computers are set to GoogleDNS 8.8.8.8. How would dnsmasq affect DNS resolution if it's not even addressed to do so ?

----------

## John R. Graham

You would set up dnsmasq on your server, configuring it toHandle DHCP for your network. Of course, you would turn off your router's DHCP service.

Offer DNS to your network. Then dnsmasq would use Google DNS to satisfy name resolution for machines off your network.Under these circumstances, dnsmasq will keep a list of host names that have active DHCP leases and the DNS portion of dnsmasq will resolve those names locally. This is what a name server is for.

- John

----------

## Gabriel_Blake

 *John R. Graham wrote:*   

> Of course, you would turn off your router's DHCP service.

 

Won't do :/

Thanks for the help. I'll have to lower my requirements  :Wink:  I'll stick with the MAC based recognition.

----------

## _______0

wow what a stupid program, all arp does is check this file:

```
cat /proc/net/arp
```

I would restrain from using ipv4 tools, they are dumb and primitive. ipv6 protocol has built-in many things that are cumbersome to find out with ipv4. One such an example is ping6.

Try this:

```
ping6 -c4 -I eth0(or your device) ff02::1
```

Where it would take crazy routing and insane setup to ssh with ipv4, ssh'ing with ipv6 it's automagic.

Gentoo should introduce the -ipv4 USE flag.

----------

## Ant P.

Install avahi-daemon on all computers and add its initscript to default.

```
avahi-browse -at
```

----------

## _______0

 *Ant P. wrote:*   

> Install avahi-daemon on all computers and add its initscript to default.

 

This suggestion is for an ideal world and avahi was las updated:

2012-02-15

----------

## Ant P.

 *_______0 wrote:*   

> This suggestion is for an ideal world and avahi was las updated:
> 
> 2012-02-15

 

Stop being a ricer.

My suggestion works and obviates the need for ridiculous actions like memorising multicast IPv6 addresses and interface names, which might as well be random numbers on udev systems.

Avahi was last updated 7 weeks ago, not 16 months. You should update your Portage tree and run glsa-check ASAP if your local systems are so outdated; your obsolete software poses a threat to the herd immunity of other network users.

----------

