aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: Try `iptables -h' or 'iptables --help' for more information.  (Read 7185 times)

DraculTepes

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 17
Try `iptables -h' or 'iptables --help' for more information.
« on: October 23, 2004, 03:48:46 AM »

tut ir ja leid euch zu nerven *G* aber bei mir tritt ständig irgendwas auf  :/ ich glaube mein rechner mag mich nich.

naja ich mach demnächst wohl einen thread auf der da heißt" Draculs gesammelte Probleme"  

naja

linux:/etc/ppp/ip-up.d # ./local
./local: line 66: Skriptes: command not found
iptables: No chain/target/match by that name
iptables v1.2.9: Unknown arg `--log-prefix'
Try `iptables -h' or 'iptables --help' for more information.
./local: line 124: xmas-scan : command not found
Warning: wierd character in interface `-s' (No aliases, :, ! or *).
Bad argument `192.168.0.0/16'
Try `iptables -h' or 'iptables --help' for more information.
Warning: wierd character in interface `-s' (No aliases, :, ! or *).
Bad argument `172.16.0.0/12'
Try `iptables -h' or 'iptables --help' for more information.
Warning: wierd character in interface `-s' (No aliases, :, ! or *).
Bad argument `10.0.0.0/8'
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.2.9: Unknown arg `--log-prefix'
Try `iptables -h' or 'iptables --help' for more information.
./local: line 143: spoofing : command not found
Warning: wierd character in interface `-p' (No aliases, :, ! or *).
Bad argument `icmp'
Try `iptables -h' or 'iptables --help' for more information.
./local: line 151: icmp_reject: command not found
Bad argument `state'
Try `iptables -h' or 'iptables --help' for more information.
Bad argument `state'
Try `iptables -h' or 'iptables --help' for more information.
Bad argument `state'
Try `iptables -h' or 'iptables --help' for more information.
Warning: wierd character in interface `--dport' (No aliases, :, ! or *).
Bad argument `53'
Try `iptables -h' or 'iptables --help' for more information.
Bad argument `22'
Try `iptables -h' or 'iptables --help' for more information.
Warning: wierd character in interface `-m' (No aliases, :, ! or *).
Bad argument `state'
Try `iptables -h' or 'iptables --help' for more information.
Warning: wierd character in interface `-m' (No aliases, :, ! or *).
Bad argument `state'
Try `iptables -h' or 'iptables --help' for more information.
Warning: wierd character in interface `-s' (No aliases, :, ! or *).
Bad argument `192.168.0.0/24'
Try `iptables -h' or 'iptables --help' for more information.
./local: line 246: ja.: command not found
iptables v1.2.9: Unknown arg `-j'
Try `iptables -h' or 'iptables --help' for more information.
./local: line 271: locnet_out: command not found
Warning: wierd character in interface `-m' (No aliases, :, ! or *).
Bad argument `state'
Try `iptables -h' or 'iptables --help' for more information.



Das ist mein problem, ich will ein einfaches script ausführen und das kommt dabei raus. das script kommt von adsl4linux.de
Code: [Select]
#!/bin/bash
#
# /etc/ppp/ip-up.local
#
# User-Addons, die nach dem Verbindungsaufbau ausgefuehrt werden
# sollen
#
# Written: [EMAIL]Michael@adsl4linux.de[/EMAIL]
#
# Most ideas and iptables-syntax from: packetfilter
# Written by Alexander Stielau
# [URL]http://www.buug.de/~aleks/iptables[/URL]
#
# Version: 20020427 - 0.2

####
#
# Einige Parameter, die uns der pppd mit uebergibt
#
####

# Interface-name (Device der aktuellen Verbindung, z.B. ppp0)
DEV_INET=$1

# local-IP-address (IP-Adresse, die wir vom Provider zuegwiesen bekommen
# haben
IP_INET=$4

# remote-IP-address (unsere Gegenstelle beim Provider)
IP_GATEWAY=$5

####
#
# Einige weitere Variablen, die praktisch sein koennen bzw. die
# benoetigt werden
#
####

# Das Device auf LAN-Seite
DEV_LAN=eth0
IP_LAN=192.168.0.2

# Loopback Device. Hat jeder. Finger weg!
DEV_LOOP=lo
IP_LOOP=127.0.0.1

# Kürzel für alle IP-Adressen
ANY=0.0.0.0/0

# Kürzel für alle IP-Adressen im eigenen LAN
LOC_NET=192.168.0.0/24

# Das aktuelle Datum und die Uhrzeit
DATE=$(date)

# Vollen Pfad von iptables
IPTABLES=/usr/sbin/iptables

####
#
# Hier beginnt das eigentliche Masquerading- und Firewallskript
#
####

# IP-Forwarding im Kernel zunächst deaktivieren - wird am Schluss des Skriptes
# wieder aktiviert
echo 0 > /proc/sys/net/ipv4/ip_forward

# Benoetigte Module laden
modprobe ip_tables &> /dev/null
modprobe ip_conntrack &> /dev/null
modprobe ip_conntrack_ftp &> /dev/null
modprobe ipt_state &> /dev/null
modprobe iptable_nat &> /dev/null
modprobe ipt_REJECT &> /dev/null
modprobe ipt_MASQUERADE  &> /dev/null

# Alle alten Regeln löschen, anschließend die Default-Policy setzen
$IPTABLES -F
$IPTABLES -X
$IPTABLES -F -t filter
$IPTABLES -F -t nat
$IPTABLES -F -t mangle
$IPTABLES -t filter -X
$IPTABLES -t nat -X
$IPTABLES -t mangle -X

# Wenn keine andere Regel greift, alles verwerfen
$IPTABLES -P INPUT DROP
$IPTABLES -P FORWARD DROP
$IPTABLES -P OUTPUT DROP

# PRE- und POST-Routing in der nat-Tabelle erlauben
$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT

#
#
# Zunächst alle "illegalen" Pakete blocken - trotz der Default-Policy "DROP"
# sinnvoll, einzeln aufzulisten, um sie korrekt zu "REJECT"en und auch
# mitzuloggen.
#
#

# Ersteinmal alles löschen, was generell kaputt ist oder
# Angriffsversuche darstellen könnte.
$IPTABLES -N invalid
$IPTABLES -A INPUT    -m state --state INVALID -i ! $DEV_LOOP -j invalid
$IPTABLES -A FORWARD  -m state --state INVALID -j invalid
$IPTABLES -A INPUT    -m unclean -i ! $DEV_LOOP -j invalid
$IPTABLES -A invalid  -m limit -j LOG --log-prefix "invalid "
$IPTABLES -A invalid  -j REJECT

#
# Scan-Pakete: log and drop
#

# Blocke sog. XMAS-Pakete
$IPTABLES -N xmas
$IPTABLES -A INPUT   -p tcp --tcp-flags ALL ALL -j xmas
$IPTABLES -A FORWARD -p tcp --tcp-flags ALL ALL -j xmas
$IPTABLES -A xmas    -m limit -j LOG --log-level info --log-prefix "xmas-scan "
$IPTABLES -A xmas    -j REJECT

# Blocke NULL Pakete
$IPTABLES -N null_scan
$IPTABLES -A INPUT     -p tcp --tcp-flags ALL NONE -j null_scan
$IPTABLES -A FORWARD   -p tcp --tcp-flags ALL NONE -j null_scan
$IPTABLES -A null_scan -m limit -j LOG --log-level info --log-prefix \
          "null-scan "
$IPTABLES -A null_scan -j REJECT

# Spoofed packets: log and drop
$IPTABLES -N spoofing
$IPTABLES -A INPUT    -i $DEV_LAN -s ! $LOC_NET -j spoofing
$IPTABLES -A FORWARD  -i $DEV_LAN -s ! $LOC_NET -j spoofing
$IPTABLES -A FORWARD  -i $DEV_INET -s 192.168.0.0/16 -j spoofing
$IPTABLES -A FORWARD  -i $DEV_INET -s 172.16.0.0/12 -j spoofing
$IPTABLES -A FORWARD  -i $DEV_INET -s 10.0.0.0/8 -j spoofing
$IPTABLES -A spoofing -m limit -j LOG --log-level info --log-prefix "spoofing "
$IPTABLES -A spoofing -j REJECT

