|
Using SuSE linux Personal 9.1 as a network firewall
Introduction to this web pageThis web page is about modifying SuSE linux Personal 9.1 to run it as a network firewall. It was done as an experiment, as SuSE Linux 9.1 uses a later kernel than Red Hat 9, and has version 1.2.9 of iptables to go with it. The information that follows is based on having done a default installation of SuSE Linux Personal 9.1. Some of the resulting configuration could also be done during setup by using the "Change" option during the installation process.
The starting pointSuSE linux Personal 9.1 is designed as a replacement for the normal Microsoft Windows operating system, so hasn`t really been designed as a basis for server or network functions. It is therefore very GUI orientated, with the firewall configuration being done via YAST using a tool called SuSEfirewall2. This allows for the setting up of various parts of the Linux firewall engine, but doesn`t allow the individualised rule control which is required for a proper network firewall. So it is neccessary to remove any firewall configuration produced by SuSEfirewall2, then use iptables to produce the rule set we actually want to use. Iptables v1.2.9 is included in the installation of SuSE Linux Personal 9.1, the binary lives in /usr/sbin/, along with iptables-restore and iptables-save. IPv6 versions live in the same place. When the Linux firewall engine is enabled via SuSEfirewall2 via YAST, then two things happen :-
The conversion processAs well as removing the effects of SuSEFirewall2, and using iptables to configure the kernel firewall engine, there are other changes that can be made which make SuSE Linux more suitable for use as a network firewall -
Removing SuSEfirewall2The easiest way to remove both of the above effects of SuSEfirewall2 is to use YAST. On the GUI,
YAST has now entirely disabled any configuration of the kernel firewall engine by SuSEfirewall2 -
Using iptables to configure the firewallOne of the aims of this whole experiment was to reuse the same firewall configuration bash shell script that was developed for use in the Red Hat Linux 9 firewall, and it has proved to be entirely possible. It was imported into SuSE Linux, and saved in /ipt/, and run from there. The rule set is loaded into kernel space, and is available for the kernel to use. However two problems emerge :
So we have to do some configuration of SuSE Linux.
Setting up a storage locationBecause we are going to be running SuSE Linux without a full iptables initialisation script, we have to create a storage location for the rule set, so that the rule set can be recovered during the bootup process. Red Hat uses /etc/sysconfig/iptables, so that seems good enough for SuSE Linux as well. We need to create this manually as an empty file, I used Vi as root, but any method will do, as long as iptables can write to it and read from it. After manually running the shell script, the rule set is in kernel space, and stays there until a reboot. So after running the shell script, use the iptables-save command to extract the rule set from kernel space, and push it in to our storage location in user space, by using redirection of the standard output :- iptables-save > /etc/sysconfig/iptables That has the rule set saved, for later restoration after a reboot or switch on. If a new version of the shell script is produced, this process has to be repeated.
Setting up a configuration scriptBrowsing through the various initialisation scripts, it appeared that the best place to put an initial script for the firewall is in /etc/init.d/boot.localNote that SuSE Linux Personal 9.1 has a directory /etc/init.d/boot.d/ as well as the normal start up directories /etc/init.d/rc0.d/ through to /etc/init.d/rc6.d/ The link files in this directory are run before the link files in the main initialisation link files in /etc/init.d/rc3.d/, etc, so form a pre-initialisation phase of the whole linux bootup process. One of the strong advantages of initialising the firewall from this pre-initialisation phase is that the firewall rule set is in place before the network cards are enabled in the later initialisation phase, so we avoid the risk of a period of time when the linux box is wide open to attack. As an aside, during shutdown, I think we should also be okay, as the network cards are disabled as part of the shutdown process, but the kernel will still be seeing the firewall ruleset. The script that we put into /etc/init.d/boot.local is required to enable ip forwarding, and to restore the ruleset to kernel space. The first one is easily done by redirecting standard output from the echo command, and so forcing a character change in the file /proc/sys/net/ipv4/ip_forward - the relevant line in the script is - echo "1" > /proc/sys/net/ipv4/ip_forward The second one also requires redirection - because we are running without a full iptables initialisation script, the iptables-restore command doesn`t have a location to recover data from. We therefore have to redirect the standard input of this command to the location we have created. The relevant line in the script is therefore - iptables-restore < /etc/sysconfig/iptables This line recovers the stored ruleset and pushes it into kernel space for the kernel to use. The whole script that I am currently using is as follows - it includes some echo statements so that you can see it happening during the boot up process ( provided you inhibit the splash screens ). echo " ." echo " ." echo " Check that ip forwarding is not enabled" echo "0" > /proc/sys/net/ipv4/ip_forward echo " ." echo " ." echo " Restore the firewall ruleset to kernel space" iptables-restore < /etc/sysconfig/iptables echo " ." echo " ." echo " Enable ip forwarding through the firewall" echo "1" > /proc/sys/net/ipv4/ip_forward echo " ." echo " ." echo " Firewall is configured" echo " ." echo " ." With the inclusion of this script, we now have a working network firewall, but there is some tidying up we can do, to optimise the performance of SuSE Linux as a network firewall, rather than as a user workstation.
Removing the splash screenThe splash screen that SuSE put on hides the reporting of the boot up process - there are several advantages in being able to see this reporting, including :-
To inhibit the splash screen, open /etc/sysconfig/bootsplash in a text editor, and change the last line from "yes" to "no".
Removing the GUIThe GUI can be removed by changing the default run level from run level 5 to run level 3. Open the file /etc/inittab in a text editor, and change the line id:5:initdefault: so that it reads id:3:initdefault: Note that SuSE Linux suffers from the same problem that Red Hat Linux 9 suffers from - if you alternate between run level 3 and run level 5 by using the command line instruction "init 3" or "init 5" several times, then eventually the GUI becomes corrupt, it won`t load, and linux hangs.
FinallyAt the present time, all I can add is that it works, SuSE Linux Personal 9.1 can be set up to act as a network firewall. Whether it is better than using Red Hat Linux 9, I can`t at present say.
© 2004 Ron Turner Return to the Index page
|
|