GNU/Linux >> LINUX-Kenntnisse >  >> Panels >> Panels

Richten Sie Ubuntu-Server 6.06 LTS als Firewall/Gateway für Ihre Kleinunternehmensumgebung ein

Richten Sie Ubuntu-Server 6.06 LTS als Firewall/Gateway für Ihre Small-Business-Umgebung ein

Umfasst:Shorewall, NAT, Caching NameServer, DHCP-Server, VPN-Server, Webmin, Munin, Apache (SSL aktiviert), Squirrelmail, Postfix-Setup mit virtuellen Domänen, Courier imap imaps pop3 pop3s, sasl-Authentifizierung für Außendienstmitarbeiter, MailScanner als ein Wrapper für SpamAssassin, Razor, ClamAV usw. Samba installiert, nicht konfiguriert.

Benötigt sehr wenig Wartung und ist über Ihre wildesten Vorstellungen hinaus erweiterbar. Alles natürlich abhängig von der verwendeten Hardware.

Dies ist nur ein COPY&PASTE-Howto. Für weitere Informationen nutzen Sie das Netz. Ich habe... Beiträge und Vorschläge sind jedoch immer willkommen! Ich weiß, dass dies besser gemacht werden kann, also fühlen Sie sich frei.

Ich hätte dieses Tuto sofort auf 6.06 LTS aufbauen sollen, wegen dem LTS. Das tut mir leid. Aufgrund einiger geringfügiger, aber wichtiger Änderungen, die erforderlich sind, damit dies mit Ubuntu 6.06 LTS funktioniert, habe ich es erneut geschrieben.

Wenn jemand von euch die Zeit findet, eine gute Installation und Konfiguration für snort UND snortsam hinzuzufügen, einschließlich einer umfassenden Systemsteuerung, wäre ich dankbar.

