I create a lot of linux based VMs on my Mac. Sometimes its a bit hard to keep track of which machines have port forwarding or what their IPs are. I found a great solution to the problem: Bonjour. This is the Zeroconf implementation for Macs. It allows a machine to broadcast what services it has. For web development you can use it to broadcast the web server that your working on. Safari on the Mac automatically includes the current services in the bookmarks menu for easy access.

Mac Setup

In the Safari preference panel select the advanced tab. Check the setting you want.

Safari preference panel

Linux Setup

Avahi is a Linux daemon for Zeroconf. It is incredibly easy to setup and you don’t have to reboot your server.

  1. Use your distros package manager to install it. For yum it is sudo yum install -y avahi.

  2. Then create a file in the /etc/avahi/services directory with a .service extension.

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_http._tcp</type>
    <port>3000</port>
  </service>
</service-group>
  1. You might need to restart Avahi. It normally picks up the changes as soon as you write the file. To restart it manually run sudo /etc/init.d/avahi-daemon restart.

Getting fancy

Toa of Mac has some great tips on how to configure a setup with 2 NICs and only broadcast on the private network.