rico55
Goto Top

IPForwarding Firewall zur interne IP

Hallo,


ich habe eine Debian Kiste als Firewall bei mir laufen, die 2 Modems auf verschiedenen Leitungen bedient.

Außerdem habe ich einen Datenbankservice bei mir intern laufen (192.168.11.2) der immer von außen erreichbar sein soll.

Ich möchte nun das alle Anfragen die an der Debian Firewall ankommen auf Port 1521 , dass die weiter geforwarded

werden auf meine interne IP 192.168.11.2.

Bisher klappt es irgendwie nicht und ich weiß nicht warum.

Ich habe folgendes probiert


1 iptables -A PREROUTING -t nat -i eth1 -p tcp --dport 1521-j DNAT --to 192.168.1.50:1521
2 iptables -A FORWARD -p tcp -m state --state NEW -d 192.168.11.2 1--dport 1521-i eth1 -j ACCEPT


was mache ich falsch?

Content-Key: 196934

Url: https://administrator.de/contentid/196934

Printed on: April 19, 2024 at 16:04 o'clock

Member: SlainteMhath
SlainteMhath Jan 14, 2013 at 14:15:10 (UTC)
Goto Top
Moin,

wieso verwendest du im PREROUTING Statement die IP 192.168.1.50, und im FORWARD die .11.2?

lg,
Slainte
Member: Alchimedes
Alchimedes Jan 14, 2013 updated at 20:55:37 (UTC)
Goto Top
Hallo,

Du musst im Kernel das ip_forwarding einschalten.

mit sysctl net.ipv4.ip_forward schaust Du wie der Status ist.
Oder kannst Du auch unter /proc schauen.

cat /proc/sys/net/ipv4/ip_forward

wenn jeweils=0 dann ist ip_forwarding nicht erlaubt.

Um es zu aktivieren z.B :

echo 1 > /proc/sys/net/ipv4/ip_forward

jedoch nach einem Reboot ist die Einstellung futsch.
Deshalb in der /etc/sysctl.conf:

net.ipv4.ip_forward = 1

danach sysctl -p /etc/sysctl.conf

Und bei Debian noch: /etc/init.d/procps.sh restart

Gruss
Member: Rico55
Rico55 Jan 14, 2013 at 22:52:10 (UTC)
Goto Top
Hallo nochmal,


@slainte

Du hast Recht. Das habe ich korrigiert, leider hat es nichts geholfen.

Folgendermaßen sieht meine /etc/network/interfaces aus


user@firewall:~# cat /etc/network/interfaces
  1. This file describes the network interfaces available on your system
  2. and how to activate them. For more information, see interfaces(5).

  1. The loopback network interface
auto lo
iface lo inet loopback

  1. The primary network interface
#allow-hotplug eth1
#iface eth1 inet dhcp

auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.200
netmask 255.255.255.0

auto eth0:1
allow-hotplug eth0:1
iface eth0:1 inet static
address 192.168.1.100
netmask 255.255.255.0

auto eth1
allow-hotplug eth1
iface eth1 inet static
address 197.70.130.93
netmask 255.255.255.0
up ip route flush table TELEKOM

up ip route add 197.70.130.0/24 dev $IFACE src 197.70.130.93 table TELEKOM
up ip route add default via 197.70.130.94 table TELEKOM
up ip rule add from 197.70.130.93 table TELEKOM

up ip route add default via 197.70.130.94 src 197.70.130.93 metric 2
up ip route add 197.70.120.0/19 via 197.70.130.94 dev $IFACE src 197.70.130.93 metric 1
up ip route add 188.111.108.253 via 197.70.130.94 dev eth1
down ip route flush table TELEKOM
down ip rule del from 197.70.130.93 table TELEKOM
down ip route del default via 197.70.130.94 metric 2
down ip route del 197.70.120.0/19 via 197.70.130.94 dev $IFACE src 197.70.130.93 metric 1
down ip route del 188.111.108.253 via 197.70.130.94 dev eth1
down ip route add 192.168.2.0/24 via 197.70.130.94 src 197.70.130.93


auto eth1:1
allow-hotplug eth1:1
iface eth1:1 inet static
address 197.70.130.90
netmask 255.255.255.0

auto eth1:2
allow-hotplug eth1:2
iface eth1:2 inet static
address 197.70.130.92
netmask 255.255.255.0

#auto eth2
#allow-hotplug eth2
#iface eth2 inet manual
  1. pre-up ifconfig $IFACE up
  2. post-down ifconfig $IFACE down

auto eth2.7
allow-hotplug eth2.7
iface eth2.7 inet manual
  1. pre-up ifconfig $IFACE up
  2. post-down ifconfig eth2 down

auto dsl-provider
iface dsl-provider inet ppp
pre-up /sbin/ifconfig eth2.7 up # line maintained by pppoeconf
provider dsl-provider

Und folgendes habe ich nun gemacht

1 iptables -A PREROUTING -t nat -i eth1 -p tcp --dport 1521-j DNAT --to 192.168.1.50:1521
2 iptables -A FORWARD -p tcp -m state --state NEW -d 192.168.1.50 1--dport 1521-i eth1 -j ACCEPT

Hat leider nichts gebracht.


@Alchimedes

Hallo,

das hatte ich auch schon geprüft.
Das forwarding steht/stand auf 1

VG
Mike
Mitglied: 16568
16568 Jan 16, 2013 at 23:42:28 (UTC)
Goto Top
Wenn ich das richtig verstanden habe:
iptables -t nat -I PREROUTING -d 188.xx.xx.251 -j DNAT --to 192.xxx.xxx.xxx
iptables -t nat -I POSTROUTING -s 192.xxx.xxx.xxx -j SNAT --to 188.xxx.xxx.xxx
sysctrl.conf:
net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=1
net.ipv4.icmp_echo_ignore_broadcasts=1


Lonesome Walker