Umfang:Erstellung eines Firewall/(Mail)-Gateways für ein kleines Netzwerk (z. B. 10 bis 15 Benutzer oder so auf einem PIII 450 MHz, 512 MB RAM und zwei identischen Netzwerkschnittstellenkarten, Breitbandverbindung, voll ausgestattet, für eine Geschäftsumgebung. Bessere Spezifikationen Ihrer Hardware (insbesondere die Menge an RAM) wird die Leistung Ihres Servers erheblich verbessern. Die genannten Spezifikationen sind ein absolutes Minimum für nicht so anspruchsvolle Kunden, nur um darauf hinzuweisen, dass es tatsächlich möglich ist, wenn Sie es wirklich wollen (muss einige Anpassungen im Nachhinein).

Erwartete Zielgruppe:(Anfang) Sysop.

Dieses Tuto führt zu einem soliden „ready to go“-System. Der lustige Teil, denke ich, (Optimieren und Tunen usw.) beginnt, wenn Sie fertig sind. Möglicherweise möchten Sie Ihre Protokolle überprüfen, um Hinweise darauf zu finden, wo die Optimierung beginnen sollte. Munin könnte dir auch viel erzählen.

Viel Spaß!

Führen Sie zunächst eine Neuinstallation mit Ubuntu-Server 6.06 LTS durch. Während der Installation werden die richtigen Einstellungen für eth0 automatisch erkannt. Wenn dies fehlschlägt, ändern Sie Ihre Netzwerkkabel und versuchen Sie es erneut. Es besteht eine sehr geringe Wahrscheinlichkeit, dass Ihr ISP keinen DHCP-Server betreibt (das habe ich noch nie gesehen) oder dass er einfach ausgefallen ist (ich habe das einige Male gesehen, auch sie können ab und zu ihr DNS vermasseln). In diesem Fall sind Sie auf Ihrer einen, warten Sie am besten, bis sie mit der Reparatur fertig sind. Wir beginnen also mit einer DHCP-zugewiesenen Adresse für eth0. Dies ist nur ein einfacher Weg, um herauszufinden, welche NIC tatsächlich eth0 ist. Wenn Sie bereits wissen, welches das ist, beginnen Sie besser mit einer statischen Adresse für eth0. Wenn Ihr ISP nicht beschissen ist, haben Sie die richtigen Einstellungen dafür.

Fahren Sie nun fort und akzeptieren Sie alle Standardwerte (aber Sie möchten vielleicht Ihre eigene Partitionierung vornehmen), installieren Sie LAMP nicht.

Melden Sie sich jetzt als der neue Benutzer an, den Sie gerade erstellt haben, und tun Sie Folgendes:

sudo passwd

Geben Sie nun erneut Ihr Passwort ein. Geben Sie als Nächstes das neue Passwort für den Benutzer „root“ ein und bestätigen Sie. Damit haben wir die unangenehme Sudo-Erfahrung fallen gelassen (etwas seltsam auf einem Server, nicht wahr?). Melden Sie sich jetzt ab und wieder als root mit dem neuen Root-Passwort an.

Bearbeiten Sie /etc/apt/sources.list mit vim (oder Ihrem bevorzugten Editor). Kommentieren Sie das CD-Repository aus. Fügen Sie als Nächstes "Universum" (ohne Anführungszeichen) zu allen Zeilen hinzu, die nicht auskommentiert sind, und kommentieren Sie die Backport-Repositorys aus. Speichern Sie die Datei.

Bearbeiten Sie /etc/network/interfaces und fügen Sie unten Folgendes hinzu:

auto eth1
iface eth1 inet static
	address		192.168.1.1
	netmask	        255.255.255.0
	broadcast	192.168.1.255
	network		192.168.1.0

Beachten Sie, dass der Rest dieses Tutorials davon ausgeht, dass Sie die Einstellungen für eth1 tatsächlich wie gezeigt vornehmen.

Mein vollständiges /etc/network/interfaces sieht so aus:

# 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
auto eth1
iface eth1 inet static
	address		192.168.1.1
	netmask		255.255.255.0
	broadcast	192.168.1.255
	network		192.168.1.0

Wie Sie sehen, erhält mein eth0 seine Einstellungen über DHCP.

Speicher die Datei. Als nächstes:

apt-get update
apt-get install openssh-server
apt-get upgrade

Während des Upgrade-Vorgangs wird ein neues Kernel-Image installiert. Also als nächstes:

reboot

Den Rest können Sie von Ihrer Workstation aus erledigen, entweder Linux oder die andere (muss Putty haben), sodass Sie tatsächlich kopieren und einfügen können. Melden Sie sich einfach bei 192.168.1.1 als root an und machen Sie weiter.

Stellen Sie sicher, dass die Netzwerkeinstellungen Ihrer Workstation mit den Einstellungen von eth1 Ihres Servers übereinstimmen

Wenn Sie hier verwirrt sind, konfigurieren und starten Sie zunächst Ihren DHCP-Server wie in diesem Artikel beschrieben und lassen Sie Ihre Workstation die richtigen Einstellungen automatisch erkennen.

Ubuntu-Server 6.06 LTS als Firewall/Gateway für Ihre Kleinunternehmensumgebung einrichten – Seite 2

Jetzt tun:

apt-get install libmd5-perl libnet-ssleay-perl libauthen-pam-perl libio-pty-perl shorewall dnsmasq openssl
wget http://surfnet.dl.sourceforge.net/sourceforge/webadmin/webmin_1.390_all.deb

"surfnet" ist der niederländische Server. Ändern Sie das in „heanet“ (für Irland), „belnet“ (für Belgien), „mesh“ (für Deutschland) und so weiter.

dpkg -i webmin_1.390_all.deb
cp /usr/share/doc/shorewall/examples/two-interfaces/* /etc/shorewall/
cd /etc/shorewall
gunzip interfaces.gz masq.gz rules.gz

Öffnen Sie nun Ihren Browser und melden Sie sich bei Webmin unter https://192.168.1.1:10000 als root mit Ihrem Root-Passwort an und ändern Sie mit dem Shorewall-Modul von Webmin die Richtlinien und Regeln Ihrer Firewall nach Bedarf (vorerst stelle ich nur die Regeln ein Datei zum Beispiel wie gezeigt, Sie können zunächst meine Regeldatei kopieren und einfügen, wenn Sie Webmin nicht mögen).

Setzen Sie außerdem in /etc/shorewall/shorewall.conf  die Zeile „IP_FORWARDING=Keep“  auf „IP_FORWARDING=On“ (ohne Anführungszeichen)
und aktivieren Sie die Firewall in /etc/default/shorewall.

Meine /etc/shorewall/rules  sieht jetzt so aus:

#############################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/
# PORT PORT(S) DEST LIMIT GROUP
# PORT PORT(S) DEST LIMIT GROUP
#
# Accept DNS connections from the firewall to the network
#
DNS/ACCEPT $FW net
ACCEPT $FW net all
ACCEPT $FW loc all
ACCEPT loc $FW all
#
# Accept SSH connections from the local network for administration
#
SSH/ACCEPT loc $FW
#
# Allow Ping from the local network
#
Ping/ACCEPT loc $FW
#
# Reject Ping from the "bad" net zone.. and prevent your log from being flooded..
#
Ping/REJECT net $FW
ACCEPT $FW loc icmp
ACCEPT $FW net icmp
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
Als nächstes:
rm /etc/shorewall/README.txt Makefile
/etc/init.d/shorewall start

Sie sollten jetzt im Internet surfen können.

FAHREN SIE NICHT FORT, BIS SIE ERFOLGREICH IM NETZ SURFEN. DENN DIES IST IHR RAHMEN. ES MUSS IN ORDNUNG SEIN.

Ubuntu-Server 6.06 LTS als Firewall/Gateway für Ihre Kleinunternehmensumgebung einrichten – Seite 3

Also brauchen wir jetzt ein paar Pakete. Tun (alles in einer Zeile!):

apt-get install clamav-daemon xfsdump razor pyzor mailscanner spamc spamassassin postfix courier-authmysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl libsasl2-modules-sql sasl2-bin libpam-mysql build-essential dpkg-dev fakeroot debhelper libdb4.2-dev libgdbm-dev libldap2-dev libpcre3-dev libmysqlclient12-dev libssl-dev libsasl2-dev postgresql-dev po-debconf dpatch zoo unzip arj rdate fetchmail zip ncftp zlib1g-dev libpopt-dev nmap lynx fileutils curl imagemagick squirrelmail squirrelmail-locales munin munin-node ntp nfs-kernel-server samba unzoo mysql-server mysql-client libapache2-mod-php4 libapache2-mod-perl2 php4 php4-cli php4-common php4-curl php4-dev php4-domxml php4-gd php4-imap php4-ldap php4-mcal php4-mhash php4-mysql php4-odbc php4-pear php4-xslt curl php-pear mailx libzzip-dev libgmp3c2 libgmp3-dev dhcp3-server pptpd

Alle Standardeinstellungen akzeptieren.

Jetzt tun:

mysqladmin -u root password yourrootsqlpassword

VERWENDEN SIE HIER EIN ECHTES PASSWORT!

Konfigurieren Sie nun Apache und Squirrelmail.

/usr/sbin/squirrelmail-configure

Stellen Sie es auf courier (Option D) und machen Sie ik sonst so, wie Sie es möchten.
Vergessen Sie nicht, einige Plugins zu aktivieren und eine Standardsprache festzulegen, falls gewünscht. Ich schlage auch vor, dies zu setzen:

$show_contain_subfolders_option = true;

Meine/etc/squirrelmail/config.php sieht jetzt so aus:(Nur meine aktuelle Konfiguration. Nicht kopieren, sondern als Referenz verwenden.)

<?php

/**
* SquirrelMail Configuration File
* Created using the configure script, conf.pl
*/

global $version;
$config_version = '1.4.0';
$config_use_color = 2;

$org_name = "Lürsen";
$org_logo = SM_PATH . 'images/sm_logo.png';
$org_logo_width = '564';
$org_logo_height = '261';
$org_title = "Lürsen";
$signout_page = 'https://lursen.net/webmail';
$frame_top = '_top';

$provider_uri = 'http://www.squirrelmail.org/';

$provider_name = 'SquirrelMail';

$motd = "";

$squirrelmail_default_language = 'nl_NL';
$default_charset = 'iso-8859-1';
$lossy_encoding = false;

$domain = 'lursen.net';
$imapServerAddress = 'localhost';
$imapPort = 143;
$useSendmail = false;
$smtpServerAddress = 'localhost';
$smtpPort = 25;
$sendmail_path = '/usr/sbin/sendmail';
$sendmail_args = '-i -t';
$pop_before_smtp = false;
$imap_server_type = 'courier';
$invert_time = false;
$optional_delimiter = '.';
$encode_header_key = '';

$default_folder_prefix = 'INBOX.';
$trash_folder = 'Trash';
$sent_folder = 'Sent';
$draft_folder = 'Drafts';
$default_move_to_trash = true;
$default_move_to_sent = true;
$default_save_as_draft = true;
$show_prefix_option = false;
$list_special_folders_first = true;
$use_special_folder_color = true;
$auto_expunge = true;
$default_sub_of_inbox = false;
$show_contain_subfolders_option = true;
$default_unseen_notify = 2;
$default_unseen_type = 1;
$auto_create_special = true;
$delete_folder = true;
$noselect_fix_enable = false;

$data_dir = '/var/lib/squirrelmail/ data/';
$attachment_dir = '/var/spool/squirrelmail/attach/';
$dir_hash_level = 0;
$default_left_size = '150';
$force_username_lowercase = false;
$default_use_priority = true;
$hide_sm_attributions = false;
$default_use_mdn = true;
$edit_identity = true;
$edit_name = true;
$hide_auth_header = false;
$allow_thread_sort = false;
$allow_server_sort = false;
$allow_charset_search = true;
$uid_support = true;

$plugins[0] = 'abook_take';
$plugins[1] = 'delete_move_next';
$plugins[2] = 'calendar';
$plugins[3] = 'filters';
$plugins[4] = 'message_details';
$plugins[5] = 'mail_fetch';
$plugins[6] = 'newmail';

$theme_css = '';
$theme_default = 0;
$theme[0]['PATH'] = SM_PATH . 'themes/default_theme.php';
$theme[0]['NAME'] = 'Default';
$theme[1]['PATH'] = SM_PATH . 'themes/plain_blue_theme.php';
$theme[1]['NAME'] = 'Plain Blue';
$theme[2]['PATH'] = SM_PATH . 'themes/sandstorm_theme.php';
$theme[2]['NAME'] = 'Sand Storm';
$theme[3]['PATH'] = SM_PATH . 'themes/deepocean_theme.php';
$theme[3]['NAME'] = 'Deep Ocean';
$theme[4]['PATH'] = SM_PATH . 'themes/slashdot_theme.php';
$theme[4]['NAME'] = 'Slashdot';
$theme[5]['PATH'] = SM_PATH . 'themes/purple_theme.php';
$theme[5]['NAME'] = 'Purple';
$theme[6]['PATH'] = SM_PATH . 'themes/forest_theme.php';
$theme[6]['NAME'] = 'Forest';
$theme[7]['PATH'] = SM_PATH . 'themes/ice_theme.php';
$theme[7]['NAME'] = 'Ice';
$theme[8]['PATH'] = SM_PATH . 'themes/seaspray_theme.php';
$theme[8]['NAME'] = 'Sea Spray';
$theme[9]['PATH'] = SM_PATH . 'themes/bluesteel_theme.php';
$theme[9]['NAME'] = 'Blue Steel';
$theme[10]['PATH'] = SM_PATH . 'themes/dark_grey_theme.php';
$theme[10]['NAME'] = 'Dark Grey';
$theme[11]['PATH'] = SM_PATH . 'themes/high_contrast_theme.php';
$theme[11]['NAME'] = 'High Contrast';
$theme[12]['PATH'] = SM_PATH . 'themes/bla ck_bean_burrito_theme.php';
$theme[12]['NAME'] = 'Black Bean Burrito';
$theme[13]['PATH'] = SM_PATH . 'themes/servery_theme.php';
$theme[13]['NAME'] = 'Servery';
$theme[14]['PATH'] = SM_PATH . 'themes/maize_theme.php';
$theme[14]['NAME'] = 'Maize';
$theme[15]['PATH'] = SM_PATH . 'themes/bluesnews_theme.php';
$theme[15]['NAME'] = 'BluesNews';
$theme[16]['PATH'] = SM_PATH . 'themes/deepocean2_theme.php';
$theme[16]['NAME'] = 'Deep Ocean 2';
$theme[17]['PATH'] = SM_PATH . 'themes/blue_grey_theme.php';
$theme[17]['NAME'] = 'Blue Grey';
$theme[18]['PATH'] = SM_PATH . 'themes/dompie_theme.php';
$theme[18]['NAME'] = 'Dompie';
$theme[19]['PATH'] = SM_PATH . 'themes/methodical_theme.php';
$theme[19]['NAME'] = 'Methodical';
$theme[20]['PATH'] = SM_PATH . 'themes/greenhouse_effect.php';
$theme[20]['NAME'] = 'Greenhouse Effect (Changes)';
$theme[21]['PATH'] = SM_PATH . 'themes/in_the_pink.php';
$theme[21]['NAME'] = 'In The Pink (Changes)';
$theme[22]['PATH'] = SM_PATH . 'themes/kind_of_blue.php';
$theme[22]['NAME'] = 'Kind of Blue (Changes)';
$theme[23]['PATH'] = SM_PATH . 'themes/monostochastic.php';
$theme[23]['NAME'] = 'Monostochastic (Changes)';
$theme[24]['PATH'] = SM_PATH . 'themes/shades_of_grey.php';
$theme[24]['NAME'] = 'Shades of Grey (Changes)';
$theme[25]['PATH'] = SM_PATH . 'themes/spice_of_life.php';
$theme[25]['NAME'] = 'Spice of Life (Changes)';
$theme[26]['PATH'] = SM_PATH . 'themes/spice_of_life_lite.php';
$theme[26]['NAME'] = 'Spice of Life - Lite (Changes)';
$theme[27]['PATH'] = SM_PATH . 'themes/spice_of_life_dark.php';
$theme[27]['NAME'] = 'Spice of Life - Dark (Changes)';
$theme[28]['PATH'] = SM_PATH . 'themes/christmas.php';
$theme[28]['NAME'] = 'Holiday - Christmas';
$theme[29]['PATH'] = SM_PATH . 'themes/darkness.php';
$theme[29]['NAME'] = 'Darkness (Changes)';
$theme[30]['PATH'] = SM_PATH . 'themes/random.php';
$theme[30]['NAME'] = 'Random (Changes every login)';
$theme[31]['PATH'] = SM _PATH . 'themes/midnight.php';
$theme[31]['NAME'] = 'Midnight';
$theme[32]['PATH'] = SM_PATH . 'themes/alien_glow.php';
$theme[32]['NAME'] = 'Alien Glow';
$theme[33]['PATH'] = SM_PATH . 'themes/dark_green.php';
$theme[33]['NAME'] = 'Dark Green';
$theme[34]['PATH'] = SM_PATH . 'themes/penguin.php';
$theme[34]['NAME'] = 'Penguin';
$theme[35]['PATH'] = SM_PATH . 'themes/minimal_bw.php';
$theme[35]['NAME'] = 'Minimal BW';
$theme[36]['PATH'] = SM_PATH . 'themes/redmond.php';
$theme[36]['NAME'] = 'Redmond';
$theme[37]['PATH'] = SM_PATH . 'themes/netstyle_theme.php';
$theme[37]['NAME'] = 'Net Style';
$theme[38]['PATH'] = SM_PATH . 'themes/silver_steel_theme.php';
$theme[38]['NAME'] = 'Silver Steel';
$theme[39]['PATH'] = SM_PATH . 'themes/simple_green_theme.php';
$theme[39]['NAME'] = 'Simple Green';
$theme[40]['PATH'] = SM_PATH . 'themes/wood_theme.php';
$theme[40]['NAME'] = 'Wood';
$theme[41]['PATH'] = SM_PATH . 'themes/bluesome.php';
$theme[41]['NAME'] = 'Bluesome';
$theme[42]['PATH'] = SM_PATH . 'themes/simple_green2.php';
$theme[42]['NAME'] = 'Simple Green 2';
$theme[43]['PATH'] = SM_PATH . 'themes/simple_purple.php';
$theme[43]['NAME'] = 'Simple Purple';
$theme[44]['PATH'] = SM_PATH . 'themes/autumn.php';
$theme[44]['NAME'] = 'Autumn';
$theme[45]['PATH'] = SM_PATH . 'themes/autumn2.php';
$theme[45]['NAME'] = 'Autumn 2';
$theme[46]['PATH'] = SM_PATH . 'themes/blue_on_blue.php';
$theme[46]['NAME'] = 'Blue on Blue';
$theme[47]['PATH'] = SM_PATH . 'themes/classic_blue.php';
$theme[47]['NAME'] = 'Classic Blue';
$theme[48]['PATH'] = SM_PATH . 'themes/classic_blue2.php';
$theme[48]['NAME'] = 'Classic Blue 2';
$theme[49]['PATH'] = SM_PATH . 'themes/powder_blue.php';
$theme[49]['NAME'] = 'Powder Blue';
$theme[50]['PATH'] = SM_PATH . 'themes/techno_blue.php';
$theme[50]['NAME'] = 'Techno Blue';
$theme[51]['PATH'] = SM_PATH . 'themes/turquoise.php';
$theme[51]['NAME'] = 'Turquoise';

$default_use_jav ascript_addr_book = false;
$abook_global_file = '';
$abook_global_file_writeable = false;

$addrbook_dsn = '';
$addrbook_table = 'address';

$prefs_dsn = '';
$prefs_table = 'userprefs';
$prefs_user_field = 'user';
$prefs_key_field = 'prefkey';
$prefs_val_field = 'prefval';
$addrbook_global_dsn = '';
$addrbook_global_table = 'global_abook';
$addrbook_global_writeable = false;
$addrbook_global_listing = false;

$no_list_for_subscribe = false;
$smtp_auth_mech = 'none';
$imap_auth_mech = 'login';
$use_imap_tls = false;
$use_smtp_tls = false;
$session_name = 'SQMSESSID';

$config_location_base = '';

@include SM_PATH . 'config/config_local.php';

/**
* Make sure there are no characters after the PHP closing
* tag below (including newline characters and whitespace).
* Otherwise, that character will cause the headers to be
* sent and regular output to begin, which will majorly screw
* things up when we try to send more headers later.
*/
?>

Als nächstes tun:

apache2-ssl-certificate -days 3650

Geben Sie den richtigen Servernamen ein!!!

Das heißt:die Adresse, unter der Sie Ihren Benutzern Zugriff auf Squirrelmail oder einen anderen Dienst per Apache auf Port 443 gewähren möchten. Nur die Domain reicht aus (MUSS IM DNS VORHANDEN SEIN). Nicht Domain/Webmail.

Wenn etwas schief gelaufen ist, löschen Sie einfach das Zertifikat und wiederholen Sie diesen Schritt.

Geben Sie nun ein:

a2enmod ssl
a2enmod rewrite
a2enmod include
cp /etc/apache2/sites-available/default /etc/apache2/sites-available/https
ln -s /etc/apache2/sites-available/https /etc/apache2/sites-enabled/https
ln -s /etc/squirrelmail/apache.conf /etc/apache2/sites-enabled/squirrelmail

Ubuntu-Server 6.06 LTS als Firewall/Gateway für Ihre Kleinunternehmensumgebung einrichten – Seite 4

Bearbeiten Sie als Nächstes /etc/courier/imapd-ssl und ändern Sie Folgendes:

TLS_CERTFILE=/etc/apache2/ssl/apache.pem

Machen Sie jetzt dasselbe mit /etc/courier/pop3d-ssl.

Bearbeiten Sie nun /etc/apache2/sites-available/default. Die Spitze muss so geändert werden, dass sie lautet:

NameVirtualHost *:80
<VirtualHost *:80>

Bearbeiten Sie auch /etc/apache2/sites-available/https, oben in der Datei sollte stehen:

NameVirtualHost *:443
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
Bearbeiten Sie /etc/squirrelmail/apache.conf. Es sollte so aussehen:
Alias /webmail /usr/share/squirrelmail

<Directory /usr/share/squirrelmail>
php_flag register_globals off
Options Indexes FollowSymLinks
<IfModule mod_dir.c>
DirectoryIndex index.php
</IfModule>

# access to configtest is limited by default to prevent information leak
<Files configtest.php>
order deny,allow
deny from all
allow from 127.0.0.1
</Files>
</Directory>
# users will prefer a simple URL like http://webmail.example.com
#<VirtualHost 1.2.3.4>
# DocumentRoot /usr/share/squirrelmail
# ServerName webmail.example.com
#</VirtualHost>
# redirect to https when available (thanks [email protected])
#
# Note: There are multiple ways to do this, and which one is suitable for
# your site's configuration depends. Consult the apache documentation if
# you're unsure, as this example might not work everywhere.
#
<IfModule mod_rewrite.c>
<IfModule mod_ssl.c>
<Location /webmail>
RewriteEngine on
RewriteCond %{HTTPS} !^on$ [NC]
RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI} [L]
</Location>
</IfModule>
</IfModule>

