1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
#!/bin/sh
#set -x
set -e
ipset=${IPSET_BIN:-../src/ipset}
case "$1" in
-4)
ip=10.0.
sep=.
net=32
ip2=192.168.162.33
;;
-6)
ip=10::
sep=:
net=128
ip2=192:168::162:33
;;
esac
case "$2" in
ip)
$ipset n test hash:ip $1 hashsize 64 timeout 100
for x in `seq 0 16`; do
for y in `seq 0 255`; do
$ipset a test $ip$x$sep$y
done
done
;;
ipmark)
$ipset n test hash:ip,mark $1 hashsize 64 timeout 100
for x in `seq 0 16`; do
for y in `seq 0 255`; do
$ipset a test $ip$x$sep$y,1023
done
done
;;
ipport)
$ipset n test hash:ip,port $1 hashsize 64 timeout 100
for x in `seq 0 16`; do
for y in `seq 0 255`; do
$ipset a test $ip$x$sep$y,1023
done
done
;;
ipportip)
$ipset n test hash:ip,port,ip $1 hashsize 64 timeout 100
for x in `seq 0 16`; do
for y in `seq 0 255`; do
$ipset a test $ip$x$sep$y,1023,$ip2
done
done
;;
ipportnet)
$ipset n test hash:ip,port,net $1 hashsize 64 timeout 100
for x in `seq 0 16`; do
for y in `seq 0 255`; do
$ipset a test $ip$x$sep$y,1023,$ip2/$net
done
done
;;
netportnet)
$ipset n test hash:net,port,net $1 hashsize 64 timeout 100
for x in `seq 0 16`; do
for y in `seq 0 128`; do
$ipset a test $ip$x$sep$y/$net,1023,$ip$y$sep$x/$net
done
done
;;
net)
$ipset n test hash:net $1 hashsize 64 timeout 100
for x in `seq 0 16`; do
for y in `seq 0 255`; do
$ipset a test $ip$x$sep$y/$net
done
done
;;
netnet)
$ipset n test hash:net,net $1 hashsize 64 timeout 100
for x in `seq 0 16`; do
for y in `seq 0 255`; do
$ipset a test $ip$x$sep$y/$net,$ip$y$sep$x/$net
done
done
;;
netport)
$ipset n test hash:net,port $1 hashsize 64 timeout 100
for x in `seq 0 16`; do
for y in `seq 0 255`; do
$ipset a test $ip$x$sep$y/$net,1023
done
done
;;
netiface)
$ipset n test hash:net,iface $1 hashsize 64 timeout 100
for x in `seq 0 16`; do
for y in `seq 0 255`; do
$ipset a test $ip$x$sep$y/$net,eth0
done
done
;;
esac
$ipset l test | grep ^$ip | while read x y z; do
if [ $z -lt 10 -o $z -gt 100 ]; then
exit 1
fi
done
$ipset x
exit 0
|