Mysql hinter Firewall

Kesar_Neron

Kesar_Neron

Tripel-As
Hallo zusammen,

ich habe hier einen MySQL Server auf einem OpenBSd System laufen.
Dieses System möchte ich nun rudimentär absichern.

Dazu wollte ich einfach die im Netzwerk nicht notwendigen Dienste mit einer Firewall absichern.

Das gelingt mir auch soweit... das einzige Problem, was ich habe ist, dass ich mich nachdem ich die pf Firewall einschalte nicht mehr mit dem MySQL Server Verbinden kann. Ein Portscan zeigt mir, dass der Dienst nicht offen ist.

Schaut euch mal bitte meine pf.conf an und sagt mir, was ich falsch mache.

Danke für eure Hilfe.

Code:
#	$OpenBSD: pf.conf,v 1.29 2005/08/23 02:52:58 henning Exp $
#
# See pf.conf(5) and /usr/share/pf for syntax and examples.
# Remember to set net.inet.ip.forwarding=1 and/or net.inet6.ip6.forwarding=1
# in /etc/sysctl.conf if packets are to be forwarded between interfaces.

#ext_if="ext0"
#int_if="int0"

#table <spamd> persist
#table <spamd-white> persist

#set skip on { lo $int_if }

#scrub in

#nat on $ext_if from !($ext_if) -> ($ext_if:0)
#rdr pass on $int_if proto tcp to port ftp -> 127.0.0.1 port 8021
#rdr pass on $ext_if proto tcp from <spamd> to port smtp \
#	-> 127.0.0.1 port spamd
#rdr pass on $ext_if proto tcp from !<spamd-white> to port smtp \
#	-> 127.0.0.1 port spamd

#block in
pass out keep state

#antispoof quick for { lo $int_if }

#pass in on $ext_if proto tcp to ($ext_if) port ssh keep state
#pass in on $ext_if proto tcp to ($ext_if) port > 49151 user proxy keep state
#pass in log on $ext_if proto tcp to ($ext_if) port smtp keep state
#pass out log on $ext_if proto tcp from ($ext_if) to port smtp keep state

block in on dc0 all

pass in on dc0 proto tcp from any to any port ftp
pass in on dc0 proto tcp from any to any port ssh
pass in on dc0 proto tcp from any to any port www
pass in on dc0 proto tcp from any to any port 445
pass in on dc0 proto {tcp,udp} from any to any port >1024
pass in on dc0 proto tcp from any to any port 3306

pass in on lo proto {tcp,udp,icmp} all
pass out on lo proto {tcp,udp,icmp} all
pass out on dc0 from any to any
 
Läuft denn MySQL überhaupt auf dem Default-Port 3306 oder ist das evtl. auch "verbogen"?
 
Japa

Hi,

also bisher konnte ich mich mit den Defaulteinstellungen verbinden. Nur nachdem ich die Firewall aktiviert habe geht es nicht mehr.

