Optimales Gateway

Post Reply
Message
Author
dhartmann
Posts: 25
Joined: 17. Sep 2004 10:18

Optimales Gateway

#1 Post by dhartmann »

Hallo, hatt jemand ne idee wie ein optimales linux gateway auf debian basis aussieht?
Ich hatte mir das bisher so vorgestellt

- iptables firewall
- squid proxy
- clamav antivirus

als grundausstattung

ich habe das soweit auch schon installiert nur die konfiguration von iptables und squid macht mir noch kopfzerbrechen;)

ich suche eine iptables konfiguration die ftp, http, https, icmp(ping), ssh von innen 10.0.0.0 nach aussen zuläst. Andersrum soll alles zu bleiben. Ausser port 80 muss glaubich für squid offen bleiben.
Habe mich an die squid Anleitung von http://www.proesdorf.de/linux/squid_conf.htm gehalten, habe aber leider noch nicht das gewünschte ergebenis.

Vieleicht hat ja jemand eine passende konfiguration parat:)
Wie würde eine optimale konfiguration von squid und iptables sein?


hoffe mir kann jemand auf die sprunge helfen...

User avatar
Lateralus
prolinux-forum-admin
Posts: 1238
Joined: 05. May 2004 7:35

#2 Post by Lateralus »

Du brauchst keinen Port von außen offen halten.

Hiermit kannst du dir vielleicht erstmal grundsätzlich ein kleines Skript schaffen, mit dem du dann weiterarbeiten kannst. Es gab auch noch irgendwo eine deutsche Seite, auf der man sich so ein Skript schreiben lassen konnte, leider finde ich die gerade nicht.

http://iptables-script.dk/index1.php

klopskuchen
prolinux-forum-admin
Posts: 1444
Joined: 26. Jun 2004 21:18
Contact:

#3 Post by klopskuchen »

> Vieleicht hat ja jemand eine passende konfiguration parat
http://www.squid-handbuch.de/hb/index.html (falls noch nicht bekannt)

Die Konfiguration musst du dir selbst bauen. Neben Cacheregeln ist sie auch abhängig von den zur Verfügung stehenden Ressourcen. Das Gateway selbst ist keine wilde Sache. Auf dem Clienten das Gateway als defaultroute eintragen und ip-masquerading auf dem Gateway aktivieren.

MfG, Klopskuchen
When all else fails, read the instructions .

dhartmann
Posts: 25
Joined: 17. Sep 2004 10:18

#4 Post by dhartmann »

ich werde das mal ausprobieren..., aber was haltet ihr von clamav antivirus auf dem gateway? Ich brauche einen free antivirus scanner der auch komerziell eingesetzt werden darf, da kommt eigentlich nur gpl software in frage oder?

klopskuchen
prolinux-forum-admin
Posts: 1444
Joined: 26. Jun 2004 21:18
Contact:

#5 Post by klopskuchen »

Auf Anhieb fallen mir da noch Bitdefender und Kaspersky ein die auf Linux laufen. Diese beiden sind lizenzpflichtig. Auch wenn ClamAV unter der GPL läuft, so haben die Entwickler sicher nichts gegen einen Obolus einzuwenden. ;)

MfG, Klopskuchen
When all else fails, read the instructions .

dhartmann
Posts: 25
Joined: 17. Sep 2004 10:18

#6 Post by dhartmann »

was haltet ihr von der iptables conf?


#!/bin/sh
# Einfache Paketfilter-Firewall für LANs
# optional: ssh-Fernwartungszugriff vom Internet aus
# optional: Support für transparenten Squid-HTTP-Proxy

# hier das externe Interface definieren
# Modem/DSL arbeitet mit ppp0, ppp1, ...
# EXTIF=ppp+
# ISDN arbeitet mit ippp0, ippp1, ...
# EXTIF=ippp+
EXTIF=eth1+

