1#!/bin/bash 2 3# Make sure iptables-restore without --noflush does not flush tables other than 4# those contained in the dump it's reading from 5 6set -e 7 8$XT_MULTI iptables-restore <<EOF 9*nat 10-A POSTROUTING -j ACCEPT 11COMMIT 12EOF 13 14EXPECT="*nat 15:PREROUTING ACCEPT [0:0] 16:INPUT ACCEPT [0:0] 17:OUTPUT ACCEPT [0:0] 18:POSTROUTING ACCEPT [0:0] 19-A POSTROUTING -j ACCEPT 20COMMIT" 21diff -u -Z <(echo -e "$EXPECT") <($XT_MULTI iptables-save | grep -v '^#') 22 23$XT_MULTI iptables-restore <<EOF 24*filter 25-A FORWARD -j ACCEPT 26COMMIT 27EOF 28 29EXPECT="*filter 30:INPUT ACCEPT [0:0] 31:FORWARD ACCEPT [0:0] 32:OUTPUT ACCEPT [0:0] 33-A FORWARD -j ACCEPT 34COMMIT 35*nat 36:PREROUTING ACCEPT [0:0] 37:INPUT ACCEPT [0:0] 38:OUTPUT ACCEPT [0:0] 39:POSTROUTING ACCEPT [0:0] 40-A POSTROUTING -j ACCEPT 41COMMIT" 42diff -u -Z <(echo -e "$EXPECT") <($XT_MULTI iptables-save | grep -v '^#') 43