Port Forwarding mit iptables

T

TW1920

Grünschnabel
Hallo beisammen,

ich würde gerne von A nach B den SMTP Port weiterleiten - als Port Forwarding. Ich habe folgendes auf A versucht:
Code:
iptables -t nat -A PREROUTING -p tcp --dport 25 -j DNAT --to xxx.xxx.xxx.xxx
iptables -t nat -A POSTROUTING -p tcp -d xxx.xxx.xxx.xxx -j MASQUERADE
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state NEW -p tcp --dport 25 -d xxx.xxx.xxx.xxx -j ACCEPT

allerdings funktioniert das leider noch nicht. xxx.xxx.xxx.xxx ist hierbei die Ziel-IP, wo die Anfragen von Port 25 auf A bei B ebenfalls auf Port 25 ankommen sollten. Die Übersicht auf A gibt folgendes aus:
Code:
root@j336441:~# iptables -vL
Chain INPUT (policy ACCEPT 205 packets, 16233 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  any    any     anywhere             anywhere             state RELATED,ESTABLISHED
    0     0 ACCEPT     tcp  --  any    any     anywhere             xxx.xxx.xxx.xxx        state NEW tcp dpt:smtp

Chain OUTPUT (policy ACCEPT 175 packets, 18776 bytes)
 pkts bytes target     prot opt in     out     source               destination
root@j336441:~# iptables -t nat -vL
Chain PREROUTING (policy ACCEPT 50 packets, 2549 bytes)
 pkts bytes target     prot opt in     out     source               destination
    8   440 DNAT       tcp  --  any    any     anywhere             anywhere             tcp dpt:smtp to:xxx.xxx.xxx.xxx

Chain INPUT (policy ACCEPT 50 packets, 2549 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 2 packets, 148 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain POSTROUTING (policy ACCEPT 2 packets, 148 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 MASQUERADE  tcp  --  any    any     anywhere             xxx.xxx.xxx.xxx

Daraus schließe ich, dass es wohl bereits beim Prerouting zu haken/ das Paket zu hängen scheint. Allerdings konnte ich bisher nicht finden was genau der Fehler ist. Vielleicht steh ich nur grad etwas auf dem Schlauch oder übersehe ich da einfach nur was?

Vielen Dank schon mal für eure Hilfe :)

Grüße
 
Fehler gefunden:
Code:
root@j336441:~# cat /proc/sys/net/ipv4/ip_forward
0
Die Weiterleitung empfangener Pakete muss erst aktiviert werden, sonst geht da nix^^

Für alle, die das vielleicht mal brauchen oder selber drüber stolpern:

Temporär aktivieren
Code:
sysctl -w net.ipv4.ip_forward=1

Für dauerhaft der /etc/sysctl.conf folgende Zeile hinzufügen
Code:
net.ipv4.ip_forward=1

Nun funzt es :bounce:
 

Ähnliche Themen

ip6tables Problem

iptables verständniss frage, xrdp nicht erreichbar.

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

Portfreigabe Plesk + Ubuntu

Debian Routing Problem

Zurück
Oben