-
Notifications
You must be signed in to change notification settings - Fork 6
/
ipt_survive_reboot
executable file
·49 lines (40 loc) · 1.08 KB
/
ipt_survive_reboot
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
#!/bin/bash
# ipt-kit: ipt_set_tcp
# Copyright (c) 2014, phiLLip maDDux II (foospidy)
# GNU GENERAL PUBLIC LICENSE
# https://github.com/foospidy/ipt-kit/blob/master/LICENSE#
#
# this follows instructions from https://wiki.debian.org/iptables
whoami=`whoami`
if [ 'root' != $whoami ];
then
echo manage_ports must be run as root, run this command again as root, or sudo manage_ports.
exit;
fi
iptables_save=`which iptables-save`
if [ -z $iptables_save ];
then
echo iptables-save not found, install iptables-save and try again.
exit;
fi
echo
echo
if [ "$1" = "-y" ];
then
REPLY='y'
else
echo "This will overwrite /etc/network/if-pre-up.d/iptables."
read -p "Are you sure you wish to continue? " -n 1 -r
echo # (optional) move to a new line
fi
if [[ $REPLY =~ ^[Yy]$ ]];
then
iptables-save > /etc/iptables.up.rules
echo "#!/bin/bash" > /etc/network/if-pre-up.d/iptables
echo "/sbin/iptables-restore < /etc/iptables.up.rules" >> /etc/network/if-pre-up.d/iptables
chmod +x /etc/network/if-pre-up.d/iptables
echo "iptables saved!"
else
echo "No changes made!"
fi
echo