Getting Yun to Yun API requests to work using hostname instead of IP Address

Hi,
I have a couple of Yuns (yun1 and yun2) on the same WiFi network.
I can call one Yun's API from the other if I refer to it using its IP address, but not if I use its hostname

Both hostname and IP address work if I type them into a browser window or run them as as curl command in terminal:

http://yun1.local/arduino/digital/13/0
http://192.168.0.4/arduino/digital/13/0

The following code is running on yun2

This doesn't work:

p.begin("curl");      
p.addParameter("http://yun1.local/arduino/digital/13/0");
p.run();

This works:

p.begin("curl");      
p.addParameter("http://192.168.0.4/arduino/digital/13/0");
p.run();

What can I do talk to them using their hostname instead of their IP Address?

Thanks
Daniel

Your yun1 doesn’t know what a ‘yun2’ is and vice versa. You can’t stick those names in a dns server, so you have to add those names in the /etc/hosts file (it only contains localhost by default).

kind regards,

Jos

Thanks Jos
I was trying to setup fixed IPs on the router and Yuns as a workaround, but I'll try your approach.

Would you mind giving me the steps to edit the hosts file via SSH?

I can SSH into it, but wouldn't know the subsequent steps.

Thanks again
Dan

I use the 'vi' editor that comes shipped with the distribution; other people use 'nano', but I don't know it. Maybe a google 'starting vi' (or similar) can help you out here.

kind regards,

Jos

cursive:
Thanks Jos
I was trying to setup fixed IPs on the router and Yuns as a workaround, but I'll try your approach.

Would you mind giving me the steps to edit the hosts file via SSH?

I can SSH into it, but wouldn't know the subsequent steps.

If you are using Windows on your host computer, use WinSCP...

Ralf

cursive:
What can I do talk to them using their hostname instead of their IP Address?

Although I haven't tried them, you can try installing either "howl-mdnsresponder" or plain "mdnsresponder" packages. They should make your yuns able to resolve each other's name
Start with howl-mdnsresponder: it's easier to uninstall if it doesn't work.