PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Firewall ==> kein Internet



mario88
16.08.03, 00:40
Also ich hab so ziemlich (derzeit noch) null Ahnung von iptables und da hab ich mir ein iptables-Skript auf harry.homelinux.org generieren lassen.
Jetzt hab ich aber das Problem, dass ich nicht mehr ins Internet kann, nachdem ich sie gestartet habe :(
Die Firewall läuft auf meiner Workstation, die gleichzeitig auch der lokale Router ist. (fürs Notebook)
Ein ping www.google.at gibt nur unknown host.
Was hab ich da vergessen bzw. welche Regeln sind falsch ?
Hier ist das Skript:


# iptables-Modul
modprobe ip_tables
# Connection-Tracking-Module
modprobe ip_conntrack
# Das Modul ip_conntrack_irc ist erst bei Kerneln >= 2.4.19 verfuegbar
modprobe ip_conntrack_irc
modprobe ip_conntrack_ftp

# Tabelle flushen
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X
iptables -t nat -X
iptables -t mangle -X

# Default-Policies setzen
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

# MY_REJECT-Chain
iptables -N MY_REJECT

# MY_REJECT fuellen
iptables -A MY_REJECT -p tcp -m limit --limit 7200/h -j LOG --log-prefix "REJECT TCP "
iptables -A MY_REJECT -p tcp -j REJECT --reject-with tcp-reset
iptables -A MY_REJECT -p udp -m limit --limit 7200/h -j LOG --log-prefix "REJECT UDP "
iptables -A MY_REJECT -p udp -j REJECT --reject-with icmp-port-unreachable
iptables -A MY_REJECT -p icmp -m limit --limit 7200/h -j LOG --log-prefix "DROP ICMP "
iptables -A MY_REJECT -p icmp -j DROP
iptables -A MY_REJECT -m limit --limit 7200/h -j LOG --log-prefix "REJECT OTHER "
iptables -A MY_REJECT -j REJECT --reject-with icmp-proto-unreachable

# MY_DROP-Chain
iptables -N MY_DROP
iptables -A MY_DROP -j DROP

# Alle Pakete protokollieren
iptables -A INPUT -j LOG --log-prefix "INPUT LOG "
iptables -A OUTPUT -j LOG --log-prefix "OUTPUT LOG "
iptables -A FORWARD -j LOG --log-prefix "FORWARD LOG "

# Korrupte Pakete zurueckweisen
iptables -A INPUT -m state --state INVALID -j DROP
iptables -A OUTPUT -m state --state INVALID -j DROP
iptables -A FORWARD -m state --state INVALID -j DROP

# Stealth Scans etc. DROPpen
# Keine Flags gesetzt
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j MY_DROP
iptables -A FORWARD -p tcp --tcp-flags ALL NONE -j MY_DROP

# SYN und FIN gesetzt
iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j MY_DROP
iptables -A FORWARD -p tcp --tcp-flags SYN,FIN SYN,FIN -j MY_DROP

# SYN und RST gleichzeitig gesetzt
iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j MY_DROP
iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN,RST -j MY_DROP

# FIN und RST gleichzeitig gesetzt
iptables -A INPUT -p tcp --tcp-flags FIN,RST FIN,RST -j MY_DROP
iptables -A FORWARD -p tcp --tcp-flags FIN,RST FIN,RST -j MY_DROP

# FIN ohne ACK
iptables -A INPUT -p tcp --tcp-flags ACK,FIN FIN -j MY_DROP
iptables -A FORWARD -p tcp --tcp-flags ACK,FIN FIN -j MY_DROP

# PSH ohne ACK
iptables -A INPUT -p tcp --tcp-flags ACK,PSH PSH -j MY_DROP
iptables -A FORWARD -p tcp --tcp-flags ACK,PSH PSH -j MY_DROP

# URG ohne ACK
iptables -A INPUT -p tcp --tcp-flags ACK,URG URG -j MY_DROP
iptables -A FORWARD -p tcp --tcp-flags ACK,URG URG -j MY_DROP

# Loopback-Netzwerk-Kommunikation zulassen
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

# Maximum Segment Size (MSS) für das Forwarding an PMTU anpassen
iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

# Connection-Tracking aktivieren
iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i ! eth0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# EDONKEY
iptables -A INPUT -i eth0 -m state --state NEW -p tcp --dport 4661 -j ACCEPT
iptables -A INPUT -i eth0 -m state --state NEW -p tcp --dport 4662 -j ACCEPT
iptables -A INPUT -i eth0 -m state --state NEW -p tcp --dport 4663 -j ACCEPT
iptables -A INPUT -i eth0 -m state --state NEW -p udp --dport 4665 -j ACCEPT

# LAN-Zugriff auf eth1
iptables -A INPUT -m state --state NEW -i eth1 -j ACCEPT

# Default-Policies mit REJECT
iptables -A INPUT -j MY_REJECT
iptables -A OUTPUT -j MY_REJECT
iptables -A FORWARD -j MY_REJECT

# Routing
echo 1 > /proc/sys/net/ipv4/ip_forward 2> /dev/null

# Masquerading
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

# SYN-Cookies
echo 1 > /proc/sys/net/ipv4/tcp_syncookies 2> /dev/null

# Stop Source-Routing
for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/accept_source_route 2> /dev/null; done

# Stop Redirecting
for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/accept_redirects 2> /dev/null; done

# Reverse-Path-Filter
for i in /proc/sys/net/ipv4/conf/*; do echo 2 > $i/rp_filter 2> /dev/null; done

# Log Martians
for i in /proc/sys/net/ipv4/conf/*; do echo 1 > $i/log_martians 2> /dev/null; done

# BOOTP-Relaying ausschalten
for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/bootp_relay 2> /dev/null; done

# Proxy-ARP ausschalten
for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/proxy_arp 2> /dev/null; done

# Ungültige ICMP-Antworten ignorieren
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses 2> /dev/null

# ICMP Echo-Broadcasts ignorieren
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts 2> /dev/null

# Max. 500/Sekunde (5/Jiffie) senden
echo 5 > /proc/sys/net/ipv4/icmp_ratelimit

# Speicherallozierung und -timing für IP-De/-Fragmentierung
echo 262144 > /proc/sys/net/ipv4/ipfrag_high_thresh
echo 196608 > /proc/sys/net/ipv4/ipfrag_low_thresh
echo 30 > /proc/sys/net/ipv4/ipfrag_time

# TCP-FIN-Timeout zum Schutz vor DoS-Attacken setzen
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout

# Maximal 3 Antworten auf ein TCP-SYN
echo 3 > /proc/sys/net/ipv4/tcp_retries1

# TCP-Pakete maximal 15x wiederholen
echo 15 > /proc/sys/net/ipv4/tcp_retries2

;;

stop)
echo "Stoppe IP-Paketfilter"
# Tabelle flushen
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X
iptables -t nat -X
iptables -t mangle -X
echo "Deaktiviere IP-Routing"
echo 0 > /proc/sys/net/ipv4/ip_forward

# Default-Policies setzen
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
;;

status)
echo "Tabelle filter"
iptables -L -vn
echo "Tabelle nat"
iptables -t nat -L -vn
echo "Tabelle mangle"
iptables -t mangle -L -vn
;;

*)
echo "Fehlerhafter Aufruf"
echo "Syntax: $0 {start|stop|status}"
exit 1
;;

esac

thx for help

Shaded
16.08.03, 13:34
ähm ich hatte mit meiner suse was ähnliches bis ich herausbekommen hab das per default die firewall für eth0 einrichtet wird anstatt für ppp0, naja einfach für ppp0 umkonfiguriert und dann gings, vielleicht liegts bei dir ja auch an so etwas simplem? *als newbie natürlich keine ahnung hab, also nicht schimpfen wenn du daran schon gedacht hast*

Jinto
16.08.03, 13:39
Ich glaube nicht, dass eth0 dein Internetdevice ist, leider hast du aber darüber kein Wort verloren.

=> nochmals generieren lassen.

mario88
16.08.03, 18:08
Original geschrieben von Jinto
Ich glaube nicht, dass eth0 dein Internetdevice ist, leider hast du aber darüber kein Wort verloren.

=> nochmals generieren lassen.
Doch das stimmt, eth0 ist mein Internet-Device. (hab kein DSL, ich hab einen Kabelzugang --> fixe IP mit Kabelmodem, angeschlossen an eth0)

Jinto
16.08.03, 18:29
- Was sagt ifconfig?
- was genau funktioniert anch dem startetn nichtmehr? (Intenretzugang vom Notebook, Arbeitsplatz, etc)

mario88
16.08.03, 18:38
root@workstation mario # ifconfig
eth0 Protokoll:Ethernet Hardware Adresse 00:40:F4:52:D1:92
inet Adresse:62.40.158.111 Bcast:62.40.158.255 Maske:255.255.255.0
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:396691 errors:0 dropped:0 overruns:0 frame:0
TX packets:164670 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:100
RX bytes:200712598 (191.4 Mb) TX bytes:19937141 (19.0 Mb)
Interrupt:22 Basisadresse:0x2000

eth1 Protokoll:Ethernet Hardware Adresse 00:40:05:89:8B:95
inet Adresse:192.168.0.1 Bcast:192.168.0.255 Maske:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:86410 errors:1 dropped:0 overruns:0 frame:0
TX packets:101362 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:100
RX bytes:6065063 (5.7 Mb) TX bytes:152139547 (145.0 Mb)
Interrupt:20 Basisadresse:0x9000

lo Protokoll:Lokale Schleife
inet Adresse:127.0.0.1 Maske:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:66 errors:0 dropped:0 overruns:0 frame:0
TX packets:66 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:0
RX bytes:4918 (4.8 Kb) TX bytes:4918 (4.8 Kb)

Komisch ist noch, dass Fehlermeldungen kommen, beim Starten der FW. (die kommen aber auch, wenn ich manuell nur das Routing aktiviere und es klappt trotzdem.)


root@workstation mario # sh /home/mario/Skripte/firewall.sh start
Starte IP-Paketfilter
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name

Jinto
16.08.03, 19:03
Du musst im Kernel natürlich auch die entsprechenden Filtermodul einbinden (NETFILTER), sonst geht nichts.

mario88
16.08.03, 23:06
Danke, das war der Fehler, jetzt funktioniert die Firewall einwandfrei.
Nur noch 1 Frage:
Die Firewall schreibt doch auch Log-Files oder?, wo finde ich die ? (in /var/log finde ich nix)

HangLoose
16.08.03, 23:20
moin moin

das kommt auf deinen logdämon an. wenn es metalog ist z.b. /var/log/kernel/current, beim syslog /var/log/messages


Gruß HL

mario88
17.08.03, 00:07
danke :)