Tuesday 4 November 2014

Installing Avahi (Zeroconf) for raspberry pi

If raspberry pi get an IP from the DHCP server at the home modem/router, the IP address may change after we reboot the router or raspberry pi itself. So next time if we want to access raspberry pi using ssh through IP address, we have to use "nmap" to scan the new IP address. We can overcome this difficulties by installing avahi (zeroconf) at the raspberry pi.

1. At the raspberry pi terminal, simply run "apt-get update & apt-get install libnss-mdns".

2. After the installation complete, run "ps -A | grep avahi" command to make sure the avahi-daemon is running



3. Now open command prompt from another computer that connected to the same home router, and try to ping to raspberry pi hostname. If you are not sure your raspberry hostname, use "cat /etc/hostname". By default the name should be "raspberrypi". The ping command should be "ping raspberrypi.local" add .local after the username. If your machine is Windows, follow the step 3.1.

To retrieve the raspberry pi's hostname

Now we can ping to raspberry pi even without knowing the its IP address

3.1 In Windows by default it doesn't support Zeroconf service. We can install Apple software, iTunes that comes together with Bonjour service (based on Zeroconf). But if you just want to install Bonjour service, follow the following steps:-

   a) Download iTunes.
   b) Right click and open with WinRAR
 


   c) Double click on "Bonjour.msi"


   d) Install Bonjour. Once the installation finished, right click on "Computer" >> Manage >>                      Services >> Start Bonjour service.


   e) Now we should be able to ping or ssh to the raspberry pi from Windows machine. 

4. To use modify the username for raspberry pi simply use "hostname <new hostname>"

5. You can also simply ssh to the raspberry pi using its hostname. Dont forget to add .local after the hostname. See example below.



No comments:

Post a Comment