-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Ubuntu 18.04 and Ubuntu 20.04 support (#2)
* initial Ubuntu 18.04 support * fix iptables commands to vars * Backported netfilter-persistent plugins from ipset-persistent for ipset persistence (Only for Ubuntu 18.04) * add support for Ubuntu 20.04 LTS * Update README * update meta
- Loading branch information
1 parent
80e3e95
commit cbaaf3c
Showing
14 changed files
with
438 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | ||
Upstream-Name: iptables-persistent | ||
Upstream-Contact: Jonathan Wiltshire <[email protected]> | ||
|
||
Files: * | ||
Copyright: © 2009, Simon Richter <[email protected]> | ||
© 2010, Chris Silva <[email protected]> | ||
© 2010, Jonathan Wiltshire <[email protected]> | ||
© 2018, gustavo panizzo <[email protected]> | ||
License: GPL-3 | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
. | ||
This package is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
. | ||
On Debian systems, the complete text of the GNU General | ||
Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/sh | ||
|
||
# This file is part of netfilter-persistent | ||
# (was iptables-persistent) | ||
# Copyright (C) 2018, gustavo panizzo <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation, either version 3 | ||
# of the License, or (at your option) any later version. | ||
|
||
# This script saves and/or restores ipset(s) to/from a file | ||
# Flush is implemented in another script, as it has to run after | ||
# iptables flush | ||
|
||
set -e | ||
|
||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
|
||
# Source configuration | ||
if [ -f "/etc/default/netfilter-persistent" ]; then | ||
. /etc/default/netfilter-persistent | ||
fi | ||
|
||
# Create the ipsets and populate them | ||
load_sets () | ||
{ | ||
#load ipset rules | ||
if [ ! -f /etc/iptables/ipsets ]; then | ||
echo "Warning: skipping IPv4 (no rules to load)" | ||
else | ||
ipset restore -exist < /etc/iptables/ipsets | ||
fi | ||
} | ||
|
||
# Save current contents of the ipsets to file | ||
save_sets () | ||
{ | ||
if [ ! "${IPSET_SKIP_SAVE}x" = "yesx" ]; then | ||
touch /etc/iptables/ipsets | ||
chmod 0640 /etc/iptables/ipsets | ||
ipset save > /etc/iptables/ipsets | ||
fi | ||
} | ||
|
||
# flush sets | ||
flush_sets () | ||
{ | ||
: | ||
} | ||
|
||
|
||
case "$1" in | ||
start|restart|reload|force-reload) | ||
load_sets | ||
;; | ||
save) | ||
save_sets | ||
;; | ||
stop) | ||
# While it makes sense to stop (delete) ipsets we keep the same | ||
# semanthics as ip(6)?tables rules | ||
echo "Automatic flushing disabled, use \"flush\" instead of \"stop\"" | ||
;; | ||
flush) | ||
flush_sets | ||
;; | ||
*) | ||
echo "Usage: $0 {start|restart|reload|force-reload|save|flush}" >&2 | ||
exit 1 | ||
;; | ||
esac |
78 changes: 78 additions & 0 deletions
78
files/ubuntu/iptables-persistent_1.0.14/plugins/15-ip4tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/sh | ||
|
||
# This file is part of netfilter-persistent | ||
# (was iptables-persistent) | ||
# Copyright (C) 2009, Simon Richter <[email protected]> | ||
# Copyright (C) 2010, 2014 Jonathan Wiltshire <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation, either version 3 | ||
# of the License, or (at your option) any later version. | ||
|
||
set -e | ||
|
||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
|
||
# Source configuration | ||
if [ -f "/etc/default/netfilter-persistent" ]; then | ||
. /etc/default/netfilter-persistent | ||
fi | ||
|
||
load_rules() | ||
{ | ||
#load IPv4 rules | ||
if [ ! -f /etc/iptables/rules.v4 ]; then | ||
echo "Warning: skipping IPv4 (no rules to load)" | ||
else | ||
iptables-restore < /etc/iptables/rules.v4 | ||
fi | ||
} | ||
|
||
save_rules() | ||
{ | ||
if [ ! "${IPTABLES_SKIP_SAVE}x" = "yesx" ]; then | ||
touch /etc/iptables/rules.v4 | ||
chmod 0640 /etc/iptables/rules.v4 | ||
iptables-save > /etc/iptables/rules.v4 | ||
fi | ||
} | ||
|
||
flush_rules() | ||
{ | ||
TABLES=$(iptables-save | sed -E -n 's/^\*//p') | ||
for table in $TABLES | ||
do | ||
CHAINS=$(iptables-save -t $table | sed -E -n 's/^:([A-Z]+).*/\1/p') | ||
for chain in $CHAINS | ||
do | ||
# policy can't be set on user-defined chains | ||
iptables -t $table -P $chain ACCEPT || true | ||
done | ||
iptables -t $table -F | ||
iptables -t $table -Z | ||
iptables -t $table -X | ||
done | ||
} | ||
|
||
case "$1" in | ||
start|restart|reload|force-reload) | ||
load_rules | ||
;; | ||
save) | ||
save_rules | ||
;; | ||
stop) | ||
# Why? because if stop is used, the firewall gets flushed for a variable | ||
# amount of time during package upgrades, leaving the machine vulnerable | ||
# It's also not always desirable to flush during purge | ||
echo "Automatic flushing disabled, use \"flush\" instead of \"stop\"" | ||
;; | ||
flush) | ||
flush_rules | ||
;; | ||
*) | ||
echo "Usage: $0 {start|restart|reload|force-reload|save|flush}" >&2 | ||
exit 1 | ||
;; | ||
esac |
76 changes: 76 additions & 0 deletions
76
files/ubuntu/iptables-persistent_1.0.14/plugins/25-ip6tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/sh | ||
|
||
# This file is part of netfilter-persistent | ||
# (was iptables-persistent) | ||
# Copyright (C) 2009, Simon Richter <[email protected]> | ||
# Copyright (C) 2010, 2014 Jonathan Wiltshire <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation, either version 3 | ||
# of the License, or (at your option) any later version. | ||
|
||
set -e | ||
|
||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
|
||
# Exit fast if IPv6 is disabled | ||
test -e /proc/sys/net/ipv6 || exit 0 | ||
|
||
load_rules() | ||
{ | ||
#load IPv6 rules | ||
if [ ! -f /etc/iptables/rules.v6 ]; then | ||
echo "Warning: skipping IPv6 (no rules to load)" | ||
else | ||
ip6tables-restore < /etc/iptables/rules.v6 | ||
fi | ||
} | ||
|
||
save_rules() | ||
{ | ||
if [ ! "${IPTABLES_SKIP_SAVE}x" = "yesx" ]; then | ||
touch /etc/iptables/rules.v6 | ||
ip6tables-save > /etc/iptables/rules.v6 | ||
chmod 0640 /etc/iptables/rules.v6 | ||
fi | ||
} | ||
|
||
flush_rules() | ||
{ | ||
TABLES=$(ip6tables-save | sed -E -n 's/^\*//p') | ||
for table in $TABLES | ||
do | ||
CHAINS=$(ip6tables-save -t $table | sed -E -n 's/^:([A-Z]+).*/\1/p') | ||
for chain in $CHAINS | ||
do | ||
# policy can't be set on user-defined chains | ||
ip6tables -t $table -P $chain ACCEPT || true | ||
done | ||
ip6tables -t $table -F | ||
ip6tables -t $table -Z | ||
ip6tables -t $table -X | ||
done | ||
} | ||
|
||
case "$1" in | ||
start|restart|reload|force-reload) | ||
load_rules | ||
;; | ||
save) | ||
save_rules | ||
;; | ||
stop) | ||
# Why? because if stop is used, the firewall gets flushed for a variable | ||
# amount of time during package upgrades, leaving the machine vulnerable | ||
# It's also not always desirable to flush during purge | ||
echo "Automatic flushing disabled, use \"flush\" instead of \"stop\"" | ||
;; | ||
flush) | ||
flush_rules | ||
;; | ||
*) | ||
echo "Usage: $0 {start|restart|reload|force-reload|save|flush}" >&2 | ||
exit 1 | ||
;; | ||
esac |
Oops, something went wrong.