5

I just set up a new AirPort Extreme and CentOS 6.2 server - the server is meant to be a general-purpose storage machine, and so I've set up Samba and Avahi on it. I can easily access the server by IP address from my MacBook Pro running OS X Lion, but attempting to resolve it by name - from the terminal with ping, in a connect prompt (smb://my-server/) - doesn't work.

Are there any particular configuration steps I need to take? How can I get access by name to the server from OS X?

Tim
  • 151
  • 1
    Tim, I suggest that you flag your question and ask a mod to move it to either Unix & Linux StackExchange, or Server Fault. This question is predominately how do I configure avahi to automatically announce my server's hostname. It's not actually a question about Apple Hardware or Software.

    OS X automatically broadcasts the computer name and associated address for link-local resolution and browsing, Avahi does (last I knew) only on a service-by-service basis. The details of which, however, are quite a bit over my head.

    – VxJasonxV Dec 27 '11 at 12:31

2 Answers2

6

Support has been available for mDNS and related discovery services on most Linux distros for sometime. Static IPs or fixed hostnames are not scalable for cloud/rapid deployment/Vagrant. Ideally, there is some good hackery in the cloud init tools and also possibly generating a unique hostname based on a string template on first boot (along with reseal scripts).

Anyhow, here's the easy way to get mDNS working for most major OSes.

On CentOS/RHEL/Fedora:

su - -c 'yum install -y avahi avahi-tools nss-mdns ;
service avahi-daemon start'

On Debian/Ubuntu: http://wiki.debian.org/ZeroConf

sudo su - -c 'apt-get install -y avahi-daemon avahi-discover nss-mdns ;
sudo invoke-rc.d avahi-daemon start'

On Arch: https://wiki.archlinux.org/index.php/Avahi

echo 'You won't need hand-holding here I assume.'

All:

What's nice is this gets mDNS working on the Linux box the other way too, so you can usually just start pinging/ssh/etc to your Mac right way. Woot. avahi-browse --all is very neat.

Don't forget the inbound firewall rule on the box acting as a server.

-A INPUT -d 224.0.0.251/32 -p udp -m udp --dport 5353 -m comment --comment "mDNS" -j ACCEPT

Also, configure with /etc/avahi/ and restart the daemon.

Incidentially, I am building a CentOS 6.2 x86_64 minimal appliance for a client on my MacBook Pro under VMware Fusion 4.x.

Perhaps someone will add the bit for making sure that the announcement work and publishing of services (esp. ssh and web urls) works correctly for Mac, Linux and even Windows clients.

Mat
  • 52,586
Barry A.
  • 1,311
  • I'm using CentOS, and have avahi-daemon (as well as avai-dnsconfd) started, but no dice: the MacBook still can't resolve the server by name. Is there additional broadcasting I can do server-side to get that working? – Tim Dec 29 '11 at 06:36
  • Perfect... I basically just needed to install avahi-tools on my CentOS VM on Mac OSX, and then I could use avahi-set-host-name to set a hostname and get into my VM! – Aditya M P Apr 28 '15 at 06:32
1

I'll take a stab at this from the Apple side of things. Jason's comment is very true - in a nutshell the question is more about how to work with Apple software coming from an OS that isn't at all common to the Mac OS.

On the Apple side, your mac needs no configuration whatsoever to see any server that is broadcasting SMB so in addition to turning on the SMB daemons, make sure no firewall is blocking those broadcast packets and ensure both computers are on the same network segment so that broadcast packets are moving back and forth. You can see the list of bonjour services, which also might help you if you want to grab the source, browse the documentation and compile bonjour for your CentOS server.

Again, the mac needs nothing other than to be connected to a network where your server advertises (sends) packets to announce it will share either SMB or bonjour services.

Another tack would be to run DNS on the CentOS server and have your mac's get it's DNS records and it should be able to resolve the server name whether or not the server is actively sharing.

Lastly, static IP addresses would also work and you could simply pop your CentOS server's address in /private/etc/hosts (there's a sym link of /etc that points to /private on the Mac OS.)

bmike
  • 302