Iptables einrichten (NAT)

trashcity

trashcity

Foren As
nachdem meine Firewall jetzt entlich so startet
möchte ich einrichten

so was will ich
eth0 = internet 195.230.xxx.xxx
eth1= lan1 192.168.1.x
eth2= lan2 192.168.2.x
eth3= lan3 192.168.3.x
eth4= dmz 192.168.254.x

so von shorewall hab ich mich schon verabschiedet ist mir zu komisch

kann mir jemand helfen damit ich Nat auf meiner Kiste zum laufem bekomme :help:
 
Also für ein einfaches Routing sollten folgende Befehle genügen
Code:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

Die regeln wer was darf mußt dann halt noch selbst anlegen :).
 
hi trashcity

ganz so trivial ist das nicht. zumal wenn da noch eine dmz mit ins spiel kommt.

die befehle fürs masquerading hat dir hopfe ja schon gepostet. damit können deine rechner im lan dann über den router ins inet.
auf den clientrechnern musst du allerdings noch die ip vom router als default gateway eintragen. ausserdem müssen die dns-server deines providers noch in die /etc/resolv.conf (auch auf den clientrechnern)

mit diesen beiden befehlen hast du, wie von hopfe schon gesagt, aber noch keinerlei filterregeln.

um diese selbst aufzustellen müsstest du schon etwas zeit in iptables investieren. nen guten einstieg findest du zum beispiel hier => http://www.linux-user.de/ausgabe/2002/05/030-firewall/firewall-4.html


eine weitere möglichkeit => du kannst dir auf folgender homepage ein skript generieren lassen.

www.harry.homelinux.org

unter iptables generator werden dir einige fragen zu deinem netz etc. gestellt, das dann generierte skript wird dir dann per mail zugesand.


Gruß HL
 
wo bitte kann ich im Kernel nat einschalten
damit ich den Nat befehl ausführen kann

und Frage noch nach dem ich ja mehrere eth´s habe gilt der befehl für alle

Code:
hera root # iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables v1.2.8: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
hera root #
 
Überprüfe einmal mit cat /usr/src/linux/.config | grep -i nat ob du nat vielleicht direkt im Kernel eingebunden hast?
 
ist jetz sich hab was im kernel vergessen
ich habs auch noch nicht gefunden

hera root # cat /usr/src/linux/.config | grep -i nat
# CONFIG_NATSEMI is not set
hera root #
 
Hallo Leute

Was mich beschäftigt ist also ich hab ein externes Interface (eth0) und drei Interne Interface(eth1 eth2 eth3)

Ich verwende aus meinen Öffentlichen IP-Adressen Pool 1 Öffentliche Adresse für meine Firewall

Und jetzt möchte ich aus jedem LAN kreis ins Internet

Der befehl NAT würde ja lauten

Code:
iptables -t nat -A POSTROUTING -o eth0 \-j SNAT --to-source xxx.xxx.xxx.xxx
(öffentliche Adresse)
so was mir jetzt aber so komisch vor kommt ist muss ich da nicht meine internen Interfaces angeben?
 
und ein par stunden später

Irgendwie gehen bei mir einige Sachen einfach nicht

Auszug aus http://www.gentoo.org/doc/de/gentoo-security.xml#doc_chap12
Nun sehen wir uns die Zustandsmaschinerie in iptables an. Wenn wir eine Prüfung bezüglich des Verbindungszustandes an eth0 haben wollen, könnten wir dies folgendermassen aktivieren:
Code listing 12.3: Pakete die zu einer bereits bestehenden Verbindung gehören akzeptieren
Code:
# iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

Da kommt bei mir
Code:
hera etc # iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables: No chain/target/match by that name
hera etc #
 
hi

trashcity schrieb:
Hallo Leute

Was mich beschäftigt ist also ich hab ein externes Interface (eth0) und drei Interne Interface(eth1 eth2 eth3)

Ich verwende aus meinen Öffentlichen IP-Adressen Pool 1 Öffentliche Adresse für meine Firewall

Und jetzt möchte ich aus jedem LAN kreis ins Internet

Der befehl NAT würde ja lauten

Code:
iptables -t nat -A POSTROUTING -o eth0 \-j SNAT --to-source xxx.xxx.xxx.xxx
(öffentliche Adresse)
so was mir jetzt aber so komisch vor kommt ist muss ich da nicht meine internen Interfaces angeben?

