PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Debian Server: Imap und iptables



R3dFox80
16.06.06, 09:50
Hallo miteinander!

Ich betreibe einen Root-Debian server im Netz.
Unter anderem laeuft dort auch ein IMAP-SSL server. Der funzt auch eigentlich einwandfrei und problemlos (courier).
Jetzt hab ich mir aber mal ne kleine firewall zusammengebastelt. Sobald die aktiv ist, passiert bei meinem emailclient NACH der Authentifizierung beim oeffnen der INBOX gar nichts mehr. auf dem Server seh ich in der /var/log/mail.log zuerst folgendes:

Jun 16 09:44:36 fibspara imapd-ssl: Connection, ip=[::ffff:84.153.118.109]
Jun 16 09:44:37 fibspara imapd-ssl: LOGIN, user=fibs, ip=[::ffff:84.153.118.109], protocol=IMAP


dann dauert es einen Moment und ich sehe fuer JEDE in der INBOX befindliche Mail folgenden fehler:

Jun 16 09:43:11 fibspara postfix/cleanup[4177]: warning: connect to mysql server 127.0.0.1: Can't connect to MySQL server on '127.0.0.1' (110)
Jun 16 09:43:11 fibspara postfix/cleanup[4177]: warning: 043701A9977: virtual_alias_maps map lookup problem for root@fibspara.de
Jun 16 09:43:11 fibspara postfix/pickup[3821]: warning: maildrop/F32CB1A9978: Error writing message file
Jun 16 09:43:11 fibspara postfix/pickup[3821]: 026AF1A9977: uid=107 from=<smmsp>
Jun 16 09:43:11 fibspara postfix/cleanup[4177]: warning: 026AF1A9977: virtual_alias_maps map lookup problem for root@fibspara.de
Jun 16 09:43:11 fibspara postfix/pickup[3821]: warning: maildrop/F32CB1A9978: Error writing message file
Jun 16 09:43:28 fibspara postfix/pickup[3821]: 030F61A9977: uid=107 from=<smmsp>
Jun 16 09:43:28 fibspara postfix/cleanup[4177]: warning: 030F61A9977: virtual_alias_maps map lookup problem for root@fibspara.de
Jun 16 09:43:28 fibspara postfix/pickup[3821]: warning: maildrop/F32CB1A9978: Error writing message file
Jun 16 09:44:28 fibspara postfix/pickup[3821]: 01A3B1A9977: uid=107 from=<smmsp>


ich bin total ratlos. Was muss ich denn noch nach aussen hin oeffnen? Sobald ich meine Firewall ausschalte funktioniert wieder alles einwandfrei..


#!/bin/bash


iptables -X
iptables -F
iptables -F -t nat
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

#### NAT rules ####
# 1st IP
# block SSH port
iptables -t nat -A PREROUTING -i eth0 -d ***.***.***.*** -p tcp --dport 22 -j DROP

# 2nd IP
# allow ssh
iptables -t nat -A PREROUTING -i eth0 -d ***.***.***.*** -p tcp --dport 22 -j ACCEPT
# drop HTTP,IMAPS and SMTP. all other will be droped in socket rules below
#iptables -t nat -A PREROUTING -i eth0 -d ***.***.***.*** -p tcp --dport 80 -j DROP
#iptables -t nat -A PREROUTING -i eth0 -d ***.***.***.*** -p tcp --dport 993 -j DROP
#iptables -t nat -A PREROUTING -i eth0 -d ***.***.***.*** -p tcp --dport 25 -j DROP

# 3rd IP
# block all incoming requests for 3rd IP
iptables -t nat -A PREROUTING -i eth0 -d ***.***.***.*** -j DROP


#### Socket rules####
# SSH
iptables -I INPUT -p tcp --sport 22 -j ACCEPT
iptables -I INPUT -p tcp --dport 22 -j ACCEPT
iptables -I OUTPUT -p tcp --dport 22 -j ACCEPT
iptables -I OUTPUT -p tcp --sport 22 -j ACCEPT

# DNS
iptables -A INPUT -p udp --sport 53 -j ACCEPT

# ICMP
#iptables -A OUTPUT -p icmp -j ACCEPT

# APACHE
# HTTP
iptables -A INPUT -p tcp --sport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT

# EMAIL
#SMTP
iptables -A INPUT -i eth0 -p tcp --sport 25 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 25 -j ACCEPT
# IMAP-SSL
iptables -A INPUT -i eth0 -p tcp --dport 993 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 993 -j ACCEPT

# allow ev'thin from lo to lo
iptables -A INPUT -p all -s localhost -d localhost -j ACCEPT


Danke fuer eure Hilfe,
R3dFox

tschloss
16.06.06, 10:11
Hast du irgendwelche Maps in Mysql (Postfix, siehe /etc/postfix/main.cf oÄ) abgelegt?
Dann würde ich mich als erstes mal darum kümmern:
"Jun 16 09:43:11 fibspara postfix/cleanup[4177]: warning: connect to mysql server 127.0.0.1: Can't connect to MySQL server on '127.0.0.1' (110)"

Die restliche Lookup-Fehler hängen vielleicht daran.

Greetz
Thomas

R3dFox80
16.06.06, 10:26
Naja also die Datenbank mit den richtigen Tabellen existiert, aber wie gesagt sobald die firewall aus ist (iptables -F -X und ACCEPT ALL), funktioniert alles. d.h. an der Datenbank selber liegt es nicht.

Habe eigentlich mit der regel
iptables -A INPUT -p all -s localhost -d localhost -j ACCEPT
jeglichen Datentransfehr in lokal freigegeben..oder?

Habe vorhin mal den Mysql port nach aussen hin freigeschalten (3306), der MySQL Fehler bleibt dann weg, abre dennoch krieg ich folgendes zu sehen:

Jun 16 10:25:35 fibspara postfix/cleanup[4301]: D10051A9977: message-id=<20060616080001.D10051A9977@fibspara.internetservic eteam.com>
Jun 16 10:25:35 fibspara postfix/qmgr[2339]: D10051A9977: from=<smmsp@fibspara.de>, size=684, nrcpt=1 (queue active)
Jun 16 10:25:35 fibspara postfix/pickup[3821]: D2ED51A99AD: uid=107 from=<smmsp>
Jun 16 10:25:35 fibspara postfix/cleanup[4300]: D2ED51A99AD: message-id=<20060616082001.D2ED51A99AD@fibspara.internetservic eteam.com>



.. und im Client ( Thunderbird ) einen Timeout ;(

Zu deiner Map-Frage:

virtual_gid_maps = static:5000
virtual_uid_maps = static:5000
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual_forwardings.cf
alias_maps = hash:/etc/aliases

Mehr hab ich in der main.cf nich drinne..

tschloss
16.06.06, 13:22
Also deine Meldungen von Postfix sind ja jetzt keine Fehler/Warnings mehr sondern normale (positive) Logeinträge.
(Allerdings hat Postfix eigentlich nach einer Mysql-DB auf localhost verlangt, das würde ich bei Gelegenheit mal auskundschaften, zumal du vielleicht nicht deinen Mysql-Server von Außen erreichbar haben möchtest.
Für die beiden Maps braucht Postfix die Datenbank jedoch in jedem Fall, in der cf-Datei findest du genauere Angaben, wo er nachschlagen will)

Timeout Client:
Kommt der beim Senden oder beim IMAP Zugriff?
Hast Du es auch mal mit normalem IMAP versucht?

Funke den Hoste doch mal mit nmap von Außen an und mit netstat vom Host selbst.

Außerdem warum machst Du NAT auf einem Root-Server? Hat der keine eigene öffentliche IP?
Und einen Mailserver mit Virtual * zu betreiebn ist auch etwas komplexer als ohne. Hostest du denn virtuelle Domains?

Bin da leider auch nicht so fit, fiel mir nur eben auf.

Greetz
Thomas

R3dFox80
16.06.06, 14:49
Also deine Meldungen von Postfix sind ja jetzt keine Fehler/Warnings mehr sondern normale (positive) Logeinträge.

Achso.. die kommen aber auch nich wenn ich die firewall abstell :cool:

Timeout Client:
Kommt der beim Senden oder beim IMAP Zugriff?

Beim IMAP

Hast Du es auch mal mit normalem IMAP versucht?

Ja, habe ich: selbes Problem

Funke den Hoste doch mal mit nmap von Außen an und mit netstat vom Host selbst.

nmap:

root@redbox:/home/fr# nmap -P0 fibspara.de

Starting Nmap 4.03 ( http://www.insecure.org/nmap/ ) at 2006-06-16 14:37 CEST
Interesting ports on 217-20-127-211.internetserviceteam.com (217.20.127.211):
(The 1671 ports scanned but not shown below are in state: filtered)
PORT STATE SERVICE
80/tcp open http
993/tcp open imaps
3306/tcp closed mysql


ein netstat aufm Host zeigt mir nicht wirklich interessante Sachen:

root@fibspara(217.20.127.211):/home/fr# netstat -a |grep imap
tcp6 0 0 *:imaps *:* LISTEN
tcp6 0 0 *:imap2 *:* LISTEN
tcp6 0 0 217-20-127-211.in:imaps p5499766D.dip.t-d:46468 VERBUNDEN
tcp6 0 0 217-20-127-211.in:imaps p5499766D.dip.t-d:46465 TIME_WAIT
tcp6 0 0 localhost:imaps localhost:33639 TIME_WAIT
tcp6 0 0 localhost:imaps localhost:33638 TIME_WAIT
tcp6 0 285 217-20-127-211.in:imap2 p5499766D.dip.t-d:36178 VERBUNDEN

root@fibspara(217.20.127.211):/home/fr# netstat -nplt
Aktive Internetverbindungen (Nur Server)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:10024 0.0.0.0:* LISTEN 2020/amavisd (maste
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 2202/mysqld
tcp 0 0 0.0.0.0:6667 0.0.0.0:* LISTEN 2149/inetd
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 2337/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 2459/apache-ssl
tcp6 0 0 :::993 :::* LISTEN 2118/couriertcpd
tcp6 0 0 :::995 :::* LISTEN 2141/couriertcpd
tcp6 0 0 :::110 :::* LISTEN 2129/couriertcpd
tcp6 0 0 :::143 :::* LISTEN 2090/couriertcpd
tcp6 0 0 :::80 :::* LISTEN 10049/apache2
tcp6 0 0 :::22 :::* LISTEN 2359/sshd
tcp6 0 0 :::25 :::* LISTEN 2337/master


Außerdem warum machst Du NAT auf einem Root-Server? Hat der keine eigene öffentliche IP?

Doch, hat er, sogar 3 :) Moechte die nur trennen. Eine fuer Public sachen wie apache, imap, etc und eine fuer die Konfiguration via SSH.

Und einen Mailserver mit Virtual * zu betreiebn ist auch etwas komplexer als ohne. Hostest du denn virtuelle Domains?

Eine momentan, jap

R3dFox80
16.06.06, 18:30
***** PROBLEM SOLVED *****

also, es lag tatsaechlich am Mysql:
folgendes hat Abhilfe geschaffen:

iptables -A INPUT -p all -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -A OUTPUT -p all -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT

Danke, tschloss :)

Tomek
16.06.06, 18:34
R3dFox80: Bitte benutze in Zukunft die CODE-Tags des Forums für das Posten von Konfigurationsdateien usw.