Stellen Sie nun sicher, dass die DirectoryIndex-Zeile in /etc/apache2/apache2.conf lautet:

DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl index.xhtml

Bearbeiten Sie /etc/apache2/ports.conf und fügen Sie Listen 443:

hinzu
Listen 80
Listen 443

Ubuntu-Server 6.06 LTS als Firewall/Gateway für Ihre Kleinunternehmensumgebung einrichten – Seite 5

Lassen Sie jetzt squirrelmail Ihre Sprache sprechen. Wenn Sie nur Englisch verwenden, können Sie die letzte Zeile in der Datei natürlich überspringen.

Bearbeiten Sie /var/lib/locales/supported.d/local.

Es sollte so aussehen:(wenn Sie Niederländer sind, passen Sie es ansonsten wie gewünscht an). Hauptsache, Sie aktivieren Ihr Gebietsschema mit dem Zeichensatz ISO-8859-1.

en_US.UTF-8 UTF-8
en_US.ISO-8859-1	ISO-8859-1
nl_NL.ISO-8859-1	ISO-8859-1

dpkg-reconfigure locales

Jetzt konfigurieren wir postfix.

postconf -e 'mynetworks = 127.0.0.0/8, 192.168.1.0/24'
postconf -e 'smtpd_sasl_local_domain ='
postconf -e 'smtpd_sasl_auth_enable = yes'
postconf -e 'smtpd_sasl_security_options = noanonymous'
postconf -e 'broken_sasl_auth_clients = yes'