Hier mal ein auzug aus nmap:
127.0.0.1
Code:
Starting nmap 3.81 ( http://www.insecure.org/nmap/ ) at 2006-06-08 14:30 GMT
Interesting ports on localhost.intra.cjd.de (127.0.0.1):
(The 1652 ports scanned but not shown below are in state: closed)
PORT     STATE SERVICE
13/tcp   open  daytime
21/tcp   open  ftp
22/tcp   open  ssh
25/tcp   open  smtp
37/tcp   open  time
80/tcp   open  http
113/tcp  open  auth
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
587/tcp  open  submission
3306/tcp open  mysql

und hier die externe Ip-Addresse:
Code:
Starting nmap 3.81 ( http://www.insecure.org/nmap/ ) at 2006-06-08 14:31 GMT
Interesting ports on 10.40.4.153:
(The 1654 ports scanned but not shown below are in state: closed)
PORT     STATE SERVICE
13/tcp   open  daytime
21/tcp   open  ftp
22/tcp   open  ssh
37/tcp   open  time
80/tcp   open  http
113/tcp  open  auth
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
3306/tcp open  mysql

natürlich mit deaktivierter Firewall.
 
du musst in deiner "my.cnf" die Variable "bind-to localhost" oder so ähnlich auskommentieren. Danach mysqld neustarten und schon kommst du von außen "ran".
 
hab isch leider nisch

Hallo und danke für die Antwort.
Leider habe ich auf dem gesamten System keine my.cnf. zumindest sagt mir das find / -name my.cnf -print


Gruß
 
find / -name "*.cnf"

Vielleicht ist ja was dabei :-). Irgendwie wird ja dein mysqld konfiguriert.
 
eine 10'er ip-adresse extern? bist du dir da ganz sicher?

wie versuchst du dich den zu verbinden? der dienst scheint ja erreichbar zu sein.
bedenke das eine anmeldung per default nur localhost möglich ist. alle user werde nur mit localhost ans quelle angelegt. der user muss das recht haben sich auch von remote (hostname oder @ für alle) aus anzumelden. evtl. ist nur das dein problem?

typische fehlermeldung dafür wäre:
ERROR 1130: Host 'x.x.x.x' is not allowed to connect to this MySQL server

board-suche schon mal hier benutzt? wohl nicht, sonst hättest du evtl. auch
das (http://www.unixboard.de/vb3/showthread.php?t=14030) gefunden :D
 
Zuletzt bearbeitet:
Ok ok.. ich sehs ein.. ich hab mich falsch ausgedrückt...

Der Server hat nur eine IP-Adresse, steht in einem Intranet.. also kein wirklich EXTERNES Device...

Ich arbeite schon ne ganze weile mit dem System. Ich verbinde mich mit dem Mysql-Administrator, Query-Browser, etc. Das funktioniert ALLES bestens...

Mein Problem ist, dass sobald ich pfctl -e mache ich mich eben nicht mehr verbinden kann. Da ich relativ neu im Bereich BSD bin, denke ich, dass es an meiner pf.conf liegt.

Also, Verbindung ohne Firewall ABSOLUT KEIN PROBLEM... Verbidnung mit Firewall nicht möglich, jedenfall mit clientprogrammen wie o.g.!

Gruß
 
slasher schrieb:
in Beitrag #4 habe ich doch genau das vermutet :-).

das hast du nicht ... deine bemerkung geht auf den ganzen server.
da mit nicht klar ist was er genau für ein fehlerbild hat vermutete ich das es nur daran liegt das der user, mit dem er sich anmelden will, das nur von localhost aus darf.
ich meinte also das feld "host" in der mysql user tabelle.

der server staret aber nicht evtl. mit "--skip-networking" oder? dann würde die verbindung nur über die lokalen sockets gegen und nicht mehr über tcp.
 
ich kenne jetzt was genau das "pfctl" macht aber bekommst du antwort wenn mal:
telnet <hostname> 3306
danach aufrufst?
 
probier doch mal folgende pf.conf:
Code:
icmp_types = "echoreq"
set block-policy drop
block in log all
pass  on lo0

pass  in  on dc0 proto tcp from any to any port 21 keep state
pass  in  on dc0 proto tcp from any to any port 22 keep state
pass  in  on dc0 proto tcp from any to any port 80 keep state
pass  in  on dc0 proto tcp from any to any port 445 keep state
pass  in  on dc0 proto tcp from any to any port 3306 keep state
pass in on dc0 proto {tcp,udp} from any to any port > 1024

pass  out on dc0 proto { tcp, udp } all keep state

die Regeln mit Befehl:
Code:
pfctl -Fa -f /etc/pf.conf
neuladen. Versuch das mal, aber kopier deine alte pf.conf vorher an einen sicheren Platz :-).
 
Zuletzt bearbeitet:
leider auch nich

Hallo zusammen

@ slasher: Leider hat das auch nicht weitergeholfen.

Ich habe die komplette pf.conf durch das von dir genannte ersetzt. Leider auch ohne ergebnis.... sobald ich mit pfctl -e die Firewall aktiviere, ist alles freigegebene bis auf MySQL erreichbar.

Dennoch vielen Dank.

Gruß

----------------------------------------------------
EDIT:

Ich konnte das Problem lösen. Auch wenn ich nach wie vor keine Ahnung habe, wo genau jetzt der unterschied liegen soll.

Hier mal das Regelwerk, dass funktioniert:

block in all

pass in on dc0 proto tcp from any to any port ftp
pass in on dc0 proto tcp from any to any port ssh
pass in on dc0 proto tcp from any to any port www
pass in on dc0 proto tcp from any to any port 445
pass in on dc0 proto {tcp,udp} from any to any port >1024
pass in on dc0 proto tcp from any to any port 3306

pass on lo all
pass out on lo proto {tcp,udp,icmp} all
pass out on dc0 from any to any
 
Zuletzt bearbeitet:

Ähnliche Themen

ip6tables Problem

[SOLVED][CentOS 7] Samba server nicht erreichbar trotz firewall regeln.

PF mit NAT OpenBSD 5.4

pf problem

Bruteforce-Angriffe auf FTP mit PF verhindern

Zurück
Oben