# icmp handling - ICMP-Pakete werden erlaubt, bis auf type 5 (redirect)
$IPTABLES -N icmp_allow
$IPTABLES -N icmp_reject
$IPTABLES -A INPUT -p icmp --icmp-type ! 5 -j icmp_allow
$IPTABLES -A INPUT -i $DEV_INET -p icmp --icmp-type 5 -m limit -j icmp_reject
$IPTABLES -A icmp_allow -j ACCEPT
$IPTABLES -A icmp_reject -m limit -j LOG --log-prefix "icmp_rej "
$IPTABLES -A icmp_reject -j REJECT --reject-with icmp-host-unreachable

#
#
# Freischalten, was auf dem *Router* benötigt wird
#
#

# Bereits bestehende Verbindungen werden immer akzeptiert: das spart
# das expizite freischalten der INPUT-Pakete bei erlaubten Verbindungen
# ein
$IPTABLES -A INPUT   -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A OUTPUT  -m state --state ESTABLISHED,RELATED -j ACCEPT

# Verbindungen zum loopback-Device - Das ist NOTWENDIG
$IPTABLES -N lo_accept
$IPTABLES -A INPUT       -i $DEV_LOOP -m state --state NEW -j lo_accept
$IPTABLES -A OUTPUT      -o $DEV_LOOP -m state --state NEW -j lo_accept
$IPTABLES -A lo_accept   -j ACCEPT

# Pings vom Gateway erlauben
$IPTABLES -N icmp_gate
$IPTABLES -A OUTPUT    -p icmp -j icmp_gate
$IPTABLES -A icmp_gate -j ACCEPT

# Erlaube www/ftp vom Gateway (z. B. beim Update übers Inet)
$IPTABLES -N www_gate
$IPTABLES -A OUTPUT -p tcp --dport 21 -s $IP_INET -m state --state NEW \
          -o $DEV_INET -j www_gate
$IPTABLES -A OUTPUT -p tcp --dport 80 -s $IP_INET -m state --state NEW \
          -o $DEV_INET -j www_gate
$IPTABLES -A www_gate -j ACCEPT

# timeserver: erlaubt das Holen der aktuellen Zeit aus dem Inet
$IPTABLES -N ntp_gate
$IPTABLES -A OUTPUT -p udp --dport 123 -s $IP_INET -m state --state NEW \
          -o $DEV_INET -j ntp_gate
$IPTABLES -A ntp_gate -j ACCEPT

# DNS erlauben
$IPTABLES -N dns_gate
$IPTABLES -A OUTPUT -p udp -o $DEV_INET --dport 53 -m state --state NEW \
          -j dns_gate
$IPTABLES -A dns_gate -j ACCEPT

# ssh-Verbindungen erlauben (aus dem lokalen Netz, vom Gateway nach aussen):
# Bei gewünschten Verbindungen von aussen an das Gateway entpsrechende Zeile
# mit aktivieren!
$IPTABLES -N ssh_gate
$IPTABLES -A OUTPUT -p tcp -m state --state NEW  --dport 22 -j ssh_gate
$IPTABLES -A INPUT  -p tcp -m state --state NEW -s $LOC_NET --dport 22 \
          -d $IP_LAN -j ssh_gate
#$IPTABLES -A INPUT  -p tcp -m state --state NEW -d $IP_INET --dport 22 \
#          -j ssh_gate
$IPTABLES -A ssh_gate -j ACCEPT

# Smtp-Verbindungen vom Gateway nach aussen (und ins LAN) erlauben
$IPTABLES -N smtp_gate
$IPTABLES -A OUTPUT -p tcp -o $DEV_INET -m state --state NEW \
          --dport 25 -j smtp_gate
$IPTABLES -A OUTPUT -p tcp -o $DEV_LAN -m state --state NEW \
          --dport 25 -d $LOC_NET -j smtp_gate
$IPTABLES -A smtp_gate -j ACCEPT

# Pop3-Verbindungen vom Gateway nach aussen erlauben
$IPTABLES -N pop3_gate
$IPTABLES -A OUTPUT -p tcp -o $DEV_INET -m state --state NEW \
          --dport 110 -j pop3_gate
$IPTABLES -A pop3_gate -j ACCEPT

#
#
# Freischalten, was auf den *Clients* benötigt wird
#
#

# Bereits bestehende Verbindungen werden immer akzeptiert: das spart
# das expizite freischalten der INPUT-Pakete bei erlaubten Verbindungen
# ein
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

