Linux optimize

The Mac Connection: Networking Linux and Macintosh systems with Netatalk

Ever want to configure a Linux system so that it emulates the functions of an AppleTalk server? In this Daily Drill Down, Bryan Pfaffenberger shows you how to network Linux and Macintosh systems with Netatalk.

In this Daily Drill Down, you'll learn how to configure a Linux system so that it emulates the functions of an AppleTalk server (chiefly, making a user’s Linux directory available from a Macintosh and making Linux printers available to Macintosh users). If all goes well, this process can be quite easy—as easy, in fact, as installing the Netatalk+asun package and launching the server. Sometimes, admittedly, it doesn't go well, which is why you should read this Daily Drill Down.

Look before you leap department: Limitations of Netatalk
Before you leap into Netatalk, examine all of the drawbacks. As you'll learn in this Daily Drill Down, Netatalk isn't as capable as Samba, a fact that's partly attributable to the limitations of AppleTalk itself. What's more, Netatalk development is, at best, a sporadic process, the online documentation is out of date and downright misleading at times, and the licensing is sufficiently strange to keep Netatalk off of most Linux distribution disks.

Are you happy with a one-way ticket?
Netatalk enables Macintosh users to access shared directories and printers on the Linux server, but it doesn't work the other way—Linux users can't access directories or printers on the Mac systems. A package that formerly enabled Linux users to access Mac filesystems, afpfs, has been abandoned by its former developer and doesn't work with recent Linux kernels. The word is that someone has resumed development, but there's nothing out there yet that's safe to run.

Is Netatalk's one-way functionality such a bad thing? Not really. It just means that shared resources need to be stored on the Linux systems that are functioning as AppleTalk servers.

Forget the standard version
Netatalk developers haven't exactly made things easy for would-be users. The ostensibly standard version of the Netatalk package—the one developed by the University of Michigan—won't work with recent Linux kernels (2.2 and higher) or Mac OS 8.0 or higher without a set of patches (called asun) authored by Adrian Sun. But the official home page doesn't explain this, despite the fact that Linux users of Netatalk have pleaded with the authors to do so. Lots of people have wasted their time compiling the standard version, only to find that it just won't work.

The moral of the story: Make sure you get the Netatalk+asun source or binary packages. For the details, see “Downloading Netatalk+asun,” later in this Daily Drill Down. Whatever you do, don't try to run the Michigan version of Netatalk, even if someone tells you it's “official.”

Make sure you're comfortable with the licenses
Be aware that Netatalk isn't distributed under the GPL. Netatalk is copyrighted by the Regents of the University of Michigan, but permission is granted to use, copy, modify, or distribute the software and its documentation for any purpose, as long as the copyright notice is reproduced in all copies. The Netatalk package contains some Solaris code, which is distributed under a similar Sun license. Adrian Sun's patches are licensed in much the same way.

Upgrade your Macs
Judging from agonized pleas for help on the Netatalk mailing list, Netatalk+asun doesn't play very well with older versions of the Mac OS. You'll be well advised to make sure that all of your Mac boxes are running version 8.1, at least.

Introducing AppleTalk
AppleTalk is Apple Computer's proprietary protocol suite for peer-to-peer networking. A middle-level networking protocol, AppleTalk is designed to run on top of more basic networking protocols and physical media, including Ethernets, FDDI (fiber-optic) networks, token-ring networks, and Apple's proprietary, low-speed LocalTalk networks. On an Ethernet, AppleTalk lives peacefully with other middle-level protocols, including TCP/IP and SMB, the Windows networking protocol that's supported by Samba.