postconf -e 'smtpd_recipient_restrictions =permission_sasl_authenticated,permit_mynetworks,reject_unauth_destination'

postconf -e 'inet_interfaces = all'
echo 'pwcheck_method: saslauthd' >> /etc/postfix/sasl/smtpd.conf
echo 'mech_list: plain login' >> /etc/postfix/sasl/smtpd.conf
postconf -e 'smtpd_tls_auth_only = no'
postconf -e 'smtp_use_tls = yes'
postconf -e 'smtpd_use_tls = yes'
postconf -e 'smtp_tls_note_starttls_offer = yes'
postconf -e 'smtpd_tls_key_file = /etc/apache2/ssl/apache.pem'
postconf -e 'smtpd_tls_cert_file = /etc/apache2/ssl/apache.pem'
postconf -e 'smtpd_tls_loglevel = 1'
postconf -e 'smtpd_tls_received_header = yes'
postconf -e 'smtpd_tls_session_cache_timeout = 3600s'
postconf -e 'tls_random_source = dev:/dev/urandom'
postconf -e 'home_mailbox = Maildir/'
postconf -e 'mailbox_command ='
postconf -e 'header_checks = regexp:/etc/postfix/header_checks'
postconf -e 'relayhost ='
postconf -e 'virtual_alias_domains = hash:/etc/postfix/virtual'
postconf -e 'virtual_alias_maps = hash:/etc/postfix/virtual'
postconf -e 'smtp_never_send_ehlo = yes'
touch /etc/postfix/header_checks
touch /etc/postfix/virtual

