0

I'm currently working on a project using 4 raspberry pi as a cluster. These pi's are attached to each other through a local network, but I need to be able to send command to it from a host computer over wi-fi. Hence they are also configured on the same wi-fi network as the host.

My problem is, is that I can't connect to them through ssh with just their hostname from my laptop. If I use their IP address it works fine, but i'm on a eduroam network so the IP addresses change every 24 hours, so I can't make a script connecting to them based on IP's.

I've tried both ssh and ping using to hostname as such:

ping my_hostname.local
ssh my_hostname.local
ssh pi@my_hostname.local

All of these result in a "Name or service not known" error.

Now having searched the internet far and wide there were several problems that could cause this.

  1. Ssh is not enabled on the raspberry pi.
  2. Avahi daemon is not running.
  3. Avahi daemon is running and should be turned off. (This was a posted solution for post Jessie distro's)

None of these solutions worked though.

The Laptop is running CentOS 7 and the pi's are on the latest Raspbian Stretch release

EDIT: Verbose output of SSH connection:

[mpuls@mitch ~]$ ssh -v epnpi1
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
ssh: Could not resolve hostname epnpi1: Name or service not known
[mpuls@mitch ~]$ ssh -v epnpi1.local
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
ssh: Could not resolve hostname epnpi1.local: Name or service not known
[mpuls@mitch ~]$ ssh -v pi@epnpi1.local
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
ssh: Could not resolve hostname epnpi1.local: Name or service not known
[mpuls@mitch ~]$ ssh -v pi@epnpi1
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
ssh: Could not resolve hostname epnpi1: Name or service not known
  • 1
    Who assigned the host names? Why do you think they should be accessible by hostname? That's not necessarily the default on your network. – Brick Mar 1 '18 at 16:02
  • @Brick Well the current setup I have with my cluster is not going to be the final one. Eventually the host computer will also be connected on the same local network that the cluster is on, but they currently only have 1 ethernet port per pi which are used to link the 4 together. So until then for testing purposes I have to connect to them through wifi. But having to look up every pi's IP address every day with a screen also isn't optimal, hence I want to be able to connect to them with their host names instead. – TH3Mitch Mar 2 '18 at 9:10
  • 1
    How did you change hostname? What do /etc/hostname and /etc/hosts contain? – Milliways Mar 2 '18 at 11:41
  • 1
    @TH3Mitch You didn't answer my question at all. This doesn't seem to have anything to do with the Pis. It seems like it's a basic networking issue related to your router and DNS. Your expectation that you can look these up by host name is not reasonable as stated. Something on your network will have to provide that look-up function, and we cannot know what might do that without knowing more about your network structure. – Brick Mar 2 '18 at 13:19
-1

You need to use a DNS server to allow all devices on your network to use those hostnames, .local is usually for avahi/bonjour so without that service those hostnames will not work without a DNS server, if you do not want to make a dns server, you can add those entries to your hosts file in the format

ip.address.4.octets name

ex.

192.168.0.23 raspberrypi1
192.168.0.24 raspberrypi2

You will need to add those entries to the host file of all computers accessing the pi's or just use a DNS server

On linux, the hosts file is typically in /etc/hosts

  • Because the ip gets changed every 24 hours it would mean i'd have to change that file every day as well. I also can't make the IP static since it's a university eduroam network. I've been told that the DNS server is running on the network so that I should be able to connect through hostnames. But even with the avahi service running I can't connect to them with .local – TH3Mitch Mar 2 '18 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.