The AppleTalk protocol suite contains the following protocols:
  • Datagram Delivery Protocol (DDP): This protocol governs the “wrapping” of AppleTalk data into packets for network transmission. The protocol is natively supported by the Linux kernel, but you'll need to make sure this support is enabled (see the section “Configuring your system for Macintosh networking”).
  • Routing Table Maintenance Protocol (RTMP): This protocol defines the way AppleTalk propagates routing tables so that all networked machines know where the other machines are located.
  • Name Binding Protocol (NBP): This protocol specifies host name resolution within AppleTalk networks.
  • Zone Information Protocol (ZIP): This protocol supports separate AppleTalk zones, or virtual subnetworks, within an AppleTalk network. The zones show up in the Chooser, a Macintosh utility used to connect to the network.
  • AppleTalk Echo Protocol (AEP): This protocol enables a network service similar to Ping. It is supported by the aecho utility, which is part of the Netatalk package.
  • AppleTalk Transaction Protocol (ATP): This protocol defines AppleTalk services that require reliable exchanges of data between the client and server.
  • Printer Access Protocol (PAP): This protocol provides access to network printers.
  • AppleTalk Session Protocol (ASP): This protocol defines the means to open, maintain, and close transactions during a session.
  • AppleTalk Filing Protocol (AFP): Designed to run on top of ASP, this protocol enables Macintosh users to access data files on a shared server.

As you'll see in the next section, the Linux kernel and Netatalk implement all of the above protocols, enabling your Linux system to function as an AppleTalk server.

Introducing Netatalk
Netatalk+asun consists of a number of separate daemons and utilities. Here are the most important of these:
  • atalkd: This daemon implements RTMP, NBP, ZIP, and AEP. NBP, ATP, and ASP are implemented as libraries.
  • papd: This daemon implements PAP.
  • psf: This utility is a PostScript printer filter for lpd, which enables lpd to work with PAP.
  • afpd: This daemon implements the Apple Filing Protocol so that Mac users can access files on UNIX and Linux systems.

Configuring your system for Macintosh networking
To integrate Macs into your Linux network, the Netatalk server needs the following:
  • Kernel 2.2 or later: Earlier versions of the kernel won't work with the Netatalk+asun package.
  • AppleTalk DDP support: Most Linux distributions enable DDP by default. Still, you should make sure that this support is enabled in the kernel configuration you're using. To find out, open a terminal window, switch to /usr/src/linux, type make xmenuconfig, and press [Enter]. In the Linux Kernel Configuration dialog box, click Networking Options, and make sure AppleTalk DDP is enabled as a module (M). If this option isn't enabled, select M and follow the on-screen instructions to recompile the modules on your system.
  • User directories: Create usernames and home directories for each of the Macintosh users who will be given access to file storage space on the server. To create a shared storage space, create a group named mac, and give this group ownership of a directory named/home/public.

Downloading Netatalk+asun
You'll find the latest versions of Netatalk+asun at the following locations:

I strongly recommend that you try the RPM package. It should run on most Linux distributions, and it makes all the necessary system modifications without requiring custom configuration on your part. This Daily Drill Down doesn't cover the configuration you'll need to do if you install Netatalk from the source code; for more information, see the Netatalk How-to.

Configuring Netatalk
One of the coolest things about Netatalk is that you don't have to do any configuration to get it running. Although the program uses a variety of configuration files, you can almost always launch the server and get immediate results without making any modifications to these files. An exception is network printer configuration, which is beyond the scope of this article. (See Printing through a LaserWriter AppleTalk printer.)