Ubuntu-Server 6.06 LTS als Firewall/Gateway für Ihre Kleinunternehmensumgebung einrichten – Seite 6

Bearbeiten Sie nun etc/postfix/header_checks.

Es sollte so aussehen:

/^Received:/ HOLD

cd /root
Konfigurieren Sie nun MailScanner.
chown postfix.postfix /var/spool/MailScanner/incoming
chown postfix.postfix /var/spool/MailScanner/quarantine
mkdir /var/spool/MailScanner/spamassassin
ln -s /etc/MailScanner/spam.assassin.prefs.conf /etc/spamassassin/mailscanner.cf
chown postfix.postfix /var/spool/MailScanner/spamassassin

Bearbeiten Sie nun /etc/MailScanner/MailScanner.conf und setzen Sie die folgenden Zeilen wie gezeigt:

Run As User = postfix
Run As Group = postfix
Queue Scan Interval = 120
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
Virus Scanners = clamav
Always Include SpamAssassin Report = yes
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
Entkommentieren Sie die Zeile # run_mailscanner=1 in /etc/default/mailscanner.

Machen Sie jetzt einen Cron-Job von /usr/sbin/check_mailscanner und führen Sie ihn alle 20 Minuten aus.

Jetzt werden wir das Startskript von MailScanner täuschen. Dies ist notwendig, da MailScanner aufgrund eines auf Exim ausgerichteten Skripts den Start verweigert, vermute ich (ich habe Exim nie wirklich verwendet, daher bin ich mir nicht sicher). Ich möchte das Skript selbst nicht ändern, da es in Zukunft möglicherweise durch ein weiteres "nicht startendes" Update ersetzt wird. Nur um auf der sicheren Seite zu sein.

touch /etc/init.d/mailscanner_pre

Bearbeiten Sie /etc/init.d/mailscanner_pre. Es sollte so aussehen:

#!/bin/sh
mkdir /var/lock/subsys
mkdir /var/lock/subsys/MailScanner
mkdir /var/run/MailScanner
chown postfix.postfix /var/run/MailScanner
chown postfix.postfix /var/lock/subsys/MailScanner

