Archiv verlassen und diese Seite im Standarddesign anzeigen : iptables Redhat 7.3
hat jemand eine ahnung in welche datei die filteregeln kommen direkt /etc/init.d/iptables
starte im mom ein script was die regeln setzt die sind aber bei reboot wieder weg und das muss ja auch ohne script direckt gehen ??
/etc/sysconfig/iptables
Schreiben über "service iptables save" bzw. "iptables-save > /etc/sysconfig/iptables".
IPTABLES_CONFIG=/etc/sysconfig/iptables
und meine filterregeln in der datei sehen dann so aus
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
iptables -A INPUT -p icmp -s 192.168.0.0 -j ACCEPT
iptables -A INPUT -p icmp -j DROP
iptables -t nat -A PREROUTING -p tcp --dport 4662 -i ppp0 -j DNAT --to 192.168.0.1:4662
iptables -t nat -A PREROUTING -p tcp --dport 4661 -i ppp0 -j DNAT --to 192.168.0.1:4661
iptables -t nat -A PREROUTING -p udp --dport 4665 -i ppp0 -j DNAT --to 192.168.0.1:4665
iptables -t nat -A PREROUTING -p tcp --dport 3000 -i ppp0 -j DNAT --to 192.168.0.100:80
aber es futzt nicht nur wenn ich die in ein script packe und ausführe
Lies mein vorheriges Posting bitte noch einmal ganz langsam.
sorry aber ich mache das zum ersten mal
#!/bin/sh
# config: /etc/sysconfig/iptables
# Source 'em up
. /etc/init.d/functions
IPTABLES_CONFIG=/etc/sysconfig/iptables
if [ ! -x /sbin/iptables ]; then
exit 0
fi
KERNELMAJ=`uname -r | sed -e 's,\..*,,'`
KERNELMIN=`uname -r | sed -e 's,[^\.]*\.,,' -e 's,\..*,,'`
if [ "$KERNELMAJ" -lt 2 ] ; then
exit 0
fi
if [ "$KERNELMAJ" -eq 2 -a "$KERNELMIN" -lt 3 ] ; then
exit 0
fi
if /sbin/lsmod 2>/dev/null |grep -q ipchains ; then
# Don't do both
exit 0
fi
iftable() {
if fgrep -qsx $1 /proc/net/ip_tables_names; then
iptables -t "$@"
fi
}
start() {
# don't do squat if we don't have the config file
if [ -f $IPTABLES_CONFIG ]; then
# If we don't clear these first, we might be adding to
# pre-existing rules.
action $"Flushing all current rules and user defined chains:" iptables -F
action $"Clearing all current rules and user defined chains:" iptables -X
chains=`cat /proc/net/ip_tables_names 2>/dev/null`
for i in $chains; do iptables -t $i -F; done && \
success $"Flushing all current rules and user defined chains:" || \
failure $"Flushing all current rules and user defined chains:"
for i in $chains; do iptables -t $i -X; done && \
success $"Clearing all current rules and user defined chains:" || \
failure $"Clearing all current rules and user defined chains:"
for i in $chains; do iptables -t $i -Z; done
echo $"Applying iptables firewall rules: "
grep -v "^[[:space:]]*#" $IPTABLES_CONFIG | grep -v '^[[:space:]]*$' | /sbin/iptables-restore -c && \
success $"Applying iptables firewall rules" || \
failure $"Applying iptables firewall rules"
echo
touch /var/lock/subsys/iptables
fi
}
stop() {
chains=`cat /proc/net/ip_tables_names 2>/dev/null`
for i in $chains; do iptables -t $i -F; done && \
success $"Flushing all chains:" || \
failure $"Flushing all chains:"
for i in $chains; do iptables -t $i -X; done && \
success $"Removing user defined chains:" || \
failure $"Removing user defined chains:"
echo -n $"Resetting built-in chains to the default ACCEPT policy:"
iftable filter -P INPUT ACCEPT && \
iftable filter -P OUTPUT ACCEPT && \
iftable filter -P FORWARD ACCEPT && \
iftable nat -P PREROUTING ACCEPT && \
iftable nat -P POSTROUTING ACCEPT && \
iftable nat -P OUTPUT ACCEPT && \
iftable mangle -P PREROUTING ACCEPT && \
iftable mangle -P OUTPUT ACCEPT && \
success $"Resetting built-in chains to the default ACCEPT policy" || \
failure $"Resetting built-in chains to the default ACCEPT policy"
echo
rm -f /var/lock/subsys/iptables
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
# "restart" is really just "start" as this isn't a daemon,
# and "start" clears any pre-defined rules anyway.
# This is really only here to make those who expect it happy
start
;;
condrestart)
[ -e /var/lock/subsys/iptables ] && start
;;
status)
tables=`cat /proc/net/ip_tables_names 2>/dev/null`
for table in $tables; do
echo $"Table: $table"
iptables -t $table --list
done
;;
panic)
echo -n $"Changing target policies to DROP: "
iftable filter -P INPUT DROP && \
iftable filter -P FORWARD DROP && \
iftable filter -P OUTPUT DROP && \
iftable filter -P OUTPUT DROP && \
iftable nat -P PREROUTING DROP && \
iftable nat -P POSTROUTING DROP && \
iftable nat -P OUTPUT DROP && \
iftable mangle -P PREROUTING DROP && \
iftable mangle -P OUTPUT DROP && \
success $"Changing target policies to DROP" || \
failure $"Changing target policies to DROP"
echo
iftable filter -F INPUT && \
iftable filter -F FORWARD && \
iftable filter -F OUTPUT && \
iftable nat -F PREROUTING && \
iftable nat -F POSTROUTING && \
iftable nat -F OUTPUT && \
iftable mangle -F PREROUTING && \
iftable mangle -F OUTPUT && \
success $"Flushing all chains:" || \
failure $"Flushing all chains:"
iftable filter -X INPUT && \
iftable filter -X FORWARD && \
iftable filter -X OUTPUT && \
iftable nat -X PREROUTING && \
iftable nat -X POSTROUTING && \
iftable nat -X OUTPUT && \
iftable mangle -X PREROUTING && \
iftable mangle -X OUTPUT && \
success $"Removing user defined chains:" || \
failure $"Removing user defined chains:"
;;
save)
echo -n $"Saving current rules to $IPTABLES_CONFIG: "
touch $IPTABLES_CONFIG
chmod 600 $IPTABLES_CONFIG
/sbin/iptables-save -c > $IPTABLES_CONFIG 2>/dev/null && \
success $"Saving current rules to $IPTABLES_CONFIG" || \
failure $"Saving current rules to $IPTABLES_CONFIG"
echo
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status|panic|save}"
exit 1
esac
exit 0
Ähm, was soll das bitte? Das ist der Inhalt von /etc/init.d/iptables. Schau mal, was dort mit /etc/sysconfig/iptables gemacht wird und dann lies meine erste Antwort nochmal und probier auch wenigstens einmal, was ich dort geschrieben habe. Und wenn Du etwas nicht glaubst oder meinst, etwas würde nicht funktionieren, dann fasse das bitte in Worte.
:rolleyes:
toll raffen tu ich das trozdem nich was wo mit iptables gemacht wird
Nein, Dein Problem ist, daß Du Dir nicht die Mühe machst, Dein wahres Problem in Worten zu beschreiben. Das ist nämlich zum einen, daß Du noch keinen Blick in die Dokumentation von Red Hat geworfen hast (also z.B. den "service" Befehl nicht kennst). Und zum anderen, daß Du mein erstes Posting entweder garnicht gelesen oder noch immer nicht ausprobiert hast, was ich dort geschrieben habe. In Deinen Antworten stellst Du zudem überhaupt keinen Bezug zu meiner Antwort her. Wozu nenne ich Dir die Kommandos zum Beschreiben der Datei, wenn Du es ignorierst?
Die Regeln kommen in /etc/sysconfig/iptables, aber nicht als Shell-Skript, sondern als Ausgabe von iptables-save, damit sie von iptables-restore verarbeitet werden können. Und genau das tut "/etc/init.d/iptables start" nämlich bzw. "service iptables start". Und wenn Du jetzt meine erste Antwort liest und irgendwas immernoch nicht verstanden haben solltest, bitte detailiert beschreiben, was!
ich soll also bei
/sbin/iptables-save -c > $IPTABLES_CONFIG 2>/dev/null && \
$IPTABLES_CONFIG 2>/dev/null && \ durch > /etc/sysconfig/iptables
ersetzen ??
ich soll also bei
/sbin/iptables-save -c > $IPTABLES_CONFIG 2>/dev/null && \
$IPTABLES_CONFIG 2>/dev/null && \ durch > /etc/sysconfig/iptables
ersetzen ??
Bei allem Respekt, aber wie kommst Du auf so einen Stuß? :rolleyes:
Du sollst Deine Filterregeln laden (entweder manuell eingeben oder per Shell-Skript), dann service iptables save aufrufen (oder wie ich es bereits in der ersten Antwort schrieb!) und danach einen Blick in /etc/sysconfig/iptables werfen und endlich mal meine erste Antwort ganz oben gründlich lesen. Dann schaltest Du den Service "iptables" noch ein, damit er beim Booten gestartet wird: chkconfig iptables on
Zusätzlich kannst Du die Regeln dann mit service iptables stop und service iptables start laden und entfernen.
Was Du da mit dem SysV initscript /etc/init.d/iptables machen willst, keine Ahnung. Ist wildes Gehacke. :ugly:
danke jetzt habe ich es gerafft "service iptables save" schreibt alle regeln die ich bisher mit meinem script aktiviert habe in die /etc/sysconfig/iptables und "chkconfig iptables on" sogt dafür das die regeln bein nächsten booten aus der etc/sysconfig/iptables angewendet werden
richtig ???
Ja, jetzt scheints zu klickern. ;)
Was "service iptables save" sonst noch so macht, kannst Du in /etc/init.d/iptables herauslesen. Hauptsächlich aber erledigt es ein "iptables-save > /etc/sysconfig/iptables".
Für chkconfig ruf mal "chkconfig --list" auf. Vielleicht klickert es dann nochmal. ;)
Powered by vBulletin® Version 4.2.5 Copyright ©2024 Adduco Digital e.K. und vBulletin Solutions, Inc. Alle Rechte vorbehalten.