Posts Tagged ‘Ubuntu’

Linux Ubuntu – creating a router, VPN, Firewall and Proxy.

Thursday, July 3rd, 2008

In this post - and the following - we want to explain how to set up a router with just Opensource materials.

This isn’t a story about journey we made in Mexico; it’s more about a personal Linux reference, which maybe is able to help someone else as well…

Before we start

This is quite some older material, but I’ve decided it put it online, so it might also help someone some day. I’m not a Linux expert and you’ll soon see for yourself what kind of problems I had - and how I cheated around. To take it right away: My project worked and was a success - well kind of.

What’s the Ubuntu server suppose to do once it’s done? The main intention was that it’s suppose to replace our old router and add some cool new features  like VPN, Proxy and a ‘better’ firewall.

The Installation

So let’s start with the installation of the Ubuntu server

Ubuntu offers a ‘server-edition’. In this version there isn’t any graphical interface and there will be just the required software packets installed.  Additional programs can be installed by aptitude or apt-get later on. To fix possible safety holes we downloaded and installed all updates that were offered by Ubuntu. Before we did that we updated our ‘sources.list’

Configuration of the ‘sources.list’ file

Apt-get requires a list of servers were it can search for updates or software and precisely for this reason the sources.list exists. You can find the file in the folder /etc/apt. Since there probably isn’t any other editor, like nano or midnight commander, installed you have to stick with ‘vi’.

Sometimes it can be a real bother, especially if you haven’t worked with ‘vi’ before. So, you might want to check the manual for it, before just starting to type, because that’ll cause errors. Errors we don’t want!

Back to the actual text, you can create your list by picking the desired servers by hand or use a generator: http://www.ubuntu-nl.org/source-o-matic/.

My list looked like this:

deb http://archive.ubuntu.com/ubuntu gutsy main restricted

deb http://archive.ubuntu.com/ubuntu gutsy-updates main restricted

deb http://security.ubuntu.com/ubuntu gutsy-security main restricted

deb-src http://archive.ubuntu.com/ubuntu gutsy main restricted

deb-src http://archive.ubuntu.com/ubuntu gutsy-updates main restricted

deb-src http://security.ubuntu.com/ubuntu gutsy-security main restricted

deb http://archive.ubuntu.com/ubuntu gutsy universe multiverse

deb http://archive.ubuntu.com/ubuntu gutsy-updates universe multiverse

deb http://security.ubuntu.com/ubuntu gutsy-security universe multiverse

deb-src http://archive.ubuntu.com/ubuntu gutsy universe multiverse

deb-src http://archive.ubuntu.com/ubuntu gutsy-updates universe multiverse

deb-src http://security.ubuntu.com/ubuntu gutsy-security universe multiverse

Those are all official Ubuntu sites; of course you can add non-official sites as well, but bear in mind that those servers could harm your server.

Installation of a new Network adapter

Till now our server will most likely just have one interface, the one over which you downloaded the updates etc. But since it is suppose to function as a router we need to have at least one more network adapter. Before you boot up you obvious need to hook your server up with one more NIC. Once you done that and booted your server go to /etc/network/ and look at the file: interfaces.

In this file you’ll find all installed network adapters that the system knows. Since you most likely want your server to get the external IP-Address dynamically you need to adjust its properties.

This is how my file looked like after I was done with it.

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces(5).

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

auto eth0

iface eth0 inet dhcp

# Our Network card which will later be hooked up to your modem

auto eth1

iface eth1 inet dhcp

After you saved the changes you can reboot the network adapters. This can be archived by ‘/etc/init.d/networking restart’. If you need further information you can check out that website: http://www.ubuntugeek.com/ubuntu-networking-configuration-using-command-line.html .

Let me explain a bit more what the line we edited above mean. ‘Auto’ tells us that the network card will be loaded when the system boots. ‘inet dhcp’ give the interface the  command to search for a DHCP and try to get a IP-Address assigned.

Once all this is done our server could be hooked up to the internet and browse - but just by himself though. There isn’t a build bride or route that would allow more users to use his internet connection.

This is it for the first part of our little series, we’ll add more as soon as we get time again…

So long Thomas!