chmod 755 /etc/init.d/mailscanner_pre
mv /etc/rc2.d/S20mailscanner /etc/rc2.d/S99mailscanner
mv /etc/rc3.d/S20mailscanner /etc/rc3.d/S99mailscanner
mv /etc/rc4.d/S20mailscanner /etc/rc4.d/S99mailscanner
mv /etc/rc5.d/S20mailscanner /etc/rc5.d/S99mailscanner
ln -s /etc/init.d/mailscanner_pre /etc/rc2.d/S20mailscanner_pre
chown postfix.postfix /var/spool/MailScanner
chown postfix.postfix /var/lib/MailScanner

Das sollte jetzt reichen, meinst du nicht?

Ubuntu-Server 6.06 LTS als Firewall/Gateway für Ihre Kleinunternehmensumgebung einrichten – Seite 7

Konfigurieren Sie jetzt die sasl-Authentifizierung.

mkdir -p /var/spool/postfix/var/run/saslauthd

Jetzt müssen wir /etc/default/saslauthd bearbeiten. Es sollte so aussehen:

# This needs to be uncommented before saslauthd will be run automatically
START=yes
PARAMS="-m /var/spool/postfix/var/run/saslauthd -r"
# You must specify the authentication mechanisms you wish to use.
# This defaults to "pam" for PAM support, but may also include
# "shadow" or "sasldb", like this:
# MECHANISMS="pam shadow"
MECHANISMS="pam"
Bearbeiten Sie als Nächstes /etc/init.d/saslauthd und ändern Sie den Speicherort der PID-Datei von saslauthd. Ändern Sie den Wert von PIDFILE in /var/spool/postfix/var/run/${NAME}/saslauthd.pid, sodass er lautet:
PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"

Füllen Sie jetzt Ihr System mit echten Benutzern. Setzen Sie die Benutzer-Shell auf /bin/false, um Sicherheitslücken zu vermeiden.

Als nächstes füllen Sie /etc/postfix/virtual wie Sie möchten. Ich liebe Webmin dafür. Sie können es natürlich auch direkt bearbeiten. Webmin leistet jedoch hervorragende Arbeit.

Gotcha!:"irgendeine.domain" usw. kann nicht mit irgendetwas übereinstimmen, was in der "mydestination"-Zeile in

erwähnt wird

/etc/postfix/main.cf

Meine /etc/postfix/virtual hat folgende Struktur:

some.domain	virtual domain
some.other.domain	virtual domain
some.really.other.domain	virtual domain
[email protected]		user
[email protected]	otheruser
[email protected]	user
[email protected]	otheruser
[email protected]	user
[email protected]	someoneidontlike
[email protected]	someoneidontlike [email protected]
[email protected]	differentuser	[email protected]	someoneidontlike
@some.really.other.domain		someonidontlike		[email protected]
und so weiter. Ich muss also nur einen Alias ​​für root und postmaster in /etc/aliases setzen. Alle anderen Aliase sollten in dieser Datei stehen. Das Weiterleiten und Zustellen von E-Mails an mehrere Adressen und so weiter kann (und sollte, glaube ich) auch in dieser Datei eingestellt werden.

Beachten Sie, dass Ihre Benutzer bei dieser Art von Setup so viele Aliase haben können, wie sie möchten (bis Sie sie satt haben), aber Sie müssen trotzdem für jeden Benutzer einen echten Benutzer mit einem Home-Verzeichnis hinzufügen.

Nicht vergessen

postmap /etc/postfix/virtual

wenn Sie fertig sind.

Jetzt wollen wir ein paar Regeln für Spamassassin, damit es besser funktioniert.

Bearbeiten Sie zuerst /etc/MailScanner/spam.assassin.prefs.conf.

Kommentieren Sie dcc_path /usr/bin/dccproc aus. Kommentieren Sie auch razor_timeout 10 aus und
bewerten Sie RCVD_IN_RSL mit 0.

Als nächstes:

cd ..
wget http://www.fsl.com/support/Rules_Du_Jour.tar.gz
tar -zxvf Rules_Du_Jour.tar.gz
cd rules_du_jour
mkdir /etc/rulesdujour
cp config /etc/rulesdujour/config
cp rules_du_jour /usr/bin
cp rules_du_jour_wrapper /etc/cron.daily
/etc/cron.daily/rules_du_jour_wrapper

Als nächstes konfigurieren wir den DHCP-Server.

Bearbeiten Sie /etc/dhcp3/dhcpd.conf. Meine sieht jetzt so aus:

# Local Network
subnet 192.168.1.0 netmask 255.255.255.0 {
	option netbios-name-servers 192.168.1.1;
	option domain-name-servers 192.168.1.1;
	option domain-name "your.domain.here";
	option broadcast-address 192.168.1.255;
	option routers 192.168.1.1;
	range 192.168.1.100 192.168.1.130;
	}

Bearbeiten Sie /etc/default/dhcp3-server. Es sollte

lauten
INTERFACES=eth1

Als nächstes:

/etc/init.d/dhcp3-server start

Installieren Sie als Nächstes dcc aus der Quelle

cd /root
wget http://www.dcc-servers.net/dcc/source/dcc.tar.Z
gunzip dcc.tar.Z
tar -xvf dcc.tar
cd dcc*
./configure
make
make install
shutdown -r now

und warte, bis es wieder hochgefahren ist.

Ubuntu-Server 6.06 LTS als Firewall/Gateway für Ihre Kleinunternehmensumgebung einrichten – Seite 8

Jetzt müssen Sie jedem echten Benutzer eine Willkommensnachricht senden und so die anfänglichen Maildir-Strukturen in ihren Home-Verzeichnissen erstellen, die erforderlich sind, um sich bei ihren Konten anmelden zu können. Sie können dafür das Postfix-Modul von Webmin verwenden. Sie müssen nichts an ihre Aliase senden. Möglicherweise möchten Sie ein externes E-Mail-Konto verwenden, um diese Willkommensnachrichten zu senden. Dazu müssen Sie jedoch zuerst Port 25 in Ihrer Firewall öffnen, wie auf dieser Seite des Tutorials gezeigt.

