Archiv verlassen und diese Seite im Standarddesign anzeigen : Portweiterleitung mit iptables
Hallo,
Ich möchte den localhost mysql Port 3306 auf eine andere IP im Netzwerk dauerhaft weiterleiten. Ich denke das geht nur mit iptables oder? Und kann mir jemand sagen welche regeln ich dafür erstellen muss?
Vielen Dank
Imox
willkommen auf dem board
Ich denke das geht nur mit iptables oder?
stichwort: PREROUTING, Forward
habe ich auch schon gesehen aber wie genau müssen die regeln aussehen? Die Beispiele die ich finde sind immer mit nat daher gehe ich davon aus das die bestimmt sind über WAN zu gehen. Das brauche ich ja aber nicht weil ich im Netzwerk bleibe.
Also ich bekomms nicht hin.
ich habe das hier ausprobiert aber kann die regeln nicht mal eintragen:
iptables -t nat -A PREROUTING --dst $EXTERNAL_IP -p tcp --dport 3306 -j DNAT --to-destination 192.168.178.12:3306
iptables -t nat -A POSTROUTING --dst 192.168.178.12 -p tcp --dport 3306 -j SNAT --to-source $EXTERNAL_IP
iptables -t nat -A OUTPUT --dst $EXTERNAL_IP -p tcp --dport 3306 -j DNAT --to-destination 192.168.178.12:3306
kann mir jemand bitte helfen?
Hi,
also gemäß diversen Anleitungen, nehmen wir diese (http://www.debuntu.org/how-to-redirecting-network-traffic-to-a-new-ip-using-iptables/), sind diese Ding nötig:
The first thing to do is do enable IP forwarding...
Then, we will add a rule telling to forward the traffic on port 1111 to ip 2.2.2.2 on port 1111...
and finally, we ask IPtables to masquerade...
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p tcp –dport 1111 -j DNAT –to-destination 2.2.2.2:1111
iptables -t nat -A POSTROUTING -j MASQUERADE
Du siehst den Unterschied?
iptables -I FORWARD -p tcp -d 192.168.178.11 --dport 3306 -j ACCEPT
iptables -t nat -A PREROUTING -i lo -p tcp --dport 3306 -j DNAT --to-destination 192.168.78.11:3306
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
das funktioniert nicht. was nun?
"es geht nicht" ist keine Fehlermeldung.
Abgesehen davon - wie versuchst Du denn, auf den "lokalen" MySQL zuzugreifen?
hab es jetzt mit xinit.d gelöst
service mysql3306
{
type = UNLISTED
flags = REUSE
socket_type = stream
protocol = tcp
user = root
wait = no
instances = UNLIMITED
port = 3306
redirect = 192.168.178.12 3306
disable = no
}
zugriff auf den mysql server ganz normal -> mysql -h 127.0.0.1 -u USER -p
Powered by vBulletin® Version 4.2.5 Copyright ©2024 Adduco Digital e.K. und vBulletin Solutions, Inc. Alle Rechte vorbehalten.