blob: 5a3e922e50672abaa03a9284e1cce1b6725f2c40 (
plain)
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
|
#!/bin/bash
# test rule replacement
set -e
# show rules, drop uninteresting policy settings
ipt_show() {
$XT_MULTI iptables -S | grep -v '^-P'
}
$XT_MULTI iptables -A FORWARD -m comment --comment "rule 1" -j ACCEPT
$XT_MULTI iptables -A FORWARD -m comment --comment "rule 2" -j ACCEPT
$XT_MULTI iptables -A FORWARD -m comment --comment "rule 3" -j ACCEPT
$XT_MULTI iptables -R FORWARD 2 -m comment --comment "replaced 2" -j ACCEPT
EXPECT='-A FORWARD -m comment --comment "rule 1" -j ACCEPT
-A FORWARD -m comment --comment "replaced 2" -j ACCEPT
-A FORWARD -m comment --comment "rule 3" -j ACCEPT'
diff -u -Z <(echo -e "$EXPECT") <(ipt_show)
$XT_MULTI iptables -R FORWARD 1 -m comment --comment "replaced 1" -j ACCEPT
EXPECT='-A FORWARD -m comment --comment "replaced 1" -j ACCEPT
-A FORWARD -m comment --comment "replaced 2" -j ACCEPT
-A FORWARD -m comment --comment "rule 3" -j ACCEPT'
diff -u -Z <(echo -e "$EXPECT") <(ipt_show)
$XT_MULTI iptables -R FORWARD 3 -m comment --comment "replaced 3" -j ACCEPT
EXPECT='-A FORWARD -m comment --comment "replaced 1" -j ACCEPT
-A FORWARD -m comment --comment "replaced 2" -j ACCEPT
-A FORWARD -m comment --comment "replaced 3" -j ACCEPT'
diff -u -Z <(echo -e "$EXPECT") <(ipt_show)
|