BSD DevCenter
oreilly.comSafari Books Online.Conferences.

advertisement


FreeBSD Basics

Accessing Microsoft Files Using Sharity-Light

07/12/2000

Experiments in SMB

Windows still got you trapped? Maybe SAMBA File System support is what you need. Michael Lucas explains how to use SMBFS.

It is possible to access data on a Microsoft computer from your FreeBSD system if the two computers are networked together. In this article, we'll be using a utility called Sharity-Light to allow a computer running Windows NT 4 to export a shared directory to another computer running FreeBSD.

But first, a crash course in NT networking. Microsoft operating systems use the NetBIOS API to facilitate file sharing over the network. The NetBIOS API uses a computer's NetBIOS (or computer) name to find networked resources. A hidden component of this NetBIOS name is a hex number that represents the type of resources and services the computer has made available to other computers on the network.

When a user on an NT computer wishes to access data on another computer, he can issue an UNC (universal naming convention) from the run command. All UNCs have the same syntax:

\\netbiosname\sharename

The \\ tells the NT operating system that the required resource does not exist on this computer; instead, NT needs to go out on the network segment.

The name of the computer the resource lives on is netbiosname.

The name of the shared resource the user wishes to access is sharename.

So, the command:

\\pdc\stuff

tells NT to go out on the network, find a computer named pdc, and look for a shared directory named stuff on that computer.

However, the UNC will fail unless the user at pdc has created a directory called stuff and has shared it. In NetBIOS, only directories can be shared; in order to share files, they must be copied into a shared directory. To share a directory on an NT computer, right-click the Start menu, and click on "Explore." Highlight a directory, right-click, and choose "Properties." Click on the "Sharing" tab and change the default of "Not Shared" to "Shared As."

By default, the Share Name will be the same as the directory name; you can change this if you wish. You can also use the Permissions button to specify which users can access this share. Note, this only affects network users, not users sitting at this computer.

FreeBSD does not use NetBIOS to manage networked resources. Instead it uses NFS, the Network File System. We need a translator to convert NFS requests into the SMB (server message block) requests that NetBIOS understands. If I want Microsoft machines to access data on my FreeBSD computer, I use a utility called Samba to provide the necessary translation. If I want my FreeBSD machine to access data on a Microsoft computer, I use the Sharity-Light utility.

If you installed the ports collection when you installed FreeBSD, and are currently connected to the Internet, issue the following commands (as root) to install Sharity-Light:

cd /usr/ports/net/sharity-light
make
make install

If you didn't install the ports collection, build the package instead. Again, as root, and while connected to the Internet:

mkdir /usr/packages
lynx www.freebsd.org/ports

Cursor down to "net" and press Enter, then cursor down to the package link for sharity light and press Enter, then press d to download. Save the downloaded file in /usr/packages and exit lynx.

As root:

cd /usr/packages
pkg_add shar*

Notice that I'm a lazy typist. I just gave pkg_add enough information to distinguish the package I wished to install; I let the wildcard character * represent the rest of the filename.

Before we can use Sharity-Light, we need to know the NetBIOS name of the NT computer we wish to access, and the name of the share containing the data we need. To determine the NetBIOS name of an NT computer, right-click on that computer's Network Neighborhood icon and click on "Properties." The name in the box next to "Computer Name" is the NetBIOS name. To quickly see which resources that machine has shared, doubleclick on Network Neighborhood, then doubleclick on the NetBIOS name of the computer to see all of its shares.

We will also require a mountpoint for the data. Let's use a mountpoint of /nt_1:

mkdir /nt_1

Lastly, FreeBSD does not use NetBIOS names; it uses host names. If your network does not have a DNS server or a WINS server, you'll need to add an entry for the NT computer in the /etc/hosts file on your FreeBSD computer.

Let's pretend I have an NT computer named alpha with an IP address of 10.0.0.1 and a shared directory named files. My FreeBSD computer is named gamma with an IP address of 10.0.0.3. On gamma, I'll add the following line to /etc/hosts:

10.0.0.1	alpha

Then, I'll test connectivity by pinging alpha's IP address:

ping 10.0.0.1
PING 10.0.0.1 (10.0.0.1): 56 data bytes
64 bytes from 10.0.0.1: icmp_seq=0 ttl=128 time=1.061 ms
64 bytes from 10.0.0.1: icmp_seq=0 ttl=128 time=0.578 ms
64 bytes from 10.0.0.1: icmp_seq=0 ttl=128 time=0.591 ms
64 bytes from 10.0.0.1: icmp_seq=0 ttl=128 time=0.597 ms
^C
---10.0.0.1 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.578/0.707/1.061/0.205 ms

Note that ping will ping forever until you terminate it with Ctrl-C. If you don't get a response, check the cabling between the two computers before trying your ping again.

Having verified connectivity, let's ensure our hosts file is working:

ping alpha

You should get the same ping results as above; if not, double-check the NetBIOS name, look for typos in the /etc/hosts file, and try again.

Pages: 1, 2

Next Pagearrow





Sponsored by: