Anzeige:
Seite 1 von 2 12 LetzteLetzte
Ergebnis 1 bis 15 von 18

Thema: Iptables

  1. #1
    Registrierter Benutzer
    Registriert seit
    Dec 2002
    Beiträge
    29

    Iptables

    Hallo,

    ich habe mal eine frage bezüglich der Iptables. Vor einiger Zeit habe ich mir auf der homepage http://www.harry.homelinux.org/ die Iptables Generieren. Leider funktionieren die nicht richtig, ich kam auf einige Seiten nicht drauf z.B. www.ebay.de oder so. Jedenfalls habe ich eine mail an den Webmaster geschickt und bekam prompt hilfe. Es wurde ein zusatz reingeschrieben, jedoch kann ich die Iptables jetzt leider nicht mehr Starten! (Fehler: bad Interpreter) Woran kann das liegen?

    Das es die Homepage wohl nicht mehr gibt, wollte ich fragen ob mir jemand von euch weiterhelfen kann!

    Gruß Markus

    #!/bin/bash
    # ---------------------------------------------------------------------
    # Linux-iptables-Firewallskript, Copyright (c) 2003 under the GPL
    # Autogenerated by iptables Generator v1.15 (c) 2002 by Harald Bertram_
    # Please visit http://www.harry.homelinux.org for new versions of
    # the iptables Generator (c).
    #
    # This Script was generated by request from:
    # Markus2212@web.de on: 2003-2-9 23:13.43 MET.
    #
    # If you have questions about the iptables Generator or about
    # your Firewall-Skript feel free to take a look at out website or
    # send me an E-Mail to webmaster@harry.homelinux.org.
    #
    # My special thanks are going to Lutz Heinrich (trinitywork@hotmail.com) who
    # made lots of Beta-Testing and gave me lots of well qualified
    # Feedback that made me able to improve the iptables Generator.
    # --------------------------------------------------------------------

    case "$1" in
    start)
    echo "Starte IP-Paketfilter"

    # 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 -m limit --limit 7200/h -j LOG --log-prefix "PORTSCAN DROP "
    iptables -A MY_DROP -j DROP

    # Alle verworfenen Pakete protokollieren
    iptables -A INPUT -m state --state INVALID -m limit --limit 7200/h -j LOG --log-prefix "INPUT INVALID "
    iptables -A OUTPUT -m state --state INVALID -m limit --limit 7200/h -j LOG --log-prefix "OUTPUT INVALID "
    iptables -A FORWARD -m state --state INVALID -m limit --limit 7200/h -j LOG --log-prefix "FORWARD INVALID "

    # 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

    # Connection-Tracking aktivieren
    iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
    iptables -A FORWARD -i ! ppp0 -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

    # Max. Segment-Size für das Forwarding anpassen
    iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

    # HTTP
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 80 -j ACCEPT

    # HTTPS
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 443 -j ACCEPT

    # SMTP
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 25 -j ACCEPT

    # POP3
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 110 -j ACCEPT

    # POP3S
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 995 -j ACCEPT

    # IMAP
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 143 -j ACCEPT

    # IMAPS
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 993 -j ACCEPT

    # NNTP
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 119 -j ACCEPT

    # DNS
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 53 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p udp --dport 53 -j ACCEPT

    # FTP
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 21 -j ACCEPT

    # SMB
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 137 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 138 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 139 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p udp --dport 137 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p udp --dport 138 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p udp --dport 139 -j ACCEPT

    # SSH
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 22 -j ACCEPT

    # MYSQL
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 3306 -j ACCEPT

    # NTP
    iptables -A INPUT -i ppp0 -m state --state NEW -p udp --dport 123 -j ACCEPT

    # IRC
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 6667 -j ACCEPT

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

    # TELNET
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 23 -j ACCEPT

    # BZFLAG
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 5155 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p udp --dport 5155 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 5156 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p udp --dport 5156 -j ACCEPT

    # HALF-LIFE
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 6000:6003 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 7001:7002 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p udp --dport 27005 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p udp --dport 27010 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p udp --dport 27015:27016 -j ACCEPT

    # IPSEC
    iptables -A INPUT -i ppp0 -p 50 -j ACCEPT
    iptables -A INPUT -i ppp0 -p 51 -j ACCEPT
    iptables -A INPUT -i ppp0 -m state --state NEW -p udp --dport 500 -j ACCEPT

    # OPENVPN
    iptables -A INPUT -i ppp0 -m state --state NEW -p udp --dport 5000 -j ACCEPT

    # LAN-Zugriff auf eth0
    iptables -A INPUT -m state --state NEW -i eth0 -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 ppp0 -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
    # Auskommentiert, da IPSEC mit RP_Filter nicht funktioniert!
    # 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

  2. #2
    ***** Avatar von Belkira
    Registriert seit
    Jun 2002
    Ort
    DE
    Beiträge
    2.313

    Arrow

    Vollständige Fehlermeldung wäre wichtig gewesen.

    http://www.linuxforen.de/forums/sear...der=descending

  3. #3
    Registrierter Benutzer
    Registriert seit
    Dec 2002
    Beiträge
    29
    Die Fehlermeldung lautet genau: bad interpreter: No such file or directory

    Könnte es sein das ich ein Programm installieren muss, oder so? Ich habe Suse Linux 8.1

  4. #4
    ***** Avatar von Belkira
    Registriert seit
    Jun 2002
    Ort
    DE
    Beiträge
    2.313
    Die Fehlermeldung lautet genau: bad interpreter: No such file or directory

    Könnte es sein das ich ein Programm installieren muss, oder so? Ich habe Suse Linux 8.1
    #!/bin/bash
    Du hast /bin/bash? Wenn nicht, ändere es in der ersten Zeile des Skripts auf #!/bin/sh ab.

  5. #5
    Premium Mitglied
    Registriert seit
    Jun 2002
    Beiträge
    2.483
    Welcher Zusatz wurde denn gemacht?
    Zweiblum versuchte es ihm zu erklären
    Rincewind versuchte es zu verstehen

    Wie man Fragen richtig stellt

  6. #6
    Registrierter Benutzer
    Registriert seit
    Dec 2002
    Beiträge
    29
    Was meinst du mit Zusatz?

  7. #7
    kleiner bruder von ruth Avatar von HangLoose
    Registriert seit
    Aug 2002
    Ort
    Old Europe
    Beiträge
    3.894
    Was meinst du mit Zusatz?
    Jinto meinte, was an dem script geändert wurde. ich tippe mal auf diese regel

    # Max. Segment-Size für das Forwarding anpassen
    iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

    wie lief denn dieses " Es wurde ein zusatz reingeschrieben" genau ab. hat harry dir ein neues script geschickt? wenn ja, hast du dieses auch ausführbar gemacht?


    ps: laut harry soll die seite so um den 12.03 wieder online sein.


    Gruß HL
    "You only go around once, so you better go hard!"

    Open Source!
    "First they ignore you, then they laugh at you, then they fight you, then you win".

  8. #8
    Registrierter Benutzer
    Registriert seit
    Dec 2002
    Beiträge
    29
    Ich habe Harry meine Datei geschickt und er hat sie mir netter weise umgeändert.


    Er schrieb an mich:

    ich vermute mal, dass dies mit einigen Provider-typischen
    Paketfiltereinstellungen zusammenhängt.

    Anliegend habe ich eine neue Zeile in das Skript eingefügt (die Zeile mit dem
    Target "-j TCPMSS ..."). Diese Zeile stellt einen Workaround für solche
    Probleme dar.

  9. #9
    kleiner bruder von ruth Avatar von HangLoose
    Registriert seit
    Aug 2002
    Ort
    Old Europe
    Beiträge
    3.894
    Hi

    dann mach die datei mal wieder ausführbar => chmod u+x /...


    Gruß HL
    "You only go around once, so you better go hard!"

    Open Source!
    "First they ignore you, then they laugh at you, then they fight you, then you win".

  10. #10
    Registrierter Benutzer
    Registriert seit
    Dec 2002
    Beiträge
    29
    Ach ja!

    Ich habe die Datei mit chmod 755 geändert und starte sie mit dem Befehl ./firewall.sh start! Das hat mit einer Datei die ich vorher mit dem Generator erstellt habe auch funktioniert!

  11. #11
    Registrierter Benutzer
    Registriert seit
    Dec 2002
    Beiträge
    29
    Habe es mit chmod u+x versucht! Habe dann mit ./firewall.sh start versucht zu starten, jedoch ohne Erfolg! Immer noch der gleiche Fehler :bad interpreter: No such file or directory

  12. #12
    kleiner bruder von ruth Avatar von HangLoose
    Registriert seit
    Aug 2002
    Ort
    Old Europe
    Beiträge
    3.894
    hi

    wenn du das script jetzt noch in deinen default runlevel einbindest, brauchst du das script nicht jedesmal von hand starten

    http://www.linuxforen.de/forums/show...threadid=69354


    Gruß HL
    "You only go around once, so you better go hard!"

    Open Source!
    "First they ignore you, then they laugh at you, then they fight you, then you win".

  13. #13
    kleiner bruder von ruth Avatar von HangLoose
    Registriert seit
    Aug 2002
    Ort
    Old Europe
    Beiträge
    3.894
    Habe es mit chmod u+x versucht! Habe dann mit ./firewall.sh start versucht zu starten, jedoch ohne Erfolg!
    als root bist du aber unterwegs? versuch mal den vollen pfad zum script.

    Gruß HL
    "You only go around once, so you better go hard!"

    Open Source!
    "First they ignore you, then they laugh at you, then they fight you, then you win".

  14. #14
    Registrierter Benutzer
    Registriert seit
    Dec 2002
    Beiträge
    29
    als root bin ich angemeldet!!!!! Mit dem vollem Pfad habe ich es versucht. Vergebens!

  15. #15
    kleiner bruder von ruth Avatar von HangLoose
    Registriert seit
    Aug 2002
    Ort
    Old Europe
    Beiträge
    3.894
    als root bin ich angemeldet!!!!!
    ein ! hätte gereicht

    hast du belkira's vorschlag schon versucht?

    Du hast /bin/bash? Wenn nicht, ändere es in der ersten Zeile des Skripts auf #!/bin/sh ab.
    edit: nimm mal die endung .sh beim script weg

    Gruß HL
    "You only go around once, so you better go hard!"

    Open Source!
    "First they ignore you, then they laugh at you, then they fight you, then you win".

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •