Friday, 22 November 2013

Avahi Auto-Configuration 0.1 Release

For my 0.1 release I will be aggregating the work I have completed thus far. This release is contains commands to run to have Avahi behave as I believe it should on a Raspberry Pi.

1. Install nss-mdns using yum install nss-mdnsAvahi should already be installed on your Pi so this is not necessary.

2. Change your hostname in /etc/hostname (on Pidora 18 Linux). NOTE: Changing your domain name here will not affect Avahi, it will still append ".local" to your hostname.

3. Open your iptables firewall to UDP packets from Avahi with iptables -I INPUT -p udp --dport 5353 -j ACCEPT. For additional security, you can modify this rule to allow traffic destined only to your Pi from your private network. For example, iptables -I INPUT -p udp --dport 5353 -s -d -j ACCEPT where the subnet represents your private network and represents the address of your Raspberry Pi. The corresponding OUTPUT rule is iptables -I OUTPUT -p udp --sport 5353 -j ACCEPT or iptables -I OUPUT -p udp --sport 5353 -s -d -j ACCEPT. NOTE: By default the iptables on a default Pidora 18 install are open and should allow this traffic through by default.

4. If you wish to enable Avahi to start at boot time, enter these commands:
rm -rf /etc/systemd/system/avahi-daemon.s*
systemctl enable avahi-daemon.service
systemctl start avahi-daemon.service

5. If you wish to customize the TXT records that will display alongside the advertised SSH service on the Raspberry Pi you can enter these commands and insert whatever text you wish to inside the txt-record tags.
sed -e '/<type>_ssh._tcp<\/type>/a \     <txt-record>Username=Blank<\/txt-record>\n     <txt-record>Password=Blank<\/txt-record>' /etc/avahi/services/ssh.service > /etc/avahi/services/ssh.service.tmp && mv -f /etc/avahi/services/ssh.service.tmp /etc/avahi/services/ssh.service


sed -e '/<type>_udisks-ssh._tcp<\/type>/a \     <txt-record>Username=Blank<\/txt-record>\n     <txt-record>Password=Blank<\/txt-record>' /etc/avahi/services/udisks.service > /etc/avahi/services/udisks.service.tmp && mv -f /etc/avahi/services/udisks.service.tmp /etc/avahi/services/udisks.service

The next phase of my project will be auto-configuring several common services such as httpd and vsftpd. I will also package these commands into an rpm to be installed.


Post a Comment