This tutorial is to setup a home server with ubuntu 10.04 LTS.

After many hours trawling through different tutorials and manuals (many old and out of date) I thought someone else might be in the same boat as me, so I wrote everything down and thought I’d post here for anyone who might wont it. I hope it helps.

My main aim was to get the internet to pass through the server and to share some media files over the network. Having the internet pass through the server has a few advantages as well as drawbacks. The use of nat and having a good firewall and filtering can give you a bit better security and control but there are some down sides like needing the computer on all the time and a little bit more hardware in another NIC (Network Interface Card). There are many more arguments both for and against so I wont try to sell you ether way this is just how I like it.

The basic things your server will need for this tutorial
  • Freshly installed ubuntu 10.04 LTS 64-bit (I don’t think anything will be different for the 32-bit version but I used 64-bit.)
  • 2x NIC (Ethernet ports)
  • Separate hard drive (2TB) for media files (this isn’t mandatory, you can use any folder one your computer instead.)

Eth0 will be the Internet connection and eth1 will be the connection to the network switch.

Internet connection sharring
We need to set the IP address for the network port (eth1) so open Terminal and type:
sudo sbin/ifconfig eth1 netmask broadcast
(enter password when asked, sudo will be used in almost every comand you can skip it by first typing “sudo su” and entering your pass word, this will sign you in as root so you don’t have to put sudo before every command (to sign out of root type “exit”). I don’t mind hiting the 5 extra keys so I leave them in)

eth0 will be left as DHCP dependant (you internet router will give it an IP address)

Then we need to flush the rules in filters and NAT tables.
sudo iptables --flush
sudo iptables --table nat --flush
And delete all chains that are not in default filter or NAT table.
sudo iptables --delete chain
sudo iptables --table nat --delete-chain

Now to setup the IP forwarding and masquerading.
(you can find out more about these commands by typeing "man iptables" in terminal.(Press "q" to quit))
sudo iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
sudo iptables --appent FORWARD --in-interface eth1 -j ACCEPT

Enable packet forwarding by editing sysctl.conf

sudo nano /etc/sysctl.conf
and un-comment (remove #)
(To exit nano press Ctrl + x and select yes to save file then yes again to replace existing file, you will need to do this every time we finish using nano)

That has set it up temporary so to save a copy of the setup just type
sudo iptables-save | sudo tee /etc/
Then we edit rc.local to load at start-up
sudo nano /etc/rc.local
add the following line at the bottom before “exit 0”
 iptables-restore < /etc/

Setup DHCP server
Install dhcp server
sudo apt-get install dhcp3-server
Dont panic. It will try to start and fail because we have not set it up yet.

To start we need to set dhcp to work on port eth1
sudo nano /etc/default/dhcp3-server
Change INTERFACES=”” to

Set routing
sudo nano /etc/network/interfaces
add the following
auto eth1
    iface eth1 inet static

up route add -host eth1

auto eth0
    iface eth0 inet dhcp
Now to configure DHCP but first a good idea to backup existing config.
sudo cp /etc/dhcp3/dhcpd.conf /etc/dhcpd.conf_original
With that done we can safely edit dhcpd.conf
sudo nano /etc/dhcp3/dhcpd.conf
comment out the lines
default-lease-time 600;

max-lease-time 7200;

now uncomment and change the “# A slightly different configuration” section to something like
subnet 162168.1.0 netmask{
    option domain-name-server;
    option routers;
    option broadcast-address;
    option subnet-mask;
    default-lease-time 600;
    max-lease-time 7200;
(I can't get that to be one code block)
The domain-name-server should be changed to whatever your DNS is on your internet router/modem

There is allot of different setups you can have, read through the file for some ideas or try “man dhcp3” in the terminal.

Setup samba
First I set the hard drive to mount at start up. This is not a part of samba directly but I find it annoying to mount them every time you restart the computer.
To find the location (eg: /media/MEDIA)

To find the UUID (eg: UUID=”749C4D8244CD6E7F”) and file system type.
sudo blkid

Then edit fstab
sudo nano /etc/fstab
add the line
 UUID=749C4D8244CD6E7F /media/MEDIA ntfs defaults 0 0

The default and two 0s at the end are to set the mount opptions to find out more try “man fstab” in the terminal. This should be ok for most people.

Now to the actual setup of samba,
sudo apt-get install samba
When asked to install packeges without verification select yes.
Backup the smb.conf
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_original
Now to edit smb.conf
sudo nano /etc/samba/smb.conf
Find the “; interfaces = eth0”
remove the ; and change to read
interfaces = eth1

and find “; bind interfaces only = yes”
and remove ;
then move to the end of the file and add
    comment = Music, Movies and TV Shows
    path = /media/MEDIA
    browsable = yes
    gest ok = yes
    read only = no
(again I can't figure out how to stop this moving into to code boxes, [MEDIA] should be at the top with the rest indented with spaces below it.)
This setup will allow anyone who can connect to your network to be able to read and right the share /media/MEDIA. There are many different ways to setup samba there are lots of examples in the smb.conf and even more information by “man smb”

Now restart the computer and your all done!

I you’d like to find out more you you can try as I have mentioned by useing the “man” comand to get the manual for that program, also I found these website helpful:
and don’t forget Google and the Ubuntu forums are your friends

Feel free to post a question I’ll try to help with any problems or if something isn’t clear. It may take me a day or more to get back to you but I shall do my best to help you.