Sharing a Samba File and Print Server Across Subnets, Part 1 - page 2
The Subnet Myth
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:
# mv /etc/samba/smb.conf /etc/samba/smb.conf-old
Then create a fresh new one using this example configuration:
[global] workgroup = group1 netbios name = xena server string = anonymous file server security = share printing = cups printcap name = cups load printers = yes [common_share] path = /sharedfiles comment = anonymous share for all users public = yes writeable = yes browseable = yes [printers] comment = All Printers browseable = yes path = /var/spool/samba printable = yes public = yes writable = no create mode = 0700
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:
Domain=[GROUP1] OS=[Unix] Server=[Samba 3.0.26a]
Sharename Type Comment
--------- ---- -------
common_share Disk anonymous share for all users
IPC$ IPC IPC Service (anonymous file server)
tp0 Printer Canon_PIXMA_iP4200
HP_LaserJet_3050 Printer HP_LaserJet_3050
Domain=[GROUP1] OS=[Unix] Server=[Samba 3.0.26a]
Server Comment
--------- -------
XENA anonymous file server
Workgroup Master
--------- -------
GROUP1
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.
Resources
- Join Samba 3 to Your Active Directory Domain
- Samba Network Browsing
- man smb.conf--don't leave home without it
Carla Schroder is the author of the Linux Cookbook and the newly-released Linux Networking Cookbook, and is a regular contributor to LinuxPlanet. Both books have extensive Samba chapters.
- Skip Ahead
- 1. The Subnet Myth
- 2. The Subnet Myth
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.