# meine eigene (interne) IP
# kann man mit ifconfig ermitteln, z.B. eth1 -> 10.10.10.1 oder eben 192.168.100.1
MYIP=10.3.25.107

# _____
#Incoming / \ Outgoing
# -->[Routing ]--->|FORWARD|------->
# [Decision] \_____/ ^
# | |
# v ____
# ___ / \
# / \ |OUTPUT|
# |INPUT| \____/
# \___/ ^
# | |
# ----> Local Process ----

# "gefälschte" IP-Adressen verhindern:
for f in /proc/sys/net/ipv4/conf/*/rp_filter; do
echo 1 > $f
done

# setzen der Policy der Standard-Regelketten
# von aussen nach innen wird eine "deny all, allow some"-Strategie verwendet
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

# löschen aller bereits definierten Regeln (flush)
iptables -F INPUT
iptables -F FORWARD
iptables -F OUTPUT

# neue Regelkette "no-conns-from-extif" anlegen
iptables -N no-conns-from-extif
# falls es "no-conns-from-extif" schon gab: leeren per flush
iptables -F no-conns-from-extif


# icmp-Pakete (z.B. ping) generell zulassen (nur für nicht-DoS-gefährdete Anwendung)
iptables -A no-conns-from-extif -p icmp -j ACCEPT

# lo-Interface zulassen
iptables -A no-conns-from-extif -i lo -j ACCEPT


# Pakete, die zu bereits bestehenden Verbindungen gehören (oder damit zusammenhängen) erlauben
iptables -A no-conns-from-extif -m state --state ESTABLISHED,RELATED -j ACCEPT

# neue Verbindungen nur dann erlauben, wenn sie NICHT über das externe Interface reinkommen
iptables -A no-conns-from-extif -m state --state NEW -i ! $EXTIF -j ACCEPT

#optional: ssh-Port nach außen aufmachen für Fernwartung vom Internet aus
iptables -A no-conns-from-extif -m state --state NEW -i $EXTIF -p tcp --dport 22 -j ACCEPT

#optional: Port 80 nach außen aufmachen für Webserver
#iptables -A no-conns-from-extif -m state --state NEW -i $EXTIF -p tcp --dport 80 -j ACCEPT


#optional: VNC für mehrere Rechner im LAN
#iptables -A no-conns-from-extif -i $EXTIF -p tcp -m state --state NEW -m tcp --dport 5800 -j ACCEPT
#iptables -A no-conns-from-extif -i $EXTIF -p tcp -m state --state NEW -m tcp --dport 5900 -j ACCEPT
#iptables -A no-conns-from-extif -i $EXTIF -p tcp -m state --state NEW -m tcp --dport 5801 -j ACCEPT
#iptables -A no-conns-from-extif -i $EXTIF -p tcp -m state --state NEW -m tcp --dport 5901 -j ACCEPT
#iptables -A no-conns-from-extif -i $EXTIF -p tcp -m state --state NEW -m tcp --dport 5802 -j ACCEPT
#iptables -A no-conns-from-extif -i $EXTIF -p tcp -m state --state NEW -m tcp --dport 5902 -j ACCEPT
#iptables -A no-conns-from-extif -i $EXTIF -p tcp -m state --state NEW -m tcp --dport 5803 -j ACCEPT
#iptables -A no-conns-from-extif -i $EXTIF -p tcp -m state --state NEW -m tcp --dport 5903 -j ACCEPT

#optional: PC-Anywhere ab >= 9.0
#iptables -A no-conns-from-extif -i $EXTIF -p tcp -m state --state NEW -m tcp --dport 5631 -j ACCEPT
#iptables -A no-conns-from-extif -i $EXTIF -p udp -m udp --dport 5632 -j ACCEPT

# unerwünschte Pakete in's Log schreiben (max. aber 1 Eintrag pro Sekunde, um DoS zu verhindern)
iptables -A no-conns-from-extif -i $EXTIF -m limit --limit 1/sec -j LOG --log-prefix "Bad packet from $EXTIF :"
iptables -A no-conns-from-extif -i ! $EXTIF -m limit --limit 1/sec -j LOG --log-prefix "Bad packet not from $EXTIF :"

# ... und verwerfen (würde auch ohne Regel durch Policy passieren).
iptables -A no-conns-from-extif -j DROP

# PaketFilter-Regelkette für hereinkommende und durchlaufende Pakete anspringen.
iptables -A INPUT -j no-conns-from-extif
iptables -A FORWARD -j no-conns-from-extif

# _____ _____
# / \ / \
# PREROUTING -->[Routing ]----------------->POSTROUTING----->
# \D-NAT/ [Decision] \S-NAT/
# | ^
# | |
# | |
# | |
# | |
# | |
# | |
# --------> Local Process ------

# Modul für NAT laden
modprobe iptable_nat

# Masquerading (spezielle Form von SNAT) aktivieren
iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE

#optional: VNC-Zugriff auf internen PC
#iptables -t nat -A PREROUTING -i $EXTIF -p tcp -m tcp --dport 5800 -j DNAT --to-destination 192.168.100.2:5800
#iptables -t nat -A PREROUTING -i $EXTIF -p tcp -m tcp --dport 5900 -j DNAT --to-destination 192.168.100.2:5900
#iptables -t nat -A PREROUTING -i $EXTIF -p tcp -m tcp --dport 5801 -j DNAT --to-destination 192.168.100.14:5800
#iptables -t nat -A PREROUTING -i $EXTIF -p tcp -m tcp --dport 5901 -j DNAT --to-destination 192.168.100.14:5900
#iptables -t nat -A PREROUTING -i $EXTIF -p tcp -m tcp --dport 5802 -j DNAT --to-destination 192.168.100.15:5800
#iptables -t nat -A PREROUTING -i $EXTIF -p tcp -m tcp --dport 5902 -j DNAT --to-destination 192.168.100.15:5900
#iptables -t nat -A PREROUTING -i $EXTIF -p tcp -m tcp --dport 5803 -j DNAT --to-destination 192.168.100.16:5800
#iptables -t nat -A PREROUTING -i $EXTIF -p tcp -m tcp --dport 5903 -j DNAT --to-destination 192.168.100.16:5900

#optional: PC-Anywhere-Zugriff (ab PCA >=9) auf internen PC
#iptables -t nat -A PREROUTING -i $EXTIF -p tcp -m tcp --dport 5631 -j DNAT --to-destination 192.168.100.2:5631
#iptables -t nat -A PREROUTING -i $EXTIF -p udp -m udp --dport 5632 -j DNAT --to-destination 192.168.100.2:5632

# IP-Forwarding einschalten
echo 1 > /proc/sys/net/ipv4/ip_forward

# optional:
# sende hereinkommende Port-80 Web-Zugriffe auf unseren (transparenten) Squid Proxy
iptables -t nat -A PREROUTING -p tcp -d ! $MYIP --dport 80 -j REDIRECT --to-port 3128
# bitte beachten: Squid muss entsprechend konfiguriert werden, damit er weiss,
# dass er ein transparenter Proxy ist!
# squid.conf (für Squid v2.3):
# http_port 3128
# httpd_accel_host virtual
# httpd_accel_port 80
# httpd_accel_with_proxy on
# httpd_accel_uses_host_header on
#
# Squid v2.4 benötigt zusätzlich diese Zeile:
# httpd_accel_single_host off


Das file habe ich im netz gefunden und funktionert, fast :wink:

allerdings funktioniert ftp über ieexplorer noch nicht richtig....
Anfangs habe ich es mit webmin versucht, aber damit komme ich noch nicht so recht klar. kann man diese iptables datei irgendwie in webmin einbinden? so dass man die regeln in webmin sieht? (zu lernzwecken)

Post Reply