|
发表于 2004-10-15 13:33:35
|
显示全部楼层
给你做了个脚本 ipts2ipt: [code:1]#!/bin/sh
# ipts2ipt --- Convert iptables-save file to iptables commands.
#
# Danny Cat, [email protected]
# Oct 2004
if [ -z $1 ]; then
echo " Usage: `basename $0` iptables-save_file"
exit 1
fi
cat $1 | sed -e '/^#/D' -e 's/\[.*\]$//' -e '/^:.*- $/D' \
-e '/^*mangle/,/COMMIT/s/^:/iptables -t mangle -P /' \
-e '/^*filter/,/COMMIT/s/^:/iptables -t filter -P /' \
-e '/^*nat/,/COMMIT/s/^:/iptables -t nat -P /' \
-e '/^*mangle/,/COMMIT/s/^\[.*\]/iptables -t mangle/' \
-e '/^*filter/,/COMMIT/s/^\[.*\]/iptables -t filter/' \
-e '/^*nat/,/COMMIT/s/^\[.*\]/iptables -t nat/' \
-e '/COMMIT/d' -e 's/^*/\n#/'
[/code:1]
希望对你有用 。 不足之处请自行修改并指出,谢谢。 |
|