First, if you haven't already set up Samba, you'll need to follow the instructions here before you can move on to this section.
If you just went through our Samba section, you already have a nicely working Samba Server to share files with Windows and other clients. However, if you want to use multiple network interfaces and still be able to run a Samba Server, there are a few extra steps you'll need to take.
Why would I want to use multiple network interfaces in FreeBSD? There are plenty reasons. One which I (Kevin) am very familiar with is using one NIC (such as wi0) to connect to the Internet while at the same time connecting to another computer on a second network that does not have access to the Internet (using a second NIC such as ep0). There are plenty of reasons why you might want a set-up like that, such as connecting to the Internet only with *nix machines while having an offline Windows machine. (If it can't connect to the Internet, Windows can't get infected with as much spyware and viruses, right?)
Whatever your reasons, if your FreeBSD machine is on 2 networks simultaneously and you still want to be able to share files with a computer on one of those networks, let's get Samba working with those two networks.
vi /usr/local/etc/smb.conf
This is the Samba configuration file we created in our Samba section. Leave everything you already have in that file alone. We're simply going to add a few lines to the end:
#The following lines enable access to your Samba share while connected to multiple networks simultaneously
hosts allow = 192.168.1. 192.168.2.
interfaces = 192.168.1.131/24 192.168.2.131/24
Allow me to explain. The line "hosts allow" specifies which subnets the client computer needs to be on in order to have access to our Samba share. Let's say that my wi0 NIC has the IP address 192.168.1.131 and is connected to a router with the IP 192.168.1.1. All computers connected to this same router are on the 192.168.1 subnet. My ep0 NIC, on the other hand, has the IP address 192.168.2.131 and is on the 192.168.2 subnet.
The last line specifies which interfaces are used with Samba. In other words, it is the IP address of my wi0 NIC followed by the IP address of my ep0 NIC. Change according to your needs. NOTE the /24 added to the end of each IP address. If you leave this out, your clients will not be able to access the Samba Server, so don't forget to add this regardless of what your NIC IP addresses are.
Save your changes and exit. Then restart Samba.
/usr/local/etc/rc.d/samba.sh restart
There. Clients on either subnet should now be able to access your Samba Server.
Please note that there are a few caveats to using Samba with multiple NICs.
The first is that each NIC must be on a different subnet, i.e. wi0 and ep0 cannot both be on networks with the subnet 192.168.1. If they are, this won't work, and I'd imagine a number of other networking issues would arise as well. Change the IP address of one of your routers, or if you're simply using a network HUB for your offline network, manually change the IP address of each computer on the network to something on a different subnet, making sure each computer on the network is on the same subnet. (For example, give each computer a static IP address beginning with 192.168.2, such as 192.168.2.100 and 192.168.2.101, etc).
The second is that you cannot use the network name of the computer ("bsd" in the example given in our Samba section) in order to connect to a Samba Server using multiple NICs if you are using a *nix client (including FreeBSD, Linux, and Mac OS X). Rather, you must specify the actual IP address of the host computer, for example:
mount_smbfs //guest@192.168.2.131/share /mnt
Where 192.168.2.131 is the IP address used by our ep0 NIC, which is connected to the same network as our client computer. If the client computer is a Windows machine, you should be able to browse for it in Network Neighborhood or My Network Places as you normally would, but I've only tested this particular setup with a FreeBSD Samba Server and a Mac OS X client so I make no guarantees about that.
Lastly, if you disconnect your Samba Server machine from the multiple networks, limiting it to a single network (i.e. you ditch the ep0 NIC and use the wi0 exclusively), you MUST comment out the last 2 lines we added to /usr/local/etc/smb.conf or your Samba Server will not work properly. Those lines are only used if the computer is connected to multiple networks. If it is on a single network, you don't need those lines and should not use them. To comment them out, simply open the smb.conf file and enter a # or ; in front of the lines. After doing this, for example, the last 2 lines we added to smb.conf for this section should look like this:
;hosts allow = 192.168.1. 192.168.2.
;interfaces = 192.168.1.131/24 192.168.2.131/24
Restart your Samba Server and you should be able to share files with other computers on your single network.
/usr/local/etc/rc.d/samba.sh restart
If you connect this machine to multiple NICs again in the future, simply uncomment the last 2 lines in smb.conf and restart Samba.