Here's a quick overview of the configuration files. If you've installed Netatalk+asun from the RPM version, you'll find them in /etc/atalk. If you installed Netatalk from source, you'll find them in /usr/local/atalk.
  • config: Available only in the RPM version of Netatalk+asun, this file specifies basic Netatalk settings, including the maximum number of clients (5 by default), the name of the AppleTalk server (by default, the server’s hos tname), the daemons that are run by default (papd and afpd), and the execution mode (background execution is enabled by default). You don't need to make any changes to this file. The settings in this file are read by the atalk script, which is installed in /etc/rc.d/init.d.
  • atalkd.conf: This file defines the AppleTalk interface for the Linux system that's functioning as a Linux server. With most systems, you can simply leave this file blank, since Netatalk will automatically detect the network interface and configure itself accordingly.
  • afpd.conf: This file configures the AppleTalk Filing Protocol daemon. Again, you can leave this file blank. It's needed only if you'd like to define more than one server on your system.
  • papd.conf: This file enables you to make local and network printers available to Macintosh users. According to the Netatalk documentation, a blank file makes your Linux system's default printer, as configured in /etc/printcap), available to Macintosh uses—but don't believe it. To make your Linux printers accessible to Macintosh users through the Chooser, you'll have to configure papd.conf, place a printer identification file (.paprc) in your default printer spool folder (such as /var/spool/lpd/lp), and install an Adobe printer description file that describes your printer's characteristics. Some printer descriptions files are available from Adobe. For more information, see Printing through a LaserWriter AppleTalk printer and How to set up the printer using AppleTalk.
  • AppleVolumes.default: This file specifies the directories that are mounted when a user logs in. By default, the file contains just one non-commented-out character, a tilde (~), which displays the user's home directory. To make other directories available, type the pathname on a line by itself and save the file.
  • AppleVolumes.system: This file contains a database that maps file types to their Macintosh equivalents. You needn't make changes to this file.

Launching the server
To start Netatalk+asun as it's installed from the RPM version, switch to superuser, if necessary, type the following, and press [Enter]:
/etc/rc.d/init.d/atalk start

You should see this message:
Starting AppleTalk services: (backgrounded)

It's as simple as that! If you see an error message, make sure that AppleTalk DDP support is enabled by means of the Appletalk module. Type /sbin/modprobe appletalk to load the module, if necessary. Try starting Netatalk again.

Connecting to the server with the Chooser
Ready to connect? Sit down in front of one the Macs on your network. Click the Apple menu icon and select Chooser. In the Chooser dialog box, click AppleShare. You should see the host name of the Linux system on which you installed Netatalk; however, you'll want to connect via TCP/IP, which gives superior performance. Click Server IP Address, type the server's IP address in the dialog box, and click OK. You'll be prompted to type the user's name and password. Do so, and then click OK. You'll next have an opportunity to specify whether the system will log on to the server automatically the next time the Mac is started. Choose the options you want and click OK.

Once the connection is established, you'll see a network icon on the Mac’s desktop. If you double-click this icon, the Mac will open a standard Finder window, showing the files in the user's Linux directory. This directory can be used as if it were an ordinary directory on the Mac's own hard disk.

Enabling transparent file sharing between Mac and Windows systems
One of Netatalk's niftiest features is its ability to enable transparent file sharing between Mac and Windows systems, a feat that can otherwise be accomplished only by means of pricey commercial software. To pull off this trick, give your Mac user a directory on the Netatalk server, and then use Samba to make this directory accessible to Windows users. By using the Netatalk directory as a common meeting place, Windows and Mac users can exchange files in both directions.

Netatalk horizons
Netatalk appears to be under continuing development, judging from the fact that the Netatalk mailing lists continue to remain active. Still, Netatalk development is, at best, a sporadic affair, a fact that's illustrated by AppleTalk Configurator, a GTK+ utility that enables Netatalk administrators to configure Netatalk in a GUI-based environment. According to the developer’s home page, AppleTalk Configurator is no longer under active development, even though the current version doesn't implement the one thing Netatalk users desperately need: a user-friendly way to configure papd so that Mac users can access Linux printers. Still, abandoned projects seem to get picked up by new converts to the cause.
Still looking for more information? Below you’ll find a small listing of some of the more helpful Netatalk resources.Neon Software: Understanding AppleTalk routingNetatalk Administrators Mailing ListResearch Systems UNIX Group, University of Michigan—Netatalk: The Apple Protocol Suite for UNIX Note: The version of Netatalk available from this site will not compile or run on Linux kernel versions 2.2 and later.Research Systems UNIX Group, University of Michigan: Netatalk FAQThe authors and editors have taken care in preparation of the content contained herein but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.