Avahi
Avahi
Avahi is a Linux service for providing multicast-DNS/DNS-SD (also known as Bonjour or mDNS/DNS-SD). Avahi allows for simple service discovery and advertisement on a local network and provides name resolution for all hosts running a mDNS/DNS-SD service.
Using Avahi allows for easy SSH access over a local wireless network. Once installed and started, users can ssh to their device using their mDNS assigned hostname.
Avahi Installation
First, mount the root filesystem as writable and install the Avahi ipkg.
$> sudo mount -o remount,rw / $> sudo /opt/bin/ipkg-opt install avahi
Avahi currently attempts to access a different dbus system socket than the one provided by the Pre's dbus, so we need to turn off dbus access for the time being. Edit /opt/etc/avahi/avahi-daemon.conf and make the following change:
Replace this line: #enable-dbus=yes With this line: enable-dbus=no
Avahi seems to want to run as a user named "avahi". To create the user, run the following command:
$> adduser -h /opt/var/run/avahi avahi
At this point, the Avahi daemon can be started with the following command:
$> sudo /opt/sbin/avahi-daemon -D
If you would like Avahi to start up at boot, create the following two files:
/opt/etc/init.d/S60avahi
#!/bin/sh [ -e /opt/etc/default/avahi ] && . /opt/etc/default/avahi if [ "$AVAHI_ENABLE" = "no" ]; then exit fi if [ -n "`pidof /opt/sbin/avahi-daemon`" ]; then killall /opt/sbin/avahi 2>/dev/null fi /opt/sbin/avahi-daemon -D
/opt/etc/default/avahi
AVAHI_ENABLE=yes
Make sure you set the startup script to executable:
$> sudo chmod 755 /opt/etc/init.d/S60avahi
Alternatively, you can create an upstart script at /etc/event.d/avahi:
start on started PmConnectionManager console output exec /opt/sbin/avahi-daemon -D respawn
NOTE: This script is not being stored in the /opt directory. You may have to replace it after an update, and it may cause problems with your Pre.
Connecting via SSH using mDNS
mDNS uses the system's hostname and appends it to the local. domain. Using the Pre's default castle hostname, the following command would be used to SSH to your Pre on port 222:
$> ssh -P 222 castle.local.
Note: The system that you are connecting from MUST have a mDNS service also running, else the hostname will not resolve
Current Issues
- The ipkg binary of Avahi attempts to find the dbus socket at /opt/var/run/dbus/system_bus_socket, but the Pre's dbus socket is at /var/run/dbus/system_bus_socket. I haven't investigated tying these two together too much, but the expanded functionality of accessing mDNS via dbus is preferred.
- The avahi-daemon seems to have issues keeping the mDNS name resolution running for more than a few minutes. I don't know if this is a power management issue or something else at this point.