Sharing a Samba File and Print Server Across Subnets, Part 1 - page 2

The Subnet Myth

January 10, 2008

By
Carla Schroder

You don't need to put Samba on a dedicated server. If you're running a small, low-demand network, you can piggyback Samba onto any PC or server that has enough disk space. However, don't pinch pennies on a larger, busy network. Samba doesn't need a lot of horsepower, so it won't cost much to set up a dedicated fileserver. This is a great way to keep older Pentium-class PCs in service and out of landfills.

Most Linux distributions split Samba into several packages, so make sure you get the server package, smbclient, and the documentation. After installation, create a world-readable and -writable directory (mode 0777) to store your shared files:

# mkdir -m 0777 /sharedfiles

Copy some files into your shared directory for testing. Make sure that any subdirectories are also world-readable and writable. File permissions don't matter. Now copy your default /etc/samba/smb.conf file for a backup and reference:

You can copy this exactly, with three exceptions. Use your own workgroup name; your Windows clients must belong to this workgroup, but Linux doesn't care. Use your own choice of a shared directory, and whatever you want for a netbios name. This can be anything at all; this is what shows up in Network Neighborhood on Windows.

Then check for syntax errors with the testparm command:

$ testparm

Any errors must be fixed. Once you get a clean run, start or restart Samba. The command for this varies, so check your /etc/init.d directory for the correct start and restart commands. On Debian, for example, it's /etc/init.d/samba {start|stop|reload|restart|force-reload}.

Now check the status of your Samba server with both smbstatus and smbclient:

$ smbstatus
$ smbclient -NL xena

You have to pass the server's hostname to smbclient. -N means don't ask for a password, and -L means list all shares, like this example:

smbclient finds your Samba shares faster than any other command. It takes Samba some time to broadcast its shares to the network, so smbclient will see them long before Network Neighborhood or any Linux network browser. Another useful command is smbtree -N; this is a text SMB browser that finds whatever Samba shares you have permission to access on your network. When smbtree sees your shares, that means that Samba has finally broadcast itself to your network.

At this point you should have a working public, anonymous share that your users can read and write to, both Linux and Windows. Come back next week to learn how to break free of your local subnet and share it across multiple subnets.