HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Rund um die Sicherheit des Systems und die Applikationen
cobrabbs
Posts: 122
Joined: 2002-10-11 13:46
Location: Hauptstatt der Welt -Laatzen
Contact:
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by cobrabbs »

olfi wrote:Hast du bei deinem Apache in der httpd.conf für dieses Verzeichnis Options +FollowSymLinks gesetzt?
ja das hab ich getan ( habe einen subdomain im confixx erstelt für den IAM , taucht nicht in der httpd.conf , sondern ich Arbeite mit WebMin ( dort ist eit ein extra Eintrag für den IAM und dort hab ich es gestzt . :roll:
Und ich würde den Pfad zu den ErrorDoc in der httpd.conf richtig setzen, damit die Fehlermeldung, dass er die Fehlermeldung nicht findet, nicht mehr kommt
ehhm , naja ich weiss leider nicht genau wie ich das machen soll , hab es hier mal gesucht , aber da gibt es ja 100 varianten , naja , so muss ich immer mein erstelltes verzeichniss "error" vom web1 überall hinkopieren , wen ich das vergesse ( so wie hier , Danke für die Info , ist mir garnicht aufgefallen ) dan findet er die ja nicht mehr . Gibt es eine elegantere Lösung für alle webxxx ??? Müsste nicht mehr kopieren .
cobrabbs
Posts: 122
Joined: 2002-10-11 13:46
Location: Hauptstatt der Welt -Laatzen
Contact:
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by cobrabbs »

in der confixx_vhost.conf ist es eingetragen Options +FollowSymLinks

es geht aber trotzdem nicht , grrrrrrrr
ich habe mir eine Index.html gebastellt und schreibe jeden Monat per hand hinzu ... naja nicht die feine Art ..
floschi
Userprojekt
Userprojekt
Posts: 3247
Joined: 2002-07-18 08:13
Location: München
Contact:
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by floschi »

Ã?hm, was jetzt, Confixx oder Webmin?

Es muss innerhalb des betreffenden VHosts in deiner confixx_vhost.conf stehen - und der Apache muss neu gestartet werden.


Gruß

Olfi ;)
kase
Posts: 1031
Joined: 2002-10-14 22:56
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by kase »

schreib ganz ans Ende der httpd.conf

<Directory "/directory/zu/den/iam/html/files">
Options +FollowSymLinks
</Directory>

Danach den Apache restarten, dann müsste es gehen.

Ich hab nämlich gerade selber mal das ganze in den VHost eingetragen, wenn man Confixx drauf hat, bringt das nix, da dass allgemein/übergeordnet -FollowSymLinks setzt (also deaktiviert)

Achtung: Nicht in die confixx_vhosts, da wirds eh wieder überschrieben.
cobrabbs
Posts: 122
Joined: 2002-10-11 13:46
Location: Hauptstatt der Welt -Laatzen
Contact:
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by cobrabbs »

olfi wrote:Ã?hm, was jetzt, Confixx oder Webmin?

Es muss innerhalb des betreffenden VHosts in deiner confixx_vhost.conf stehen - und der Apache muss neu gestartet werden.


Gruß

Olfi ;)
hehehe :lol: hab mich ein wenig dumm ausgedrückt , habe beides
cobrabbs
Posts: 122
Joined: 2002-10-11 13:46
Location: Hauptstatt der Welt -Laatzen
Contact:
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by cobrabbs »

kase wrote:schreib ganz ans Ende der httpd.conf

<Directory "/directory/zu/den/iam/html/files">
Options +FollowSymLinks
</Directory>

Danach den Apache restarten, dann müsste es gehen.

Ich hab nämlich gerade selber mal das ganze in den VHost eingetragen, wenn man Confixx drauf hat, bringt das nix, da dass allgemein/übergeordnet -FollowSymLinks setzt (also deaktiviert)

Achtung: Nicht in die confixx_vhosts, da wirds eh wieder überschrieben.
du hast recht , jetzt geht es :lol: :lol: DANKE :-D
Anonymous
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by Anonymous »

Vielleicht ist das hier noch schöner:

Code: Select all

<Directory "/pfad/zu/den/iam/htmls">
Options +FollowSymLinks
DirectoryIndex current.html
</Directory>
Einfach ans ende der /etc/httpd/conf/httpd.conf

