Installing and Configuring a Simple Gateway Server

Dashamir Hoxha

Legal Notice

1. Introduction
1.1. Who Should Read This Tutorial
1.2. The Story
1.3. Requirements
2. Installation
2.1. Prepare the Installation Server
2.2. Prepare Installation Floppies
2.3. Install Rescue System
2.4. Install Server System
2.4.1. ks-server.cfg
2.4.2. syslinux.cfg
2.5. Fix GRUB (Bootloader Menu)
3. Network Configuration
3.1. Checking
3.2. /usr/local/config/network.sh
3.3. /usr/local/config/nework.cfg
3.4. /usr/local/config/network.cfg.1
3.5. /usr/local/config/network.cfg.2
3.6. /usr/local/config/network.cfg.3
4. Firewall
4.1. iptables.sh
4.2. input-rules.sh
4.3. forward-rules.sh
4.4. local-network-rules.sh
4.5. samba-rules.sh
4.6. port.sh
4.7. port-forward.sh
4.8. source-nat.sh
5. Services
5.1. Web Server
5.2. Samba
6. Reconfiguration
6.1. reconfig.sh
6.2. test.sh
7. Backup

1. Introduction

This tutorial describes the installation and configuration of a small GNU/Linux server that is used as gateway to the Internet and as a web server for a small company or institution. It takes a practical approach, describing all the steps in details, with all the commands that are used in a concrete example.

1.1. Who Should Read This Tutorial

Anybody that wants to learn how to install a gateway GNU/Linux server can read this tutorial. However, it assumes that the reader has some experience with GNU/Linux and it does not explain everything in details. The intended audience is the newbie GNU/Linux admins, not the newbie GNU/Linux users. So, if you have no previous experience with GNU/Linux, it will be hard to understand and to follow the instructions in the tutorial, and you have better to start with some introductory tutorials first, e.g. Introduction to Linux -- A Hands on Guide

In order to help you understand whether you can follow this tutorial easily, try to answer the following questions. If you can answer them positively, then most probably you can follow the instructions easily.

  1. Have you ever used GNU/Linux? Do you know what is Fedora?

  2. Have you ever installed a GNU/Linux system yourself? Do you know what is a partition? Do you know what is a swap partition?

  3. Have you ever used the commands of GNU/Linux? Do you know what is a terminal ? Have you ever used ls , cd , mkdir , cp , rm ?

  4. Do you know what is bash ? Do you know what are shell scripts ?

  5. Have you ever configured a network interface yourself? Do you know what is an IP and a netmask ?

  6. Do you know what are services? Have you ever heard about DNS , sendmail , apache ?

  7. Have you ever used the vi editor?

1.2. The Story

This tutorial is based on a concrete example, which will be described here. Suppose that a small organization (or company, institution, etc.) has a small network of computers and it is connected to Internet using a small router/modem. The diagram below shows how the components of the network are connected physically. The router and the computers are connected in an ethernet network by means of a HUB (which is represented in the picture by the thick line).

The way that the components of the network are connected physically.  There is a router/modem that provides connection to the Internet. The router and the computers are connected in an ethernet network by means of a HUB (which is represented in the picture by the thick line).

Figure 1. Physical diagram of the network

What we want to do is to place a GNU/Linux server between the router and the rest of the local network, so that it serves as a gateway for it. This way it can protect the network with a firewall, it can serve as a web server for the company, etc. We want to use SNAT (Source Network Address Translation, called also Masquerading ), so that the local computers can access the Internet, but they cannot be accessed from outside. However, we want to be able to access from outside the port 1972 of a database server that is in the local network. For this, we are going to use DNAT (Destination Network Address Translation, also called port forwarding ).

Another goal is to make this change in network configuration seamlessly and painlessly, so that the staff of the organization does not experience any interruption in the Internet connection, and we don't have to work all the night in order to do it. For this reason we are going to do it in two steps. First we are going to configure the server according to the following diagram:

First configuration of the network

Figure 2. First configuration of the network

In this network configuration the GNU/Linux server can perform all of its functions: gateway, web server, port-forwarding, etc. However the other computers can choose either the GNU/Linux server, or the router itself as gateway. This ensures that the Internet connection is not interrupted for the local network, during the time that the server is installed and tested. Also, the switch to the new gateway can be done gracefully, one by one, without Internet connection interruption.

Once the server is installed and tested, and once all the computers switch to the new gateway, we can change the configuration of the network as shown in the diagram below:

Second configuration of the network

Figure 3. Second configuration of the network

In this configuration the local network can access the Internet only through the GNU/Linux server. However, the local computers don't need to change the gateway, it is the same as before: 10.10.3.100. The physical connection doesn't need to be changed as well: the router, the server and the local machines are still connected to the HUB, same as before.

During the configuration of the server we will take care so that we can switch instantly from the first configuration to the second configuration (we will see later how).

1.3. Requirements

The minimal requirements for the GNU/Linux server are:

  • Pentium I, CPU

  • 64MB RAM

  • 1GB HDD

  • Floppy drive (no need for CD-ROM drive)

  • Two ethernet network cards.