Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Iptables Problem
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
Koolance
n00b
n00b


Joined: 07 Apr 2006
Posts: 7

PostPosted: Fri Apr 07, 2006 1:47 pm    Post subject: Iptables Problem Reply with quote

Ich probiere mir zur Zeit einen kleinen stromsparenden Gentoo Allzweckserver aufzubauen. Er soll eine Firewall, Router und AMule Client werden. Doch bis jetzt ist er nicht mal ein Router. Ich habe die Grundinstallation nach dem Gentoo handbuch (Minimal CD+Stage3 Archiv+ Kernel 2.6) gemacht. Und danach die anleitung zum bau eine Gentoo Routers verwendet.
Allerdings funktioniert einfach das Routing nicht. Wenn ich pinge klappt noch die Namensauflösung, sonst aber nichts. So wie es aussieht kommen die Pakete auf dem Server an aber er gibt nichts zurück.
Ein Tippfehler in den IPTables Regeln ist ausgeschlossen da ich sie zur Sicherheit noch ein mal gelöscht habe und über SSL Console per Copy&Paste aus dem Router-Tutorial eingefügt habe.
Den Kernel habe ich auch schon neu kompiliert und danach noch mal iptables gemerged.

Mögliche Fehlerursache:
Während der Grundinstallation wurde ich irgendwann mal gefragt wie der Firewall des Server konfiguriert werden soll (Standalone Server, Router oder Garnicht) hier habe ich Router gewählt.

Abschließend muß ich noch sagen das ich eigentlich aus der Windowswelt komme und mein Linuxwissen nicht sonderlich tief geht, daher bitte möglichst einfache Antworten :)
Back to top
View user's profile Send private message
himpierre
l33t
l33t


Joined: 31 Aug 2002
Posts: 867
Location: Berlin

PostPosted: Fri Apr 07, 2006 2:46 pm    Post subject: Reply with quote

Hallo.

Ein bisschen mehr musst Du schon verraten. Netzwerktopologie, iptables Regeln usw.

t.
Back to top
View user's profile Send private message
Koolance
n00b
n00b


Joined: 07 Apr 2006
Posts: 7

PostPosted: Fri Apr 07, 2006 6:00 pm    Post subject: Reply with quote

Aber gerne :)
Eingereichtet nach diesem Tutorial: http://www.gentoo.org/doc/de/home-router-howto.xml

DSL-Modem->Gentoo-Server->Switch->Mein Windows rechner

eth0=Lan
Eth1=Wan
Eth2=nicht eingerichtet und beim booten deaktiviert. (soll irgendwann mal ne DMZ werden)

DHCP-Server= Dnsmasq läuft und funktioniert
Kernel: Gentoo 2.6.15-r1 (manuelle Konfiguration)
Partitionen:Boot,SWAP und Home (boot wird direkt gemounted)

Die Regel
Quote:

Zuerst löschen wir unsere aktuellen Regeln
# iptables -F
# iptables -t nat -F

Richten Sie das Standardverhalten für Pakete ein, auf die keine Regel zutrifft
# iptables -P INPUT ACCEPT
# iptables -P OUTPUT ACCEPT
# iptables -P FORWARD DROP

Kopieren Sie diese Beispiele ...
# export LAN=eth0
# export WAN=eth1

Dann schränken wir unsere Dienste so ein, dass sie nur im LAN arbeiten
# iptables -I INPUT 1 -i ${LAN} -j ACCEPT
# iptables -I INPUT 1 -i lo -j ACCEPT
# iptables -A INPUT -p UDP --dport bootps -i ! ${LAN} -j REJECT
# iptables -A INPUT -p UDP --dport domain -i ! ${LAN} -j REJECT

(Optional) Erlauben Sie den Zugriff auf unseren SSH-Server aus dem WAN
# iptables -A INPUT -p TCP --dport ssh -i ${WAN} -j ACCEPT

Werfen Sie TCP/UDP-Pakete für privilegierte Ports weg
# iptables -A INPUT -p TCP -i ! ${LAN} -d 0/0 --dport 0:1023 -j DROP
# iptables -A INPUT -p UDP -i ! ${LAN} -d 0/0 --dport 0:1023 -j DROP

Schlussendlich fügen wir NAT-Regeln hinzu
# iptables -I FORWARD -i ${LAN} -d 192.168.0.0/255.255.0.0 -j DROP
# iptables -A FORWARD -i ${LAN} -s 192.168.0.0/255.255.0.0 -j ACCEPT
# iptables -A FORWARD -i ${WAN} -d 192.168.0.0/255.255.0.0 -j ACCEPT
# iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
Sagen Sie dem Kernel, dass IP-Forwarding in Ordnung ist
# echo 1 > /proc/sys/net/ipv4/ip_forward
# for f in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 1 > $f ; done

