Current time: 06-28-2024, 04:10 AM Hello There, Guest! (LoginRegister)


Thread Closed 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[HOWTO] IPtables nach rebbot / shutdown
Author Message
Darkside2009 Offline
Junior Member
*

Posts: 80
Joined: Nov 2009
Reputation: 1
Post: #1
[HOWTO] IPtables nach rebbot / shutdown
Ich weis nicht ob es hier schon angesprochen wurde, aber die suche dazu hat mir nicht geholfen.Deshalb hier mal ein kleines Howto für IPtables.

Sicher gibt es hier einige die fail2ban einsetzen. Nur hab ihr nach einem reboot /shutdown folgenden befehl einmal ausgeführt :
Quote:iptables -nL
alles was fail2ban dort bisher eingetragen hat ist verschwunden.
folgender kleiner trick hilft da schon.

als erstes erstellt ihr folgendes kleines script :
Quote: vi /root/backup_iptables
fügt folgenden code in das script ein:
Quote:logrotate -f /root/iptables_backup
iptables-save -c > /etc/iptables.conf
für logrotate brauchen wir noch folgende conf datei :
Quote:vi /root/iptables_backup
mit folgendem inhalt :
Quote:/etc/iptables.conf {
rotate 5
compress
}
erstellt einen neuen cron-auftrag den ihr stündlich ausführen lasst. den befehl der im cron ausgeführt werden soll ist folgender :
Quote:/root/backup_iptables

danach erstellt ihr ein kleines script, welches beim reboot / shutdown ausgeführt wird und die iptables.conf wieder einliest.

Quote:vi /etc/network/if-pre-up.d/iptables

jetzt folgenden inhalt dort einfügen :
Quote:#!/bin/sh

# Load iptables rules before interfaces are brought online
# This ensures that we are always protected by the firewall
#
# Note: if bad rules are inadvertently (or purposely) saved it could block
# access to the server except via the serial tty interface.
#

RESTORE=/sbin/iptables-restore
STAT=/usr/bin/stat
IPSTATE=/etc/iptables.conf

test -x $RESTORE || exit 0
test -x $STAT || exit 0

# Check permissions and ownership (rw------- for root)
if test `$STAT --format="%a" $IPSTATE` -ne "600"; then
echo "Permissions for $IPSTATE must be 600 (rw-------)"
exit 0
fi

# Since only the owner can read/write to the file, we can trust that it is
# secure. We need not worry about group permissions since they should be
# zeroed per our previous check; but we must make sure root owns it.
if test `$STAT --format="%u" $IPSTATE` -ne "0"; then
echo "The superuser must have ownership for $IPSTATE (uid 0)"
exit 0
fi

# Now we are ready to restore the tables
$RESTORE < $IPSTATE
das script vorher testen bevor ihr rebootet. evtl. die iptables.conf in /etc auf chmod 600 setzen. wenn alles ok, könnt ihr ja mal einen reboot machen und danach dann mit
Quote:iptables -nL
nachsehen ob alles wieder beim alten ist

im anhang sind alle scripte vorhanden


Attached File(s)
.tar  backupiptables.tar (Size: 10 KB / Downloads: 6)
(This post was last modified: 02-23-2010 01:55 AM by BeNe.)
02-21-2010 12:33 PM
Find all posts by this user
Knut Offline
Member
***

Posts: 736
Joined: Nov 2006
Reputation: 10
Post: #2
RE: IPtables nach rebbot / shutdown
Nett :-)
Kannst Du gerne auch ins Wiki übertragen.


Gruß Knut
02-21-2010 03:42 PM
Find all posts by this user
Darkside2009 Offline
Junior Member
*

Posts: 80
Joined: Nov 2009
Reputation: 1
Post: #3
RE: IPtables nach rebbot / shutdown
(02-21-2010 03:42 PM)Knut Wrote:  Nett :-)
Kannst Du gerne auch ins Wiki übertragen.


Gruß Knut

wenn du mir jetzt noch sagts, wie ich das ins wiki übertrage, würde ich das gerne machen
Cool
02-22-2010 12:45 AM
Find all posts by this user
gOOvER Offline
Banned

Posts: 3,561
Joined: Jul 2007
Post: #4
RE: IPtables nach rebbot / shutdown
Da es Deutsch ist, hab ich es mal in den deutschen Bereich verschoben Smile
02-22-2010 01:15 AM
Visit this user's website Find all posts by this user
Darkside2009 Offline
Junior Member
*

Posts: 80
Joined: Nov 2009
Reputation: 1
Post: #5
RE: IPtables nach rebbot / shutdown
(02-22-2010 01:15 AM)gOOvER Wrote:  Da es Deutsch ist, hab ich es mal in den deutschen Bereich verschoben Smile

was sollten wir " ohne " dich hier nur machen .... ? Big Grin

hast dir nen keks mit ner tasse tee verdient Cool
02-22-2010 01:35 AM
Find all posts by this user
Knut Offline
Member
***

Posts: 736
Joined: Nov 2006
Reputation: 10
Post: #6
RE: IPtables nach rebbot / shutdown
Guckst mal drüber obs noch so passt: http://www.isp-control.net/documentation...t_erhalten

Knut
02-22-2010 01:49 AM
Find all posts by this user
Darkside2009 Offline
Junior Member
*

Posts: 80
Joined: Nov 2009
Reputation: 1
Post: #7
RE: IPtables nach rebbot / shutdown
(02-22-2010 01:49 AM)Knut Wrote:  Guckst mal drüber obs noch so passt: http://www.isp-control.net/documentation...t_erhalten

Knut

hab noch eine kleine änderung vorgenommen. musste
Quote:chmod 644
sein

danke dir
02-22-2010 01:58 AM
Find all posts by this user
Knut Offline
Member
***

Posts: 736
Joined: Nov 2006
Reputation: 10
Post: #8
RE: IPtables nach rebbot / shutdown
Ahh... OK. Nun hast Du ja auch selbst einen Wiki-Account Smile
02-22-2010 02:06 AM
Find all posts by this user
Thread Closed 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)