dann habt ihr auch geschmeidig den Index richtig ;o)

Lucas
Anonymous
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by Anonymous »

Hi,

also die installation hat wunderbar bei mir geklappt, aber ich habe bei der Pfandgabe zum www Verzeichniss irgendwo einen Fehler, und ich seh den Wald vor lauter Bäumen nicht mehr :oops:

in der iam_report hab ich stehen:

Code: Select all

IAM=/usr/local/iam
DUMP=/usr/local/iam/dump
WWWDIR=/home/www/web5/html/report
Ich wollte mir den Report anschauen, und hab einen 404er error gekriegt. Ich hab mir dann mal den Pfad der beiden Datein angeschaut, und ist mir was aufgefallen 8O

current.html -> /home/www/web5/html//2003-01.html
last.html -> /home/www/web5/html//2002-12.html

Wie kriege ich diesen "doppel /" weg? Der scheint ja dafür verantwortlich zu sein dass ich die Seiten nicht aufrufen kann


Thx für hilfe :wink:

Yves
kase
Posts: 1031
Joined: 2002-10-14 22:56
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by kase »

WWWDIR=/home/www/web5/html/report/

Oder das Verzeichnis report existiert nicht...
kowtun
Posts: 22
Joined: 2002-09-17 18:10
Location: Hamburg
Contact:
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by kowtun »

Hat jemand eine automatische Lösung, um das dump file am Anfang des Abrechnungszeitraum zu löschen?
Danke!
kowtun
Posts: 22
Joined: 2002-09-17 18:10
Location: Hamburg
Contact:
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by kowtun »

Habe es nun so gelöst:

Code: Select all

#!/bin/bash

#get year / month
MONTH=$(/bin/date '+%B')
YEAR=$(/bin/date'+%Y')

# shutting down iptables
/etc/init.d/iptables stop

# moving dump file
mv /usr/local/iam/dump /home/www/bla/bla/bla/iam_dump_$MONTH.$YEAR.dat

# gzip dump file
/usr/bin/gzip -f /home/www/bla/bla/bla/iam_dump_$MONTH.$YEAR.dat

# starting iptables
/etc/init.d/iptables start
phantom
Posts: 74
Joined: 2003-01-20 18:06
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by phantom »

Hmm... warum fährst Du iptables runter? Ist nicht sonderlich sicher, oder?
kase
Posts: 1031
Joined: 2002-10-14 22:56
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by kase »

vor allem fährt er IP Tables herrunter, bevor er einen Dump gemacht hat. Vor dem iptables stop müsste unbedingt ein iptables dump stehen, dass Herunterfahren von IPtables bringt übrigens herzlich wenig, da er nicht in Echtzeit in die Dump File schreibt, und man so mit der Dump File alles machen kann, was man will, so lange kein iptables dump dazwischen kommt.
kowtun
Posts: 22
Joined: 2002-09-17 18:10
Location: Hamburg
Contact:
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by kowtun »

Ich hätte gedacht das es aus muss da sonst kein verschieben möglich ist.
Also würde ein DUMP und ein anschließender MOVE reichen?
Obwohl mein cronjob eh erst nach dem dump läuft ;)
Anyway, ich werde dann das stoppen und starten lassen und so moven, wenn dies geht.
unknown
Posts: 4
Joined: 2003-02-11 13:49
Contact:
 

fehlermeldung beim start vom IP-table

Post by unknown »

hallo,