So müssen wir nach dem Booten die Regeln nicht per Hand starten
# /etc/init.d/iptables save
# rc-update add iptables default
# nano /etc/sysctl.conf
Fügen Sie die folgende Zeilen hinzu oder entfernen Sie die Kommentare:
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1


Zur Einwahl verwende ich rp-pppoe. (Dynamisch Ip) Provider Netcologne, aber im Internet ist der Server ja eigentlich schon. Mit
iptraf konnte ich sehen das die Pings am Server ankommen, aber das war mir eigentlich vorher schon klar da ja die SSL-Verbindung funktioniert.

EDIT
Mir ist gerade noch was aufgefallen, beim booten kann ich kurz einen roten Punkt sehen. Allerdings kann ich im "/var/log/dmesg" keinen Fehler finden. Als Logger habe ich syslog-ng installiert.
Back to top
View user's profile Send private message
sschlueter
Guru
Guru


Joined: 26 Jul 2002
Posts: 578
Location: Dortmund, Germany

PostPosted: Fri Apr 07, 2006 11:08 pm    Post subject: Reply with quote

Zeige uns doch mal die Ausgaben der folgenden Befehle:

# iptables -t filter -v -L -n

# iptables -t nat -v -L -n

# cat /proc/sys/net/ipv4/ip_forward

# netstat -rn
Back to top
View user's profile Send private message
Koolance
n00b
n00b


Joined: 07 Apr 2006
Posts: 7

PostPosted: Sat Apr 08, 2006 8:32 am    Post subject: Reply with quote

Hier die Ausgaben:

server ~ # iptables -t filter -v -L -n
Chain INPUT (policy ACCEPT 471 packets, 455K bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
3542 229K ACCEPT all -- eth0 * 0.0.0.0/0 0.0.0.0/0
0 0 REJECT udp -- !eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:67 reject-with icmp-port-unreachable
0 0 REJECT udp -- !eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:53 reject-with icmp-port-unreachable
0 0 ACCEPT tcp -- eth1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
338 17712 DROP tcp -- !eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpts:0:1023
1 78 DROP udp -- !eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpts:0:1023
0 0 DROP udp -- !eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpts:0:1023

Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 DROP all -- eth0 * 0.0.0.0/0 192.168.0.0/16
3635 198K ACCEPT all -- eth0 * 192.168.0.0/16 0.0.0.0/0
0 0 ACCEPT all -- eth1 * 0.0.0.0/0 192.168.0.0/16

Chain OUTPUT (policy ACCEPT 4568 packets, 755K bytes)
pkts bytes target prot opt in out source destination


________________________________________________________________________________________________________________________________________

iptables -t nat -v -L -n
Chain PREROUTING (policy ACCEPT 6894 packets, 413K bytes)
pkts bytes target prot opt in out source destination
0 0 DNAT tcp -- eth1 * 0.0.0.0/0 0.0.0.0/0 tcp dpts:6881:6889 to:192.168.0.2

Chain POSTROUTING (policy ACCEPT 1738 packets, 98080 bytes)
pkts bytes target prot opt in out source destination
0 0 MASQUERADE all -- * eth1 0.0.0.0/0 0.0.0.0/0

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

________________________________________________________________________________________________________________________________________

server ~ # cat /proc/sys/net/ipv4/ip_forward
1
________________________________________________________________________________________________________________________________________

server ~ # netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
195.14.247.165 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 127.0.0.1 255.0.0.0 UG 0 0 0 lo
0.0.0.0 195.14.247.165 0.0.0.0 UG 0 0 0 ppp0
Back to top
View user's profile Send private message
sschlueter
Guru
Guru


Joined: 26 Jul 2002
Posts: 578
Location: Dortmund, Germany

PostPosted: Sat Apr 08, 2006 11:38 am    Post subject: Reply with quote

eth1 ist falsch. Du musst an diesen Stellen ppp0 anstelle von eth1 verwenden.
Back to top
View user's profile Send private message
Koolance
n00b
n00b


Joined: 07 Apr 2006
Posts: 7

PostPosted: Sat Apr 08, 2006 12:05 pm    Post subject: Reply with quote

Danke, das klingt logisch, ich kann es leider unterwegs und kann es erst am Montag ausprobieren.

Aber damit ich am Montag voll durchstarten kann schreibe ich noch mal wie ich vorgehen werde.

Ich muss erst alle Regeln löschen:

Zuerst löschen wir unsere aktuellen Regeln
# iptables -F
# iptables -t nat -F

Dann diese Regeln einfügen:

Richten Sie das Standardverhalten für Pakete ein, auf die keine Regel zutrifft
# iptables -P INPUT ACCEPT
# iptables -P OUTPUT ACCEPT
# iptables -P FORWARD DROP

Dann die export Regeln leicht verändert einfügen.

# export LAN=eth0
# export WAN=ppp0

Und die restlichen Regeln wie gehabt. Das klappt bestimmt, vielen Dank noch mal.
Back to top
View user's profile Send private message
Koolance
n00b
n00b


Joined: 07 Apr 2006
Posts: 7

PostPosted: Mon Apr 10, 2006 2:41 pm    Post subject: Reply with quote

Die Hoffnung war groß, aber leider klappt es immer noch nicht. Vielleicht hat ja noch einer eine Idee.
Hier noch mal die Ausgaben:

iptables -t filter -v -L -n
Chain INPUT (policy ACCEPT 104 packets, 9896 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
578 50431 ACCEPT all -- eth0 * 0.0.0.0/0 0.0.0.0/0
0 0 REJECT udp -- !eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:67 reject-with icmp-port-unreachable
0 0 REJECT udp -- !eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:53 reject-with icmp-port-unreachable
0 0 ACCEPT tcp -- ppp0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
115 6040 DROP tcp -- !eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpts:0:1023
0 0 DROP udp -- !eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpts:0:1023

Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 DROP all -- eth0 * 0.0.0.0/0 192.168.0.0/16
68 3324 ACCEPT all -- eth0 * 192.168.0.0/16 0.0.0.0/0
0 0 ACCEPT all -- ppp0 * 0.0.0.0/0 192.168.0.0/16

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

_________________________________________________________________________________________________________________

iptables -t nat -v -L -n
Chain PREROUTING (policy ACCEPT 7548 packets, 460K bytes)
pkts bytes target prot opt in out source destination

Chain POSTROUTING (policy ACCEPT 2164 packets, 128K bytes)
pkts bytes target prot opt in out source destination
0 0 MASQUERADE all -- * eth1 0.0.0.0/0 0.0.0.0/0

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

__________________________________________________________________________________________________________________

cat /proc/sys/net/ipv4/ip_forward
1
Back to top
View user's profile Send private message
sschlueter
Guru
Guru


Joined: 26 Jul 2002
Posts: 578
Location: Dortmund, Germany

PostPosted: Mon Apr 10, 2006 3:59 pm    Post subject: Reply with quote

Du benutzt ja auch immer noch eth1 :-)

Du hast beim MASQUERADE vergessen, ppp0 zu nehmen.
Back to top
View user's profile Send private message
Koolance
n00b
n00b


Joined: 07 Apr 2006
Posts: 7

PostPosted: Mon Apr 10, 2006 4:58 pm    Post subject: Reply with quote

Ich bin gerade über meinen Router Verbunden :) :D

Aber für so viel blödheit könnte ich selber schlagen... :evil:

Aber noch mal herzlichen Dank.
Back to top
View user's profile Send private message
sschlueter
Guru
Guru


Joined: 26 Jul 2002
Posts: 578
Location: Dortmund, Germany

PostPosted: Mon Apr 10, 2006 5:22 pm    Post subject: Reply with quote

Hehe, kein Problem. :-)

Du könntest dann bei Gelegenheit die iptables-Konfiguration etwas sicherer machen. Von den auf dem Router laufenden Diensten werden nur diejenigen geschützt, die auf priviligierten Ports lauschen. Heutzutage lauschen viele Dienste auch auf höheren Ports.

Du kannst die lauschenden Ports mittels

Code:
netstat -tulpn


ermitteln.
Back to top
View user's profile Send private message
Koolance
n00b
n00b


Joined: 07 Apr 2006
Posts: 7

PostPosted: Mon Apr 10, 2006 5:29 pm    Post subject: Reply with quote

Danke für den Tip, aber bis jetzt ist da noch nicht viel los.

Quote:
netstat -tulpn Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 6360/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6509/sshd
udp 0 0 0.0.0.0:1024 0.0.0.0:* 6360/dnsmasq
udp 0 0 0.0.0.0:53 0.0.0.0:* 6360/dnsmasq
udp 0 0 0.0.0.0:67 0.0.0.0:*


Jetzt muss ich erst mal aMule ohne X zum laufen bekommen, das wird mich wahrscheinlich den Rest der Woche kosten :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum