Sunday, August 19, 2007

Avahi announcing services on behalf of other machines.

The coolest feature of Avahi is to announce services to Bonjour/Rendezvous clients both Mac and Windows with the Bonjour IE plugin when they dont actually have an mDNSresponder on them. I am using my linux box(FC5) to announce a bunch of my intranet web pages so I dont have to remember all the links.

I am announcing my two webcams, Wireless router, printserver, network switch, Apache on my linux box, Cacti network monitoring on my linux box and my router. The cool thing is it will even let you do links.

For example.
Router = http://router or http://192.168.1.1
(I am using static hostnames in /etc/hosts on OSX and Linux and the windows hosts file)

Cacti = http://firefly/cacti
(cacti after the hostname being the path)


You need to do two things assuming you have Avahi up and running which I am not going to cover here...but contact me if you need help with that. You need to create .service files and you need to create hosts files.

First well create the hosts file that is located in /etc/avahi: vi /etc/avahi/hosts

paste in your IP to Name conversions noting that any service on the localhost does not need to be in this file. Mine happen to be as follows:
192.168.1.1 router.local
192.168.1.3 printserver.local
192.168.1.5 switch.local
192.168.1.6 wlan.local


Now create the .service files. You can search google for any service type as they are almost all defined already.

>create a service file: touch wlan.service

paste the following into the wlan.service file.


<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name>WLAN Web Server</name>
<service>
<type>_http.\_tcp</type>

<host-name>wlan.local</host-name>

<port>80</port>
</service>
</service-group>




If you wanted to create one with a patch such as the cacti example above simply add a txt-record tag.

>create a service file: touch cacti.service

paste the following into the cacti.service file.


<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name>Cacti Web Interface</name>
<service>
<type>_http.\_tcp</type>

<port>80</port>

<txt-record>path=/cacti</txt-record>

</service>
</service-group>


Save the file and restart Avahi: service avahi-daemon restart



Once Avahi is restarted you can check the log file to make sure the services are announcing successfully. You can even use avahi-browse -a to see if the services are all announcing. Then just open your Bonjour window and they should all show up.

No comments: