IPTABLES PREROUTING Frage

Einrichten des lokalen Netzes, Verbindung zu anderen Computern und Diensten.
Antworten
thomas99
Beiträge: 2
Registriert: 08.09.2012 08:25:54

IPTABLES PREROUTING Frage

Beitrag von thomas99 » 08.09.2012 08:39:00

Hallo Zusammn,
ich versuche auf einer Firewall alle eingehenden Traffic einer IP auf Port 80 zu einer anderen IP auch Port 80 weiterzuleiten. Die Weiterleitung klappt nur, wenn ich mit VPN verbunden bin.

Code: Alles auswählen

*nat
:PREROUTING ACCEPT [1:806400]
#:PREROUTING ACCEPT [14550:806400]
:POSTROUTING ACCEPT [9969:520884]
:OUTPUT ACCEPT [5:372]
#-A PREROUTING -d 1.2.3.4 -p tcp -m tcp --dport 80 -j DNAT --to-destination 5.6.7.8:80
COMMIT
Nach meinen Verständins wird alles von iP 1.2.3.4 mit Port 80 zu 5.6.7.8 Port 80 weitergeleitet. Na das klappt schon eben nur über die VPN.

EIne Idee, wo es hier hängt?

Danke
Thomas

PinguFan
Beiträge: 164
Registriert: 10.10.2009 16:07:03

Re: IPTABLES PREROUTING Frage

Beitrag von PinguFan » 08.09.2012 09:30:04

Hallo thomas99,
mit Deinen Regeln kann ich nicht viel anfnagen.
Bei mir sieht ne Firewall zum Blocken, Inputen und Forwarden so aus:

Code: Alles auswählen

#!/bin/sh

### ALLE REGELN L Ö S C H E N ###
/sbin/iptables -F
/sbin/iptables -X
/sbin/iptables -t nat -F


### A L L E S B L O C K I E R E N ###
/sbin/iptables --policy INPUT DROP
/sbin/iptables --policy FORWARD DROP
/sbin/iptables --policy OUTPUT DROP

### I N P U T ###
#Port für whois (43), http (80), NTP (123), DNS (53) offen zu halten, NTP,
DNS benutzt UDP
/sbin/iptables --append INPUT --in-interface eth0 --jump ACCEPT

#/sbin/iptables --append INPUT --in-interface ppp+ \
# --protocol tcp --source-port 43 --jump ACCEPT

#/sbin/iptables --append INPUT --in-interface ppp+ \
# --protocol tcp --source-port 80 --jump ACCEPT

/sbin/iptables --append INPUT --in-interface ppp+ \
--protocol udp --source-port 53 --jump ACCEPT

/sbin/iptables --append INPUT --in-interface ppp+ \
--protocol udp --source-port 123 --jump ACCEPT

### F O R W A R D I N G ###
#Port für ssh (22), whois (43), www (80), NTP (123), https (443), e-Mail
(465 u. 993),
#VPN (1723), ntp per java (5076), Skype (61161) für tcp öffnen

/sbin/iptables --table nat --append POSTROUTING --out-interface ppp+ \
--jump MASQUERADE

/sbin/iptables --append FORWARD --protocol tcp \
-m multiport --ports 22,43,80,443,465,993,1723,5076 --jump ACCEPT

/sbin/iptables --append FORWARD --protocol udp \
--source-port 123 --jump ACCEPT

/sbin/iptables --append FORWARD --protocol gre --jump ACCEPT
ppp+ ist mein Internetzugang, ne Fritzcard.
eth0 ist die Netzwerkkarte für LAN.
Alles andere dürfte selbstredend sein.
In diesen Regeln jetzt noch ne IP-Adresse unterzubringen, ist bestimmt irgendwo beschrieben.
Gruss PingFan

Cae
Beiträge: 6349
Registriert: 17.07.2011 23:36:39
Wohnort: 2130706433

Re: IPTABLES PREROUTING Frage

Beitrag von Cae » 08.09.2012 15:23:11

thomas99 hat geschrieben:Die Weiterleitung klappt nur, wenn ich mit VPN verbunden bin.
Und jetzt sollen wir raten, wie dein VPN aussieht, wo der Kram hin soll und herkommt, welche Netze und Interfaces herumschwirren? Die DNAT-Regel wird so funktionieren wie erwartet.

Gruß Cae
If universal surveillance were the answer, lots of us would have moved to the former East Germany. If surveillance cameras were the answer, camera-happy London, with something like 500,000 of them at a cost of $700 million, would be the safest city on the planet.

—Bruce Schneier

thomas99
Beiträge: 2
Registriert: 08.09.2012 08:25:54

Re: IPTABLES PREROUTING Frage

Beitrag von thomas99 » 09.09.2012 10:42:20

Hi Cae,

Stimmt - da fehlen noch ein paar Infos. Ich muss mich selber erst einmal mit der Firewall auseinandersetzen. Das Ding wurde vor einiger Zeit von einem Andern aufgesetzt.
Hat zwei Nics, eingehender Traffic und das interne Netz.
Also die VPN blockt alles, bis auf icmp.
Unter ppp gibt es „filters“ wo die „active-filter“ definiert sind – hier müsste eine Regel rein, um den Port 80 auf einer IP nicht zu blocken, damit die Weiterleitung klappt?
Sehe ich das richtig?

DANKE
Ciao Thomas

Antworten