Let's say that I have a computer plugged in to a local network using a dhcp connection, so it will get a different IP every time. Is there a way to find this computer (so the IP) from a different computer on the same local network?

Both computers run Linux. I can set up the "lost" computer a'priori before it gets restarted (and gets a different IP), but I would prefer a solution that just works out of the box (if it exists).

6 Answers 6


If you can configure the dhcp daemon, a good transparent solution would be binding a specific ip address to the computer network card MAC address — that way when the computer requests an address via dhcp, the daemon will hand out the very same address.

Some dhcp servers let computers propose hostnames (I'm unsure of the internals, and whether this is actually common behavior or not) - you may want to check whether this works with your router or not. Even if it works, you need to have your dhcp client send the hostname (the --hostname option in dhcpcd). It's a shot in the dark, but it's worth a try — if it works, you can just use the computer hostname instead of the ip address (or use it to find the numeric address).


Since you tagged your question "Debian", here's a quick recipe that should solve your problem.

On your lost and finder computers run the following (as root, or use sudo as/if necessary):

# apt-get install avahi-utils

Then, as long as the lost and finder computers are on the same broadcast domain (i.e. the same physical network), you should be able to use avahi-resolve to resolve the IP address (either v4 or v6) of each host from the other.

For example, any user on finder can resolve lost, as follows:

$ avahi-resolve -4 -n lost.local
$ avahi-resolve -6 -n lost.local
lost.local      fe80::a00:27ff:fea7:4900

Similarly, on lost:

$ avahi-resolve -4 -n finder.local
$ avahi-resolve -6 -n finder.local
finder.local    fe80::a00:27ff:fe72:804

Obviously, I have glossed over a lot, and a few little details could go wrong that prevent avahi from working correctly out of the box, but from my own experiments on a few different occasions, there's a good chance that it should all Just Work (tm).


If you have some control over the DHCP server, arrange that it always provides the same IP address to your machine. Most DHCP servers out there can reserver IP addresses to a machine with a given MAC address or to a particular client name.

Otherwise, the next best thing is to use a dynamic DNS service: a small program running on your computer sends an update to a DNS server whenever your computer's IP changes. You can set up your own dynamic DNS server inside or outside your LAN, or piggyback on an existing DNS server, or use one of the dynamic DNS services out there (there are free ones, at least for personal use).

If that's not an option either, you can have a script that accesses a web page under your control and leaves your IP address there. Crude, but works through most firewalls.

An alternative that doesn't require knowing the IP address of your computer is to establish a tunnel (a VPN) between your computer and another computer with a known IP address. Run the VPN client on the computer with the changing address and the VPN server on the fixed-IP machine. Once the tunnel is established, you can open connections in either direction.


You can use tcpdump to capture the response to a broadcast ping from your finder pc. For example if your network is and the mac address of your "lost" computer is a1:25:de:1f:00:12

ping -c 20 &> /dev/null & tcpdump -n -c 1 ether host a1:25:de:1f:00:12

Adjust the ping count higher if you're not getting any responses


If you are in the same network you are in the same broadcast domain. How big is the network? Class C or more?

If class C you could simply ping all 253 IPs and look into your arp-cache if you find "your" MAC-adress.


General steps

  1. edit the file: /etc/nsswitch.conf.
  2. change the line: hosts: files .... to: hosts: files wins .......
  3. then at the commandline:

    $ sudo apt-get install winbind
  4. now you can refer to the computer by hostname:

    $ ping computername`,`ftp computername

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .