0

I have recently replaced a router at home. The old one was D-Link DIR-300, the new one is Keenetic Lite. There are two computers at home, let's call them desktop and laptop.

The problem is, before I changed the router I was able to connect e.g. from laptop to desktop like that:

ssh user@desktop

and it worked just fine; now when I try that, I get

ssh: Could not resolve hostname desktop: Name or service not known

which apparently means that ssh doesn't know what desktop is anymore.

The computer still seems to be visible from the local network, when I run nmap -sP 192.168.1.*, IP addresses of both computers are there. Furthermore, I don't think the issue is with ssh itself: when I set up port 22 forwarding on router, I was able to ssh into both computers using their external IP addresses. Using local IP addresses leads to port 22: connection refused, though.

Here are my questions:

  1. How the hostname was resolved in the first place? When I did ssh user@desktop, how did the program find out to which IP should it connect?
  2. How do I fix my setup so that it is able to do that again?
  3. Why am I unable to connect via ssh using local IP addresses?

1 Answer 1

1

Your old router may have had its own dns service running and at some point you entered the names laptop and desktop and told it to assign them the same address all the time. Or, your computers may actually be named laptop and desktop and the old router's DHCP service was picking that up when they asked for an address.

So.. to fix this, you'll need to find equivalent settings in your router, or work around it. Common work around for non-mobile devices (iThings and 'droids, etc) is to use the hosts file to provide a mapping of a name to an IP address. Alternatively, use a 3rd device to provide that service - I use a Raspberry Pi to provide DHCP, local network DNS (desktop.home.test), a caching only DNS server for external lookups, and DHCP service. More manual config involved but as a sysadmin/dev guy it isn't much...

As to not being able to connect via IP address, assuming the address is correct it may be possible that your router is splitting wireless off onto a different subnet from the wired connections and is preventing communication between them. This can be kinda common for providing guest access, so a client has a internet access but can't see/access computers on the local-to-it subnet. Again, solution to this will actually depend on the router, the software/firmware version it is running, etc.

Depending on what your current router/modem can do you may want to look at installing one of the 3rd party firmware/OSes on it, they all tend to provide all of these services and more (like QoS, etc)

2
  • "Common work around for non-mobile devices (iThings and 'droids, etc) is to use the hosts file to provide a mapping of a name to an IP address." Can I rely on these addresses not changing?
    – wrwt
    Commented Jun 21, 2019 at 21:37
  • @wrwt: That depends mostly on the router that is assigning the addresses. Some will remember the lease even after it expires, allowing devices to stick to the same address for years. Others retain the lease for just as long as it gets renewed. Some don't do persistent leases at all; as soon as the device reboots it gets a new lease. Finally some are just routers from hell. To be sure /etc/hosts always works, you should check if your router allows configuring static leases (aka DHCP reservations) based on MAC addresses. Commented Jun 21, 2019 at 21:43

You must log in to answer this question.

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