adlersam
Posts: 6
Joined: Sat Aug 18, 2012 6:18 am

Zeroconf on RPi?!

Sat Feb 23, 2013 5:28 pm

Hi,

most time, my RPi runs standalone, doing its work in a remote location while not being connected to a LAN. But for maintenance, I want to be able to ssh into it, either by connecting the RPi at home to my local network _or_ by _directly_ connecting a Laptop to the RPi at the remote location.

While the first scenario does work out of the box, as both the RPi and the ssh client computer get IP addresses assigned from my LAN's DHCP server, neither the laptop nor the RPi will get IP adresses assigned in the second scenario.

An easy workaround would be to set static IP addresses on both sides, but I'd like to be a bit smarter and use Zeroconf to get my mini-network up and running. This way, I hope that the RPi continues to get an IP from the DHCP server when connected to my home network, while it negotiates appropriate IP addresses through Zeroconf with my Laptop when being connected point to point.

Unfortunately, no matter what I do, I can't get the RPi to configure an IP using Zeroconf. I tried these tutorials:

http://raspberrypi.org/phpBB3/viewtopic ... 66&t=18207
http://elinux.org/RPi_Advanced_Setup

But the RPi leaves eth0 unconfigured, i.e. ifconfig never shows an IP address being assigned to eth0. I even tried it on a newly installed Raspbian, but still without any success.

Can anyone spot what I may do wrong? Thanks a lot for any help,

AdlerSam

P.S.: A more general tutorial:

http://linuxwiki.de/ZeroConf

says that a packet called zcip is available in Debian that does the IP assignment, but this packet is not available in the Raspian repository.

randrade
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
Contact: Website

Re: Zeroconf on RPi?!

Sun Feb 24, 2013 12:18 am

Doesn't Avahi do zeroconf without problems?

gridrun
Posts: 46
Joined: Mon Feb 18, 2013 12:26 pm
Contact: Website

Re: Zeroconf on RPi?!

Sun Feb 24, 2013 12:38 pm

Why not use a DHCP server on the maintenance laptop? You could try http://www.dhcpserver.de/dhcpsrv.htm
Find more info on Raspberry Pi, Virtualization and all things cloudy on my blog: http://niston.wordpress.com

adlersam
Posts: 6
Joined: Sat Aug 18, 2012 6:18 am

Re: Zeroconf on RPi?!

Mon Feb 25, 2013 7:30 am

Doesn't Avahi do zeroconf without problems?
I meanwhile found out that the Debian packet avahi-autoipd is required for automated IP assignment. Furthermore, the file /etc/dhcp/dhclient-exit-hooks.d/zzz_avahi-autoipd, wich is part of that packet, seems to be wrong: It starts the avahi-autoipd deamon when the one of the DHCP events EXPIRE|FAIL|TIMEOUT occurs - which I could never see happening on the RPi on either bootup or plugging / unplugging the ethernet cable. After changing this script to start the deamon on PREINIT, everything works fine now.
Why not use a DHCP server on the maintenance laptop? You could try http://www.dhcpserver.de/dhcpsrv.htm
Well, because the laptop is typically being used as a DHCP client in my home LAN as well - and I was looking for a solution without the need of manual reconfiguration.

Anyhow, prolem is solved now :-). Many thanks for your suggestions.

ericchaves
Posts: 2
Joined: Sat Jul 13, 2013 5:27 pm

Re: Zeroconf on RPi?!

Sat Jul 13, 2013 5:36 pm

Hi Adler,

I'm facing a similar problem and after several trials I'm still unable to make my rpi to autoassign an local-link ip when connected directly to my macbook.

What exactly have you done in your case to solve the issue?

Cheers,

Eric

adlersam
Posts: 6
Joined: Sat Aug 18, 2012 6:18 am

Re: Zeroconf on RPi?!

Sat Jul 13, 2013 7:12 pm

Hi Eric,

did you install avahi-autoipd? If you did, you could simply start the autoipd deamon manually, which should assign an IP address from the 169.254 range being dedicated for that purpose.

If that works, you may change /etc/dhcp/dhclient-exit-hooks.d/zzz_avahi-autoipd as described in my previous post to automate the process, i.e. assigning a 169.254.x.y address _only_ if no "regular" address could be obtained from a DHCP server.

Hope that helps,

AdlerSam

ericchaves
Posts: 2
Joined: Sat Jul 13, 2013 5:27 pm

Re: Zeroconf on RPi?!

Sat Jul 13, 2013 8:25 pm

HI Adler,

Before any further, thanks for your help. I'm having a hard time with this setup because I'm lacking KVM required to attach the rpi, making the ssh from my macbook the only possible way to access it. When the unit is attached to my router, it obtains an ip from dhcp as expected and I can ssh into it as usual. However when I connect rpi directly to the mac's ethernet it seems that no local-link ip is assigned at the rpi's end.

In order to facilitate some debugging, I configured the rpi to announce it's services via bonjour, which it does as expect when connected to the router.

I already installed avahi-daemon and avahi-autopid plus updated zzz_avahi-autoipd as below, which I assumed it's what you did.

Code: Select all

case "$reason" in
    MEDIUM|ARPCHECK|ARPSEND|NBI)
        ;;

    BOUND|RENEW|REBIND|REBOOT|STOP|RELEASE)
        # Stopping avahi-autoipd is left for the enter hook
        ;;

    PREINIT|EXPIRE|FAIL|TIMEOUT)
        /user/sbin/avahi-autoipd -wD $interface 2> /dev/null
       ;;