ich habe heute IAM installiert und beim start mit "/etc/init.d/iptables start" bekomme ich massig fehlermeldungen der art:
"/lib/modules/2.4.18-19.7.xsmp/kernel/net/ipv4/netfilter/ip_tables.o: insmod /lib/modules/2.4.18-19.7.xsmp/kernel/net/ipv4/net
filter/ip_tables.o failed
/lib/modules/2.4.18-19.7.xsmp/kernel/net/ipv4/netfilter/ip_tables.o: insmod ip_tables failed
iptables v1.2.5: can't initialize iptables table `filter': iptables who? (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
/lib/modules/2.4.18-19.7.xsmp/kernel/net/ipv4/netfilter/ip_tables.o: init_module: Device or resource busy
Hint: insmod errors can be caused by incorrect module parameters, including invalid IO or IRQ parameters.
You may find more information in syslog or the output from dmesg"

weiterhin bekomme ich die Fehlermeldung:
"Writing iptables ip accounting stats: /usr/local/iam/dump
/lib/modules/2.4.18-19.7.xsmp/kernel/net/ipv4/netfilter/ip_tables.o: init_module: Device or resource busy
/lib/modules/2.4.18-19.7.xsmp/kernel/net/ipv4/netfilter/ip_tables.o: insmod /lib/modules/2.4.18-19.7.xsmp/kernel/net/ipv4/net
filter/ip_tables.o failed
/lib/modules/2.4.18-19.7.xsmp/kernel/net/ipv4/netfilter/ip_tables.o: insmod ip_tables failed
iptables v1.2.5: can't initialize iptables table `filter': iptables who? (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded."

wenn ich mit "/etc/init.d/iptables dump" ein dump erstellen will.

der kernel ist der neuste verfügbare 2.4.18-19.7.xsmp

kann jemand helfen?
captaincrunch
Userprojekt
Userprojekt
Posts: 7066
Joined: 2002-10-09 14:30
Location: Dorsten
Contact:
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by captaincrunch »

/lib/modules/2.4.18-19.7.xsmp/kernel/net/ipv4/netfilter/ip_tables.o: insmod ip_tables failed
iptables v1.2.5: can't initialize iptables table `filter': iptables who? (do you need to insmod?)
Sieht fast so aus, als wären die nötigen IPTables-Kernelmodule nicht vorhanden oder fehlerhaft kompiliert ...
DebianHowTo
echo "[q]sa[ln0=aln256%Pln256/snlbx]sb729901041524823122snlbxq"|dc
unknown
Posts: 4
Joined: 2003-02-11 13:49
Contact:
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by unknown »

danke für die schnell antwort, kann ich dies irgendwie rausfinden ob die kernelmodule nicht vorhanden oder falsch kompiliert sind oder gibts da ne andere möglichkeit dies "einzustellen"
captaincrunch
Userprojekt
Userprojekt
Posts: 7066
Joined: 2002-10-09 14:30
Location: Dorsten
Contact:
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by captaincrunch »

Probier mal ein

Code: Select all

modprobe ip_tables
Wenn's da schon hakt, müsstest du mal nähere Angaben zu der Distri machen.
DebianHowTo
echo "[q]sa[ln0=aln256%Pln256/snlbx]sb729901041524823122snlbxq"|dc
unknown
Posts: 4
Joined: 2003-02-11 13:49
Contact:
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by unknown »

also ich habe die alte iptables erstmal wieder zurückgespielt und da ging der start auch problemlos.

mit modprobe ip_tables bekomme ich auch fehler:
/lib/modules/2.4.18-19.7.xsmp/kernel/net/ipv4/netfilter/ip_tables.o: init_module: Device or resource busy
Hint: insmod errors can be caused by incorrect module parameters, including invalid IO or IRQ parameters.
You may find more information in syslog or the output from dmesg
/lib/modules/2.4.18-19.7.xsmp/kernel/net/ipv4/netfilter/ip_tables.o: insmod /lib/modules/2.4.18-19.7.xsmp/kernel/net/ipv4/net
filter/ip_tables.o failed
/lib/modules/2.4.18-19.7.xsmp/kernel/net/ipv4/netfilter/ip_tables.o: insmod ip_tables failed

das system ist Red Hat Linux release 7.2 (Enigma) Kernel 2.4.18-19.7.xsmp on an i686
Dual-Pentium mit Raid-System falls dies wichtig ist?!
markus niewerth
Posts: 54
Joined: 2002-10-20 18:39
Location: Bocholt
Contact:
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by markus niewerth »

Ich habe das mal hier nachgemacht weil ich IAM brauchte wegen der Traffic Kontrolle. Aber was sagt mir das hier:
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

0 0 local all -- eth0 any 192.168.0.0/16 anywhere

0 0 local all -- eth0 any p15114505.pureserver.info anywhe
re
134 303K local all -- lo any anywhere anywhere

259K 79M www tcp -- eth0 any anywhere anywhere
tcp dpt:http
0 0 www tcp -- eth0 any anywhere anywhere
tcp dpt:https
0 0 www tcp -- eth0 any anywhere anywhere
tcp dpt:22202
0 0 ftp tcp -- eth0 any anywhere anywhere
tcp dpts:ftp-data:ftp
0 0 rsync tcp -- eth0 any anywhere anywhere
tcp dpt:rsync
0 0 cvs tcp -- eth0 any anywhere anywhere
tcp dpts:cvspserver:iec870-5-104
0 0 mail tcp -- eth0 any anywhere anywhere
tcp dpt:smtp
266 23665 mail tcp -- eth0 any anywhere anywhere
tcp spt:smtp
1116 60470 misc tcp -- eth0 any anywhere anywhere
tcp dpt:ssh
0 0 misc tcp -- eth0 any anywhere anywhere
tcp dpt:domain
0 0 misc udp -- eth0 any anywhere anywhere
udp dpt:domain
0 0 misc tcp -- eth0 any anywhere anywhere
tcp dpt:ident
342 460K outgoing tcp -- eth0 any anywhere anywhere
tcp spts:0:1024
348 59544 outgoing udp -- eth0 any anywhere anywhere
udp spts:0:1024
13311 1725K ip_local_port_range tcp -- eth0 any anywhere an
ywhere tcp dpts:filenet-tms:61000
1 40 ip_local_port_range tcp -- eth0 any anywhere an
ywhere tcp spts:filenet-tms:61000
0 0 fragment all -f eth0 any anywhere anywhere

6803 448K unknown all -- eth0 any anywhere anywhere


Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination


Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

0 0 local all -- any eth0 anywhere 192.168.0.0/
16
0 0 local all -- any eth0 anywhere p15114505.pu
reserver.info
134 303K local all -- any lo anywhere anywhere

306K 258M www tcp -- any eth0 anywhere anywhere
tcp spt:http
0 0 www tcp -- any eth0 anywhere anywhere
tcp spt:https
0 0 www tcp -- any eth0 anywhere anywhere
tcp spt:22202
0 0 ftp tcp -- any eth0 anywhere anywhere
tcp spts:ftp-data:ftp
0 0 rsync tcp -- any eth0 anywhere anywhere
tcp spt:rsync
0 0 cvs tcp -- any eth0 anywhere anywhere
tcp spts:cvspserver:iec870-5-104
0 0 mail tcp -- any eth0 anywhere anywhere
tcp spt:smtp
213 34586 mail tcp -- any eth0 anywhere anywhere
tcp dpt:smtp
868 128K misc tcp -- any eth0 anywhere anywhere
tcp spt:ssh
0 0 misc tcp -- any eth0 anywhere anywhere
tcp spt:domain
0 0 misc udp -- any eth0 anywhere anywhere
udp spt:domain
0 0 misc tcp -- any eth0 anywhere anywhere
tcp spt:ident
239 14012 outgoing tcp -- any eth0 anywhere anywhere
tcp dpts:0:1024
221 14426 outgoing udp -- any eth0 anywhere anywhere
udp dpts:0:1024
17601 955K ip_local_port_range tcp -- any eth0 anywhere an
ywhere tcp spts:filenet-tms:61000
1 40 ip_local_port_range tcp -- any eth0 anywhere an
ywhere tcp dpts:filenet-tms:61000
0 0 fragment all -f any eth0 anywhere anywhere

6746 1098K unknown all -- any eth0 anywhere anywhere


Chain cvs (2 references)
pkts bytes target prot opt in out source destination

0 0 ACCEPT all -- any any anywhere anywhere


Chain fragment (2 references)
pkts bytes target prot opt in out source destination

0 0 ACCEPT all -- any any anywhere anywhere


Chain ftp (2 references)
pkts bytes target prot opt in out source destination

0 0 ACCEPT all -- any any anywhere anywhere


Chain ip_local_port_range (4 references)
pkts bytes target prot opt in out source destination

30914 2680K ACCEPT all -- any any anywhere anywhere


Chain local (6 references)
pkts bytes target prot opt in out source destination

268 606K ACCEPT all -- any any anywhere anywhere


Chain mail (4 references)
pkts bytes target prot opt in out source destination

479 58251 ACCEPT all -- any any anywhere anywhere


Chain misc (8 references)
pkts bytes target prot opt in out source destination

1984 189K ACCEPT all -- any any anywhere anywhere


Chain outgoing (4 references)
pkts bytes target prot opt in out source destination

1150 548K ACCEPT all -- any any anywhere anywhere


Chain rsync (2 references)
pkts bytes target prot opt in out source destination

0 0 ACCEPT all -- any any anywhere anywhere


Chain unknown (2 references)
pkts bytes target prot opt in out source destination

13549 1547K ACCEPT all -- any any anywhere anywhere


Chain www (6 references)
pkts bytes target prot opt in out source destination

565K 337M ACCEPT all -- any any anywhere anywhere
Und vor allem, wieso Listet die Webauswertung nicht alles das auf, was auch IP Tables auf der Console auflistet. Wo bekomm ich eine genaue Anleitung zu IAM (englisch oder deutsch) ?

Gruß Markus

EDIT:

Ich habe grade nochmal ein

Code: Select all

./iam -r dump
gemacht, aber die Werte stimmen nicht, der FTP zeigt mir 0 MB an, der HTTP ca. 300MB - geflossen sind aber: 700MB HTTPD und ca. 2GB andere Services. Jetzt bin ich keinen Schritt weiter, sondern es ist alles noch ungenauer. Was habe ich falsch gemacht. Ich bin strikt nach Anleitung vorgegangen. ???
kase
Posts: 1031
Joined: 2002-10-14 22:56
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by kase »

@ Markus Niewerth: Auch wenns jetzt total OT ist, deine Sig is cool !
distanzcheck
Posts: 531
Joined: 2003-01-09 08:58
Location: NRW
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by distanzcheck »

Habe dieses in der httpd.conf eingetrage

Code: Select all

<Directory "/home/www/web1/html/iam/report/">
Options +FollowSymLinks
DirectoryIndex current.html
</Directory>
wenn ich aber nun domain.de/iam/report/last.html oder curent.html aufrufe bekomme ich immer noch die fehlermeldungen.

Apache habe ich neu gestartet!

Dirk
kase
Posts: 1031
Joined: 2002-10-14 22:56
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by kase »

Fällt mir auf Anhieb nur ein, dass du vielleicht noch ein * nach /report/ machen könntest, oder dass du das ganze nicht ganz ans Ende der httpd.conf geschieben hast, und es weiter unten wieder überschrieben wird
distanzcheck
Posts: 531
Joined: 2003-01-09 08:58
Location: NRW
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by distanzcheck »

aufeinmal gehts, frage aber nicht warum, habe nix mehr geändert!

Dirk
distanzcheck
Posts: 531
Joined: 2003-01-09 08:58
Location: NRW
 

Re: HOWTO: Standardinstallation von IAM zur Traffic-Kontrolle

Post by distanzcheck »

habe aber nun in der 7var/log/warn viele dieser einträge

Code: Select all

Feb 10 09:23:01 p15112076 modprobe: modprobe: Can't locate module binfmt-0000
Feb 10 09:23:01 p15112076 modprobe: modprobe: Can't locate module binfmt-0000
Feb 10 14:25:01 p15112076 modprobe: modprobe: Can't locate module binfmt-0000
Feb 10 14:25:01 p15112076 modprobe: modprobe: Can't locate module binfmt-0000
Feb 10 14:27:01 p15112076 modprobe: modprobe: Can't locate module binfmt-0000
Feb 10 14:27:01 p15112076 modprobe: modprobe: Can't locate module binfmt-0000
Feb 10 14:29:01 p15112076 last message repeated 2 times
Feb 10 14:31:01 p15112076 modprobe: modprobe: Can't locate module binfmt-0000
Feb 10 14:31:01 p15112076 modprobe: modprobe: Can't locate module binfmt-0000
Feb 10 14:33:01 p15112076 last message repeated 2 times
Feb 10 14:35:01 p15112076 modprobe: modprobe: Can't locate module binfmt-0000
Feb 10 14:35:01 p15112076 modprobe: modprobe: Can't locate module binfmt-0000
Feb 10 14:37:01 p15112076 last message repeated 2 times
wie bekomme ich diesen fehler weg ?

das ist meine itables

Code: Select all

#! /bin/sh
#
# iptables ip accounting
#
# chkconfig: 2345 08 92
# description: iptables ip accounting

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=iptables
DESC="iptables ip accounting"

DUMPFILE=/usr/local/iam/dump

#set -x

extif=eth0
extip=xxx.xxx.xxx.xxx
intif=lo
intnet=192.168.0.0/16

ip_local_port_range=`cat /proc/sys/net/ipv4/ip_local_port_range|tr 't' ':'`

start_firewall() {
	flush
	allow_all

# free of charge

	new_chain local
	acc_ip local $intnet
	acc_ip local $extip
	iptables -A OUTPUT -o $intif -j local
	iptables -A INPUT -i $intif -j local

	
# internet services

	new_chain www
	acc_port www www
	acc_port www https
	acc_port www 22202  # Caudium Config

	new_chain ftp
	acc_port ftp ftp-data:ftp

	new_chain rsync
	acc_port rsync rsync

	new_chain cvs
	acc_port cvs 2401:2404

	new_chain mail
	acc_port mail smtp
	acc_port_out mail smtp

	new_chain misc
	acc_port misc ssh
	acc_port misc domain
	acc_port misc domain udp
	acc_port misc auth

	new_chain outgoing
	acc_port_out outgoing 0:1024
	acc_port_out outgoing 0:1024 udp

	new_chain ip_local_port_range
	acc_port ip_local_port_range $ip_local_port_range
	acc_port_out ip_local_port_range $ip_local_port_range

# other traffic (unspecified)

	new_chain related
	acc_ip related 0/0 -m state --state RELATED

	new_chain fragment
	acc_ip fragment 0/0 -f

	new_chain unknown
	acc_ip unknown 0/0
}

# acc_ip table ip [args]
acc_ip () {
	CHAIN=$1; shift
	IP=$1; shift
	iptables -A OUTPUT -o $extif -d $IP -j $CHAIN "$@"
	iptables -A INPUT -i $extif -s $IP -j $CHAIN "$@"
}

# acc_port table port [protocol]
acc_port () {
	iptables -A OUTPUT -o $extif -p ${3:-tcp} --sport $2 -j $1
	iptables -A INPUT -i $extif -p ${3:-tcp} --dport $2 -j $1
}

# acc_port_out table port [protocol]
acc_port_out () {
	iptables -A OUTPUT -o $extif -p ${3:-tcp} --dport $2 -j $1
	iptables -A INPUT -i $extif -p ${3:-tcp} --sport $2 -j $1
}

new_chain() {
	CHAIN=$1; shift
	TARGET=$1; shift
	iptables -N $CHAIN
	iptables -A $CHAIN -j ${TARGET:-ACCEPT} "$@"
}

deny_all() {
	iptables -t filter -P INPUT DROP
	iptables -t filter -P FORWARD DROP
	iptables -t filter -P OUTPUT DROP
}

allow_all() {
	iptables -t filter -P INPUT ACCEPT
	iptables -t filter -P FORWARD ACCEPT
	iptables -t filter -P OUTPUT ACCEPT
}

dump_stats() {
	DATE=`date '+%Y%m%d%H%M%S'`
	echo "START $DATE" >> $DUMPFILE
	iptables -vnxZ -L --line-numbers -t filter >> $DUMPFILE
	#iptables -vnxZ -L --line-numbers -t nat >> $DUMPFILE
	echo "END $DATE" >> $DUMPFILE
}

flush() {
	dump_stats
	iptables -t filter -F
	iptables -t filter -X
}

status() {
	echo
	echo "**** Filter Tables:"
	echo
	iptables -vnx -L --line-numbers -t filter
	#iptables -vnx -L --line-numbers -t nat
	echo
}


case "$1" in
  start)
	echo -n "Starting $DESC: "
	start_firewall
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	flush
	allow_all
	echo "$NAME."
	;;
  reload|force-reload)
	echo "Reloading $DESC configuration:"
	start_firewall
	echo "$NAME."
  	;;
  restart)
	echo -n "Restarting $DESC: "
	flush
	allow_all
	sleep 1
	start_firewall
	echo "$NAME."
	;;
  status)
	echo "Current $DESC configuration:"
	status
  	;;
  dump)
	echo "Writing $DESC stats: $DUMPFILE"
	dump_stats
  	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|force-reload|status|dump}" >&2
	exit 1
	;;
esac

exit 0
Post Reply