How To Set Up a Home Network With Ubuntu, Part 2

October 11, 2008 by
Filed under: HowTo, linux, Ubuntu 

In Part 1 I showed how to set up your home network with static IP addresses. In Part 2 I'm going to show how to share folders across the network. There's a lot of information on the net for setting up Samba (which works with Windows SMB) to share files. That's fine if you need to share files and folders with Windows computers, but in a pure Linux environment NFS (Network File System) works just as well or better. Some reports on the web claim it to be 3-4 times faster than Samba for file transfers. In today's post, I'll show how to install and configure NFS in order to share folders across your home Linux network.

I'll show how to configure the server first. We'll need to make sure all of the required packages are installed. From the terminal:

sudo apt-get install nfs-kernel-server nfs-common portmap

Next, make sure that portmap is not bound to loopback.

sudo dpkg-reconfigure portmap

Now we'll configure a folder to share. There are two ways (that I know of) to do this; through the file manager, or by editing /etc/exports. I'll show the first way. Open Nautilus, (the Ubuntu file manager), and right click on the folder you want to share, (for this example, /home/username/Music), and select Share from the menu. Enter your password if prompted, and then the Share Folder dialog should come up. Modify the Share through: drop-down from Do not share to Unix networks (NFS).

Affiliate Link

Now we just need to add access to the other computers on our network. From the block diagram in Part 1, our network addresses are of the form 192.168.2.10, 192.168.2.11, etc.

Home Network Block Diagram

Home Network Block Diagram

Under the Allowed Hosts section, click on Add. In the new dialog, leave the Allowed Hosts: drop-down on Specify hostname. Now, in the Host name: field enter

192.168.2.1/24

and click OK. This will allow clients in the address range of 192.168.2.1 - 192.168.2.255 to connect to the shared folder. Now click OK in the Shared Folder dialog. In order for the NFS kernel server to read these new share settings we'll need to restart it.

sudo /etc/init.d/nfs-kernel-server restart

and then export the share.

sudo exportfs -a

Note: If you are running a software firewall, you'll need to make sure you open ports 111 and 2049 for the NFS service.

Now we need to set up the other computers on our network to connect to the shared folder as clients. Log in to one of the other computers and install the nfs-common and portmap packages.

sudo apt-get install nfs-common portmap

Again, make sure that portmap is not bound to loopback.

sudo dpkg-reconfigure portmap

Now create a directory for your local mount point of the shared folder.

cd ~
mkdir media

Just to be sure, restart portmap and nfs-common.

sudo /etc/init.d/portmap restart
sudo /etc/init.d/nfs-common restart

Finally, mount the remote shared folder to the new directory you just created.

sudo mount 192.168.2.10:/home/username/Music /home/username/media

You should now be able to browse the media folder and see the contents of your remote Music folder. Repeat the process for the remaining computers on your network.

In Part 3 I will cover how to automatically mount the shared folders when you boot the computer.

Comments

5 Responses to “How To Set Up a Home Network With Ubuntu, Part 2”

  1. Anonymous says:

    Thanks a lot :)

  2. Linerd says:

    OK, it looks like this functionality has been removed from Nautilus since Hardy (8.04) from what I see on the Ubuntu Forums. The tool is still available, just not through Nautilus.

    To open the tool:
    Alt+F2
    Enter the command: shares-admin and click Run. Now click Unlock and enter your password at the prompt. Now you can create a new share.

    Click Add. Select the Path drop-down and select Other..., navigate to and double click the folder you want to share and click Open. Make sure Share through: is set to Unix networks (NFS).

    Click Add in the Allowed Hosts section.

    Leave the Allowed Hosts: drop-down on Specify hostname. Now, in the Host name: field enter
    192.168.2.1/24
    and click OK. Now click on Share back in the Share Folder window. And finally, click Close in the Shared Folders window.

    Now you can pick back up with the instructions at the point where is says:
    sudo /etc/init.d/nfs-kernel-server restart

    As you can see from my previous comment, it's a lot quicker just to make the manual change to the /etc/exports file.

    Thanks for pointing out the problem.

  3. Linerd says:

    It looks like something has changed in Nautilus since I did this. You can still do this the manual way. You need to edit /etc/exports.

    sudo gedit /etc/exports

    Then add a line like:
    /home/username/Music 192.168.2.1/24(rw)

    and then save the file.

    Now continue on the HowTo where it says
    sudo /etc/init.d/nfs-kernel-server restart

  4. Aubrey says:

    About this paragraph in your tutorial...

    "Open Nautilus, (the Ubuntu file manager), and right click on the folder you want to share, (for this example, /home/username/Music), and select Share from the menu. Enter your password if prompted, and then the Share Folder dialog should come up. Modify the Share through: drop-down from Do not share to Unix networks (NFS)."

    I right click the Public folder that I want to share, but I do not see the "Share" in the menu. What I see related are "Sharing Options" and "Properties" and none of them gives me the Share Folder dialog.

    Should I reboot after installing NFS?

    I am running Ubuntu 8.10 - latest version by now Jan 7, 2009.

  5. Anonymous says:

    thank you :)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>