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.
In the Safari preference panel select the advanced tab. Check the setting you want.
Avahi is a Linux daemon for Zeroconf. It is incredibly easy to setup and you don't have to reboot your server.
Use your distros package manager to install it. For
sudo yum install -y avahi.
Then create a file in the
/etc/avahi/servicesdirectory with a
<?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>
- 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.
Toa of Mac has some great tips on how to configure a setup with 2 NICs and only broadcast on the private network.