# NAT/Masquerading ist notwendig
$IPTABLES -t nat -A POSTROUTING -o $DEV_INET -s $LOC_NET -j SNAT \
          --to-source $IP_INET

# Das bekannte MTU/MSS-Spielchen bei ADSL und PPPoE
$IPTABLES -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS \
          --clamp-mss-to-pmtu

# Einige Dienste, die man 100%ig nicht nach draussen lassen will, besonders
# wichtig bei Windowskisten, die sonst so ziemlich alles nach aussen pusten,
# was nur irgendwie gefährlich ist. "It's not a bug, itÄs a feature" - ja ja.
# Für weitere Details zu den Ports: siehe /etc/services
$IPTABLES -A INPUT -p tcp -m multiport \
          --sport 135,137,138,139,67,68,69,23,111,161,1433 -j REJECT
$IPTABLES -A INPUT -p udp -m multiport \
          --sport 135,137,138,139,67,68,69,23,111,161,1433 -j REJECT
$IPTABLES -A INPUT -p tcp -m multiport \
          --dport 135,137,138,139,67,68,69,23,111,161,1433 -j REJECT
$IPTABLES -A INPUT -p udp -m multiport \
          --dport 135,137,138,139,67,68,69,23,111,161,1433 -j REJECT
$IPTABLES -A FORWARD -p tcp -m multiport \
          --sport 135,137,138,139,67,68,69,23,111,161,1433 -j REJECT
$IPTABLES -A FORWARD -p udp -m multiport \
          --sport 135,137,138,139,67,68,69,23,111,161,1433 -j REJECT
$IPTABLES -A FORWARD -p tcp -m multiport \
          --dport 135,137,138,139,67,68,69,23,111,161,1433 -j REJECT
$IPTABLES -A FORWARD -p udp -m multiport \
          --dport 135,137,138,139,67,68,69,23,111,161,1433 -j REJECT

# Für's lokale LAN alles weitere erlauben. Sicherer ist es, wie oben beim
# Gateway jeden einzelnen Dienst freizuschalten. Das ist aber sehr
# zeitaufwendig und da die Rechner nicht direkt von aussen erreichbar sind,
# auch nicht wirklich notwendig
$IPTABLES -N locnet_out
$IPTABLES -A INPUT -s $LOC_NET -i $DEV_LAN -m state --state NEW -j locnet_out
$IPTABLES -A FORWARD -s $LOC_NET -i $DEV_LAN -o $DEV_INET \
          -m state --state NEW -j locnet_out
$IPTABLES -A locnet_out -j ACCEPT

#
#
# Abschluss-Regeln
#
#

# Alles Loggen, was bis jetzt durchgegangen ist. Sollte man sich genauer
# anschauen, wenn das im Log auftaucht
$IPTABLES -A INPUT   -m limit -j LOG --log-prefix "FINAL IN "
$IPTABLES -A OUTPUT  -m limit -j LOG --log-prefix "FINAL OUT "
$IPTABLES -A FORWARD -m limit -j LOG --log-prefix "FINAL FOR "

# Und dann alles abblocken, was bis hierin durchgegangen ist
$IPTABLES -A INPUT   -j REJECT
$IPTABLES -A OUTPUT  -j REJECT
$IPTABLES -A FORWARD -j REJECT

# Forwarding im Kernel nun wieder aktivieren
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/all/proxy_arp

# IP-Spoofing aktivieren - Sollte unter SuSE leichter in /etc/rc.config
# gesetzt werden, ansonsten hier aktivieren
#for f in /proc/sys/net/ipv4/conf/*/rp_filter; do
#      echo 1 > $f
#done


Doch das gebrabbel der Maschine von oben kommt heraus :/
Logged

bootstrap

  • Guest
RE: Try `iptables -h' or 'iptables --help' for more information.
« Reply #1 on: November 01, 2004, 03:44:01 PM »

Hi.

Das Script erwartet Parameter. Wenn da jemand wirklich helfen soll, dann erzähl mal wie/wo/warum du's überhaupt aufgerufen hast.

Übrigens - bevor du ein Script einfach mal eben startest, solltest du versuchen rauszubekommen was es eigentlich macht. Auf diese Art könntest du möglicherweise auch von selbst darauf kommen was das Script eigentlich von dir möchte.

Cheers
Logged