esac
I also tried to define a second interface (eth0:1) and setted it to start as ipv4ll, in a chance to have it working with multiple ips, without any luck. The only way so far that I reach some success was to have the second if setted with an static local-link ip manually assigned, which I would like to avoid.

Do you have any idea on what could be wrong or how could I debug the autoipd deamon? I haven't got much luck with google so far.

Cheers,

Eric
adlersam wrote:Hi Eric,

did you install avahi-autoipd? If you did, you could simply start the autoipd deamon manually, which should assign an IP address from the 169.254 range being dedicated for that purpose.

If that works, you may change /etc/dhcp/dhclient-exit-hooks.d/zzz_avahi-autoipd as described in my previous post to automate the process, i.e. assigning a 169.254.x.y address _only_ if no "regular" address could be obtained from a DHCP server.

Hope that helps,

AdlerSam

adlersam
Posts: 6
Joined: Sat Aug 18, 2012 6:18 am

Re: Zeroconf on RPi?!

Sun Jul 14, 2013 7:47 am

Hi Eric,

if you really don't have an HDMI monitor and a keyboard around to temporarily connect it to the RPI for debugging, you may try this:

- Connect your RPI to your router and ssh into it.
- Have a look at the avahi-autoipd man page (man avahi-autoipd); that's always a good idea :-).
- Start avahi-autoipd with the --force-bind option (avahi-autoipd -D --force-bind eth0).
- Check if you got a link-local address now on eth0:avahi with ifconfig. If you didn't, something is seriously wrong.
- Assuming everything is fine until now, you may temporarily add the --force-bind option into the autoipd enter- and exit-hooks and reboot.
- After booting, look at the interface again. It should now get a link-local address whenever you connect the ethernet cable and release it when you unconnect the cable.
- If things don't work as expected, find out why: Just put echo statements into all cases of both the autoipd's enter- and exit hooks and check in /var/log/syslog what happens when you plug / unplug your ethernet cable.
- If you know the events that are triggered when plugging / unplugging the cable, adapt the scripts according to your needs.

Cheers,

AdlerSam

User avatar
cyrano
Posts: 714
Joined: Wed Dec 05, 2012 11:48 pm
Location: Belgium

Re: Zeroconf on RPi?!

Mon Jul 15, 2013 11:08 am

ericchaves wrote:I'm having a hard time with this setup because I'm lacking KVM required to attach the rpi, making the ssh from my macbook the only possible way to access it. When the unit is attached to my router, it obtains an ip from dhcp as expected and I can ssh into it as usual. However when I connect rpi directly to the mac's ethernet it seems that no local-link ip is assigned at the rpi's end.
You need to enable "Internet Sharing" in System Preferences / Network on the MB Pro. That will launch a DHCP server which will provide the Pi with an ip. I've been using this since I got my Pi in january.

geco82
Posts: 1
Joined: Sun Oct 26, 2014 11:52 am

Re: Zeroconf on RPi?!

Sun Oct 26, 2014 11:55 am

Hi ericchaves,
did you solve the issue?
Thanks

Giacomo

jviyer
Posts: 30
Joined: Mon Nov 04, 2013 3:48 pm

Re: Zeroconf on RPi?!

Sat Feb 13, 2016 2:36 pm

Hello AdlerSam,
I have a request. I have been reading quite a bit about connecting wireless to without going through the home router. I don't want to run a dhcp server (i.e. I am trying to do your solution).Tried several approaches before I saw this post. Would you be able to share the end to end what I need to do.
background:
I have installed avahi-daemon and avahi-autoipd. I have been able to ssh to "mypi.local" when Rpi is connected to home network.
I have the EDIMAX wifi adapter (dmesg give rtl8192us as the driver.)
I have tried:
a) by modifying /etc/network/interfaces file as follows (adhoc mode)

Code: Select all

auto lo

iface lo inet loopback
iface eth0 inet dhcp

#allow-hotplug wlan0
#iface wlan0 inet manual
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
auto wlan0
iface wlan0 inet static
 address 192.168.1.1
 netmask 255.255.255.0
 wireless-channel 1
 wireless-essid RPiAdHocNetwork
 wireless-mode ad-hoc
and have:

Code: Select all

case "$reason" in
    MEDIUM|ARPCHECK|ARPSEND|NBI)
        ;;

    BOUND|RENEW|REBIND|REBOOT|STOP|RELEASE)
        # Stopping avahi-autoipd is left for the enter hook
        ;;

    PREINIT|EXPIRE|FAIL|TIMEOUT)
        /user/sbin/avahi-autoipd -wD $interface 2> /dev/null
       ;;
esac
Then, on the PI I did:

Code: Select all

ifdown --f wlan0
- Started: avahi-autoipd with the --force-bind option (avahi-autoipd -D --force-bind wlan0).
ifdup --f wlan0
I am able to discore the network on ubuntu laptop:

Code: Select all

sudo iw dev wlan0 scan | grep SSID
...
SSID=RPiAdHocNetwork. 
But unable to really connect to it !
<on my Ubuntu 12.04 laptop I did>:

Code: Select all

sudo iwconfig wlan0 essid RPiAdHocNetwork
ping myrpi.local 
ping: unknown host myrpi.local
Sorry to impose on your time but since you got it working I was hoping to get some sample configs/command sequence.
Thanks a lot !
Jay

Return to “Networking and servers”