4 # VERY simple access control script for leeenux
7 export PATH
=/tmp
/sbin
:/tmp
/bin
:/bin
:/usr
/bin
:/sbin
:/usr
/sbin
14 if [ -z "$action" -o -z "$mac" -o -z "$ip" -o -z "$class" ]; then
15 echo Usage
: $0 [permit\|deny
] [MAC
] [IP
] [Class
]
16 echo Example
: $0 permit
00:02:2d
:aa
:bb
:cc
10.0.0.105 member
20 if [ "$action" = "permit" ]; then
21 #I prefer that the older connections fall off the end of the table -TJ
24 elif [ "$action" = "deny" ]; then
28 echo "FATAL: Bad action: $action!"
32 if [ "$class" = "Owner" ]; then
34 elif [ "$class" = "Member" ]; then
36 elif [ "$class" = "Public" ]; then
39 echo "FATAL: Bad class: $class!"
43 # Mark outbound traffic from this node.
44 # Because we use insert, we must insert below rule 1,
45 # since rule 1 starts out by marking packets not authed via this chain as such (class 4)
46 iptables
-t mangle
$cmd NoCat
$pos -m mac
--mac-source $mac -s $ip -j MARK
--set-mark $mark
48 # Traffic counting in FORWARDED chains
49 if [ "$InternalDevice" ]; then
50 iptables
-t filter
$cmd NoCat_Download
-o $InternalDevice -d $ip -j RETURN
51 iptables
-t filter
$cmd NoCat_Upload
-i $InternalDevice -s $ip -j RETURN
53 iptables
-t filter
$cmd NoCat_Download
-d $ip -j RETURN
54 iptables
-t filter
$cmd NoCat_Upload
-s $ip -j RETURN
57 # Mark inbound RELATED,ESTABLISHED traffic to this node as ACCEPT
58 iptables
-t filter
$cmd NoCat_Inbound
-d $ip -m state
--state RELATED
,ESTABLISHED
-j ACCEPT