Beachten Sie, dass Sie natürlich auch nach dieser Ersteinrichtung eine Nachricht an jeden neu hinzugefügten Benutzer senden müssen.

Ihr Webmail-Server befindet sich unter https://ihre.domain/webmail (senden Sie zuerst diese Nachrichten!)

Munin befindet sich unter http://your.domain/munin

Webmin befindet sich unter https://your.domain:10000

If you haven't set any domains, use https://192.168.1.1/webmail etc.

Check that you can log in to your webmail and actually send and receive mail within your local network. If you're satisfied, open port 25 on your firewall for incoming tcp traffic (postfix) and port 6277 for incoming udp traffic (dcc). You may wish to make your webmail server availableto your users from the outside world. Open port 443 for incoming tcp traffic as well (apache ssl). Opening port 993 is also a good idea for incoming tcp connections, as it facilitates imaps.

My /etc/shorewall/rules now looks like this:(just to begin with, all firewall settings shown in this article are just ment to get you up and running, you might want to adjust these settings once you are done!)

#############################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/
# PORT PORT(S) DEST LIMIT GROUP
# PORT PORT(S) DEST LIMIT GROUP
ACCEPT net $FW tcp 25
ACCEPT net $FW tcp 443
ACCEPT net $FW tcp 993
ACCEPT net $FW udp 6277
#
# Accept DNS connections from the firewall to the network
#
DNS/ACCEPT $FW net
ACCEPT $FW net all
ACCEPT $FW loc all
ACCEPT loc $FW all
#
# Accept SSH connections from the local network for administration
#
SSH/ACCEPT loc $FW
#
# Allow Ping from the local network
#
Ping/ACCEPT loc $FW
#
# Reject Ping from the "bad" net zone.. and prevent your log from being flooded..
#
Ping/REJECT net $FW
ACCEPT $FW loc icmp
ACCEPT $FW net icmp
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
Restart the firewall:
/etc/init.d/shorewall restart

Next do:

/var/dcc/libexec/updatedcc

Now we configure your VPN Server.

Edit /etc/pptpd.conf. It should look like this now:

###############################################################################
# $Id: pptpd.conf 4255 2004-10-03 18:44:00Z rene $
#
# Sample Poptop configuration file /etc/pptpd.conf
#
# Changes are effective when pptpd is restarted.
###############################################################################

# TAG: ppp
# Path to the pppd program, default '/usr/sbin/pppd' on Linux
#
#ppp /usr/sbin/pppd

# TAG: option
# Specifies the location of the PPP options file.
# By default PPP looks in '/etc/ppp/options'
#
option /etc/ppp/pptpd-options

# TAG: debug
# Turns on (more) debugging to syslog
#
#debug

# TAG: stimeout
# Specifies timeout (in seconds) on starting ctrl connection
#
# stimeout 10

# TAG: noipparam
# Suppress the passing of the client's IP address to PPP, which is
# done by default otherwise.
#
#noipparam

# TAG: logwtmp
# Use wtmp(5) to record client connections and disconnections.
#
logwtmp

# TAG: bcrelay <if>
# Turns on broadcast relay to clients from interface <if>
#
#bcrelay eth1

# TAG: localip
# TAG: remoteip
# Specifies the local and remote IP address ranges.
#
# Any addresses work as long as the local machine takes care of the
# routing. But if you want to use MS-Windows networking, you should
# use IP addresses out of the LAN address space and use the proxyarp
# option in the pppd options file, or run bcrelay.
#
# You can specify single IP addresses seperated by commas or you can
# specify ranges, or both. For example:
#
# 192.168.0.234,192.168.0.245-249,192.168.0.254
#
# IMPORTANT RESTRICTIONS:
#
# 1. No spaces are permitted between commas or within addresses.
#
# 2. If you give more IP addresses than MAX_CONNECTIONS, it will
# start at the beginning of the list and go until it gets
# MAX_CONNECTIONS IPs. Others will be ignored.
#
# 3. No shortcuts in ranges! ie. 234-8 does not mean 234 to 238,
# you must type 234-238 if you mean this.
#
# 4. If you give a single localIP, that's ok - all local IPs will
# be set to the given one. You MUST still give at least one remote
# IP for each simultaneous client.
#
# (Recommended)
localip 192.168.1.1
remoteip 192.168.1.10-30
# or
#localip 192.168.0.234-238,192.168.0.245
#remoteip 192.168.1.234-238,192.168.1.245

Next edit /etc/ppp/options.It should look like this:
asyncmap 0
noauth
lock
hide-password
proxyarp
lcp-echo-interval 30
lcp-echo-failure 4
noipx

Edit /etc/ppp/pptpd-options. It should look like this:
###############################################################################
# $Id: pptpd-options 4643 2006-11-06 18:42:43Z rene $
#
# Sample Poptop PPP options file /etc/ppp/pptpd-options
# Options used by PPP when a connection arrives from a client.
# This file is pointed to by /etc/pptpd.conf option keyword.
# Changes are effective on the next connection. See "man pppd".
#
# You are expected to change this file to suit your system. As
# packaged, it requires PPP 2.4.2 and the kernel MPPE module.
###############################################################################


# Authentication

# Name of the local system for authentication purposes
# (must match the second field in /etc/ppp/chap-secrets entries)
name pptp-vpn

# Optional: domain name to use for authentication
# domain mydomain.net

# Strip the domain prefix from the username before authentication.
# (applies if you use pppd with chapms-strip-domain patch)
#chapms-strip-domain


# Encryption
# Debian: on systems with a kernel built with the package
# kernel-patch-mppe >= 2.4.2 and using ppp >= 2.4.2, ...
# {{{
refuse-pap
refuse-chap
refuse-mschap
# Require the peer to authenticate itself using MS-CHAPv2 [Microsoft
# Challenge Handshake Authentication Protocol, Version 2] authentication.
require-mschap-v2
# Require MPPE 128-bit encryption
# (note that MPPE requires the use of MSCHAP-V2 during authentication)
require-mppe-128
# }}}




# Network and Routing