nein musst du nicht. source nat wird dann *auf* dem angegebenen interface ausgeführt.
für deinen fall würde ich aber das target MASQUERADE nehmen. MASQUERADE ist nen sonderfall von SNAT.

mal ne frage => was für eine anbindung hast du? dsl?
wenn ja nehme mal als interface ppp0 statt eth0.

zu deiner frage im letzten posting. am besten du postest nochmal den netfilterabschnitt aus deiner kernelconfig. möglich das du was vergessen hast.

ach nochwas, wenn du noch keine weiteren regeln aufgestellt hast, brauchst du diese regel noch gar nicht

iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

da deine default policy eh noch auf ACCEPT steht


Gruß HL
 
Also zu meiner Netzwerk

Ich bin über einen Router von meinen ISP mit dem INTERNET verbunden ich hab von meine Provider ein Öffentlich Range bekommen
So jetzt benutze ich auf meinen ersten Interface Eth0 eine IP-adresse aus meiner Range das heißt meine IP-Adresse ist fix weiter hab ich noch 8 andere Adressen für Mailserver Webserver und so was ich aber noch nicht benutze


Also hat mein router xxx.xxx.xxx.113 und meine Firewall hat xxx.xxx.xxx.114

In meiner Firewall hab ich eine Multi Interface Netzwerkkarte für meine 4 Lankreise

Eth1 192.168.1.0
Eth2 192.168.2.0
Eth3 192.168.3.0
Eth4 192.168.4.0


Meine
Code:
Networking options
Einstellungen

Code:
<*> Packet socket                                                                        x x
  x x                                [ ]   Packet socket: mmapped IO                                                          x x
  x x                                < > Netlink device emulation                                                             x x
  x x                                [*] Network packet filtering (replaces ipchains)                                         x x
  x x                                [ ]   Network packet filtering debugging                                                 x x
  x x                                [ ] Socket Filtering                                                                     x x
  x x                                <*> Unix domain sockets                                                                  x x
  x x                                [*] TCP/IP networking                                                                    x x
  x x                                [ ]   IP: multicasting                                                                   x x
  x x                                [ ]   IP: advanced router                                                                x x
  x x                                [ ]   IP: kernel level autoconfiguration                                                 x x
  x x                                < >   IP: tunneling                                                                      x x
  x x                                < >   IP: GRE tunnels over IP                                                            x x
  x x                                [ ]   IP: ARP daemon support (EXPERIMENTAL)                                              x x
  x x                                [ ]   IP: TCP Explicit Congestion Notification support                                   x x
  x x                                [ ]   IP: TCP syncookie support (disabled per default)                                   x x
  x x                                  IP: Netfilter Configuration  --->                                                      x x
  x x                                < >   The IPv6 protocol (EXPERIMENTAL)                                                   x x
  x x                                < >   Kernel httpd acceleration (EXPERIMENTAL)                                           x x
  x x                                [ ] Asynchronous Transfer Mode (ATM) (EXPERIMENTAL)                                      x x
  x x                                < > 802.1Q VLAN Support                                                                  x x
  x x                                ---                                                                                      x x
  x x                                < > The IPX protocol                                                                     x x
  x x                                < > Appletalk protocol support                                                           x x
  x x                                Appletalk devices  --->                                                                  x x
  x x                                < > DECnet Support                                                                       x x
  x x                                < > 802.1d Ethernet Bridging                                                             x x
  x x                                < > CCITT X.25 Packet Layer (EXPERIMENTAL)                                               x x
  x x                                < > EDP2 ATA Packet Layer (EXPERIMENTAL)                                                 x x
  x x                                < > LAPB Data Link Driver (EXPERIMENTAL)                                                 x x
  x x                                [ ] 802.2 LLC (EXPERIMENTAL)                                                             x x
  x x                                [ ] Frame Diverter (EXPERIMENTAL)                                                        x x
  x x                                < > Acorn Econet/AUN protocols (EXPERIMENTAL)                                            x x
  x x                                < > WAN router




Code:
IP: Netfilter Configuration

Code:
  x x                                <M> Connection tracking (required for masq/NAT)                                          x x
  x x                                <M>   FTP protocol support                                                               x x
  x x                                <M>   Amanda protocol support                                                            x x
  x x                                <M>   TFTP protocol support                                                              x x
  x x                                <M>   IRC protocol support                                                               x x
  x x                                < > Userspace queueing via NETLINK (EXPERIMENTAL)                                        x x
  x x                                <M> IP tables support (required for filtering/masq/NAT)                                  x x
  x x                                <M>   limit match support                                                                x x
  x x                                <M>   MAC address match support                                                          x x
  x x                                <M>   Packet type match support                                                          x x
  x x                                <M>   netfilter MARK match support                                                       x x
  x x                                <M>   Multiple port match support                                                        x x
  x x                                <M>   TOS match support                                                                  x x
  x x                                <M>   ECN match support                                                                  x x
  x x                                <M>   DSCP match support                                                                 x x
  x x                                <M>   AH/ESP match support                                                               x x
  x x                                <M>   LENGTH match support                                                               x x
  x x                                <M>   TTL match support                                                                  x x
  x x                                <M>   tcpmss match support                                                               x x
  x x                                < >   Helper match support                                                               x x
  x x                                < >   Connection state match support                                                     x x
  x x                                < >   Connection tracking match support                                                  x x
  x x                                < >   Unclean match support (EXPERIMENTAL)                                               x x
  x x                                < >   Owner match support (EXPERIMENTAL)                                                 x x
  x x                                <M>   Packet filtering                                                                   x x
  x x                                <M>     REJECT target support                                                            x x
  x x                                < >     MIRROR target support (EXPERIMENTAL)                                             x x
  x x                                <M>   Full NAT                                                                           x x
  x x                                <M>     MASQUERADE target support                                                        x x
  x x                                <M>     REDIRECT target support                                                          x x
  x x                                [*]     NAT of local connections (READ HELP)                                             x x
  x x                                <M>     Basic SNMP-ALG support (EXPERIMENTAL)                                            x x
  x x                                <M>   Packet mangling                                                                   
 x x
  x x                                <M>     TOS target support
<M>   ECN match support                                                                  x x
  x x                                <M>   DSCP match support                                                                 x x
  x x                                <M>   AH/ESP match support                                                               x x
  x x                                <M>   LENGTH match support                                                               x x
  x x                                <M>   TTL match support                                                                  x x
  x x                                <M>   tcpmss match support                                                               x x
  x x                                < >   Helper match support                                                               x x
  x x                                < >   Connection state match support                                                     x x
  x x                                < >   Connection tracking match support                                                  x x
  x x                                < >   Unclean match support (EXPERIMENTAL)                                               x x
  x x                                < >   Owner match support (EXPERIMENTAL)                                                 x x
  x x                                <M>   Packet filtering                                                                   x x
  x x                                <M>     REJECT target support                                                            x x
  x x                                < >     MIRROR target support (EXPERIMENTAL)                                             x x
  x x                                <M>   Full NAT                                                                           x x
  x x                                <M>     MASQUERADE target support                                                        x x
  x x                                <M>     REDIRECT target support                                                          x x
  x x                                [*]     NAT of local connections (READ HELP)                                             x x
  x x                                <M>     Basic SNMP-ALG support (EXPERIMENTAL)                                            x x
  x x                                <M>   Packet mangling                                                                    x x
  x x                                <M>     TOS target support                                                               x x
  x x                                < >     ECN target support                                                               x x
  x x                                <M>     DSCP target support                                                              x x
  x x                                <M>     MARK target support                                                              x x
  x x                                <M>   LOG target support                                                                 x x
  x x                                <M>   ULOG target support                                                                x x
  x x                                <M>   TCPMSS target support                                                              x x
  x x                                <M> ARP tables support                                                                   x x
  x x                                <M>   ARP packet filtering                                                               x x
  x x                                < > ipchains (2.2-style) support                                                         x x
  x x                                < > ipfwadm (2.0-style) support


bitte sag mir was ich noch Reinnehmen soll und was raus soll
 
hm, bei deiner anbindung müßte dann eth0 doch richtig sein.

zu deiner kernelconfig, das noch als modul reinnehmen

[ ] IP: TCP syncookie support (disabled per default)

< > Connection state match support
< > Connection tracking match support
< > Owner match support (EXPERIMENTAL)


Gruß HL
 

Ähnliche Themen

Wired-Lan komisches Verhalten

iptables - default policy - Server macht dicht

OpenVPN - Server kann clients nicht erreichen.

keine Verbindung nach aussen

iptables Problem mit der Syntax ethx

Zurück
Oben