Score:1

Connecting to raspberry pi failure in name resolution

je flag

My current setup is that I have multiple Raspberry pis connected to my laptop through a network switch. None of the pis are connected to the internet. I want to broadcast commands to all of them to use a camera so want to use Terminator through Ubuntu on Windows.

If I ssh into the pi from PowerShell using ssh -X pi[i]@rpi[i].local, where [i] represents the number of my pi, I can get access but broadcasting commands is not an option. When I enter Ubuntu, and subsequently terminator or tmux, I cannot get access through ssh and the error message is:

ssh: Could not resolve hostname rpi2.local: Temporary failure in name resolution

When I unplug the cable connecting my laptop to the pis the error message does not change.

Has anyone got an idea as to what the problem might be and why I cannot connect through Ubuntu, but powershell works fine?

Artur Meinild avatar
vn flag
Not a direct answer, but Tmux supports this. [See my answer here](https://askubuntu.com/questions/1320470/open-8-panes-of-tmux-and-go-to-different-directory-in-each-one-and-run-a-comma/). Although, the question is about 8 different directories, it might as well be 8 different SSH connections - it's the same. The main thing here is pane synchronization.
Paul avatar
je flag
I will look into using tmux as an alternative, I have never heard of it before until today. Thank you for your suggestion
Artur Meinild avatar
vn flag
Be aware that Tmux is a "server" solution, whereas a terminal (such as Terminator) is a client solution. Tmux runs as a persistent server, so it's accessible with any terminal. This also gives additional safety when running remote commands, since nothing will break if you loose connection. You can just reconnect to the server, and everything will still be running.
Paul avatar
je flag
Hm strange but tmux does not allow me to connect to my raspberry pis either. The error code is simply "Could not resolve hostname: Name or service not known" even though my pi is clearly turned on and plugged in
Artur Meinild avatar
vn flag
I think you need to troubleshoot the network then. This most likely isn't an Ubuntu issue though. Do you have a firewall or gateway where you can see the IP addresses of the Pis? You should probably look into this, but again most likely off-topic here. Also, in your question please include as much details as possible. Commands you run, IP addresses, error messages etc.
Paul avatar
je flag
I have added extra information in my initial question to hopefully clarify this.
NotTheDr01ds avatar
vn flag
@ArturMeinild and I are assuming this is on Windows Subsystem for Linux since you mention that it works from PowerShell. Is this correct? If so, can you add the [tag:windows-subsystem-for-linux] tag? Also, if it is WSL, do you have a `/etc/wsl.conf` in Ubuntu?
Paul avatar
je flag
Added the tag. There is no /etc/wsl.conf file in Ubuntu.
Score:1
vn flag

Since you mention that the Pi's are accessible from the Windows host but are not on the Internet, I'm going to make an assumption that they are either on a separate VLAN or have firewall rules to prevent access from devices outside the local network.

However, Ubuntu running on WSL2 is actually on a separate network from the Windows host. Its network is running behind a NAT'd, virtual Hyper-V switch.

This is likely why Ubuntu isn't able to connect to the Pi's. If that's the case, it's pretty much the converse of this question, but with similar answers.

This should also explain the fact that name resolution is failing. The .local TLD indicates that the Pi's are using mDNS. I'm not an expert in mDNS, but I'm guessing you'd need to be able to see them on the network in order to get their addresses that way. There's no "DNS server" that Ubuntu/WSL2 could use to perform the lookup for .local.

With that said, here are some possible options (and non-options):

Run the Windows SSH client through Ubuntu

This one started off as an afterthought that I was adding at the bottom of this answer, but it's possible that it may be the most straightforward solution.

Try:

ssh.exe -X pi[i]@rpi[i].local

Since Ubuntu can run Windows commands (as long as you append the .exe, you may be able to just utilize this form to accomplish your task.

One potential caveat is that you have the -X option in there for X11 forwarding. If you really do need this to forward to Ubuntu (via WSLg), then this may not be an option. I haven't tested it in that capacity.

WSL1

Unfortunately, for your use-case, you may not be able to use WSL1 here. Normally this is the easiest method for solving this type of problem. WSL1 operates as a pseudo-kernel translation layer directly to the Windows kernel. As a result, it shares the same network as the Windows host.

However, WSL1 doesn't support mDNS, so if you want to use WSL1, you'd need to either use the IP addresses or set up some type of resolver for those Pi addresses. This should be possible (IIRC) by editing the Windows host file (c:\Windows\System32\Drivers\etc\hosts).

If you want to use this method, see the other answer I linked above for how to backup and convert to WSL1.

SSH Jumphost through Windows OpenSSH server

I find having the Windows OpenSSH server to be a nice "Swiss Army Knife" for connectivity assistance. In this case, the concept is the same as in the other answer, but the flow is reversed.

After configuring the Windows OpenSSH server as mentioned in the other answer, you would be able to access your Pi's through something like:

ssh -X pi[i]@rpi[i].local -J $(hostname).local

If your username differs for Windows, you can use:

ssh -X pi[i]@rpi[i].local -J <windows_username>@$(hostname).local

What this does is first connect to the Windows OpenSSH server using mDNS ($(hostname).local), then uses that as a jumphost to the Pi. Since you will be connected to the Windows network after the "jump", the mDNS lookup for the Pi's should work as well. I tested this the best I could with my network.

Bridge network

As mentioned in the other answer, it may be possible to use an experimental feature to create the virtual network switch in bridged mode. You no longer need a Preview version of WSL, though - As long as you've installed WSL from the Microsoft Store, it should work.

PowerShell and/or Windows SSH client through Tmux

Similar to the first possible solution and untested for this particular use-case, but in theory you can use the concept in my answer here to handle this by running PowerShell (or the Windows SSH client) inside Tmux in Ubuntu.

Paul avatar
je flag
Thank you I will try this tomorrow when I get back into work
Paul avatar
je flag
Thankfully your suggestion of using ssh by "ssh.exe" works and I am now able to connect to my raspberry pis. I have used the -Y flag which does the X forwarding (personally using x410 for this) and everything seems fine. Thank you for your answer.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.