# If pppd is acting as a server for Microsoft Windows clients, this
# option allows pppd to supply one or two DNS (Domain Name Server)
# addresses to the clients. The first instance of this option
# specifies the primary DNS address; the second instance (if given)
# specifies the secondary DNS address.
# Attention! This information may not be taken into account by a Windows
# client. See KB311218 in Microsoft's knowledge base for more information.
#ms-dns 10.0.0.1
ms-dns 192.168.0.1

# If pppd is acting as a server for Microsoft Windows or "Samba"
# clients, this option allows pppd to supply one or two WINS (Windows
# Internet Name Services) server addresses to the clients. The first
# instance of this option specifies the primary WINS address; the
# second instance (if given) specifies the secondary WINS address.
#ms-wins 10.0.0.3
ms-wins 192.168.0.1

# Add an entry to this system's ARP [Address Resolution Protocol]
# table with the IP address of the peer and the Ethernet address of this
# system. This will have the effect of making the peer appear to other
# systems to be on the local ethernet.
# (you do not need this if your PPTP server is responsible for routing
# packets to the clients -- James Cameron)
proxyarp

# Debian: do not replace the default route
nodefaultroute


# Logging

# Enable connection debugging facilities.
# (see your syslog configuration for where pppd sends to)
#debug

# Print out all the option values which have been set.
# (often requested by mailing list to verify options)
#dump


# Miscellaneous

# Create a UUCP-style lock file for the pseudo-tty to ensure exclusive
# access.
lock

# Disable BSD-Compress compression
nobsdcomp
auth

Next, edit /etc/ppp/chap-secrets. It should look like this:

# Secrets for authentication using CHAP
# client	server	secret			IP addresses
user  pptp-vpn  abcdefg  "*"
Now do:
/etc/init.d/pptpd restart

You must be able now to setup a vpn connection to your new server from the inside of your firewall as "user" with password "abcdefg" (without the quotes) Change this initial username and password and add some users, if you like. Maybe you'll have to reboot some machines to make it work.

Now open your firewall for incoming vpn connections. To do this, set your /etc/shorewall/rules as shown.

My /etc/shorewall/rules at this time:

#############################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/
# PORT PORT(S) DEST LIMIT GROUP
# PORT PORT(S) DEST LIMIT GROUP
ACCEPT net $FW tcp 25
ACCEPT net $FW tcp 443
ACCEPT net $FW tcp 993
ACCEPT net $FW udp 6277
DNAT net fw:192.168.1.1 tcp 1723
DNAT net fw:192.168.1.1 47
#
# Accept DNS connections from the firewall to the network
#
DNS/ACCEPT $FW net
ACCEPT $FW net all
ACCEPT $FW loc all
ACCEPT loc $FW all
#
# Accept SSH connections from the local network for administration
#
SSH/ACCEPT loc $FW
#
# Allow Ping from the local network
#
Ping/ACCEPT loc $FW
#
# Reject Ping from the "bad" net zone.. and prevent your log from being flooded..
#
Ping/REJECT net $FW
ACCEPT $FW loc icmp
ACCEPT $FW net icmp
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
To complete this step, do:
/etc/init.d/shorewall restart

So now your customers will be able to do their (computer network related) job at home as well.

Note, that this only makes sense when your server has a reliable broadband connection to the internet, which in The Netherlands is the defacto standard, even for very tiny offices and most home addresses. In this respect we are way ahead of the rest of the world.

Now edit your /etc/MailScanner/spam.assassin.prefs.conf and add the following lines at the bottom:

score RCVD_IN_SORBS_WEB 10
score RCVD_IN_WHOIS_INVALID 10
score RCVD_IN_WHOIS_BOGONS 10
score RCVD_IN_NJABL_PROXY 10
score RCVD_IN_DSBL 10
score RCVD_IN_XBL 10
score RCVD_IN_BL_SPAMCOP_NET 10
score RCVD_IN_SORBS_DUL 10
score SARE_LWSYMFMT 3
score SARE_MLB_Stock4 3
score SARE_BAYES_5x8 3
score SARE_BAYES_6x8 3
score URIBL_SC_SURBL 10
score URIBL_WS_SURBL 10
score URIBL_PH_SURBL 10
score URIBL_OB_SURBL 10
score URIBL_AB_SURBL 10
score URIBL_JP_SURBL 10
score URIBL_SBL 10
score ALL_TRUSTED 0

Now clean your /root directory. That's where all the downloads went.

Samba is installed. As every setup of Samba is unique, I can't help you out here. Don't know how to do it? This is a good starting point.

To complete all of this, do:

/etc/init.d/mailscanner restart

Now watch the spam reports in the headers of incoming mail (but make sure your users agree to this, as you will be violating some postal and maybe other laws) to adjust the last edit (and add some) to make it work as you like. Especially false negatives and even more false positives should draw your attention. When you are done you may wish to send most spam, if not all, to /dev/null.

Make this spy yob easy:Create a special account to which you send a copy of all mail handled by your server. Let's assume you create this user and call it "spy" (without quotes) and you have given spy a line in /etc/postfix/virtual, (like "[email protected]    spy", without quotes). Next do:

postmap /etc/postfix/virtual

Now send spy a welcome message, as a rule of thumb, and check that spy's account is fully operational. Next do:

postconf -e 'always_bcc = spy' 

DONE!


Panels
  1. Die 5 besten Anrufsoftwarelösungen für Ihr Unternehmen

  2. Richten Sie Ubuntu-Server 6.10 als Firewall/Gateway für Ihre Kleinunternehmensumgebung ein

  3. So richten Sie eine Weiterleitung für Ihre Website in cPanel ein

  4. So richten Sie eine Firewall mit UFW unter Ubuntu 16.04 ein

  5. 7 Vorteile der Verwendung von Virtual Private Server für Ihr Unternehmen

So konfigurieren Sie ONLYOFFICE CRM für Ihre geschäftlichen Anforderungen

Ich brauche eine Webhosting-Lösung für mein kleines Unternehmen. Wie wähle ich?

So richten Sie einen Linux-Killswitch für VPNs ein

So richten Sie eine Firewall auf Ihrem Linux-Server ein

Die 15+ Linux-Firewall-Software zum Schutz Ihres Linux-Systems

Linux für Unternehmen:Erweitern Sie Ihr Unternehmen mit diesen Anwendungen