@@ -1,54 +1,49 | |||
|
1 | 1 | #!/bin/bash |
|
2 | 2 | # |
|
3 | 3 | # Setup Firewall |
|
4 | 4 | # |
|
5 | 5 | |
|
6 | 6 | # Load utility functions |
|
7 | 7 | . ./functions.sh |
|
8 | 8 | |
|
9 | 9 | if [ "$ENABLE_IPTABLES" = true ] ; then |
|
10 | 10 | # Create iptables configuration directory |
|
11 | 11 | mkdir -p "${ETC_DIR}/iptables" |
|
12 | 12 | |
|
13 | 13 | if ! [ "$RELEASE" = jessie ] ; then |
|
14 | #setting slaves | |
|
15 | #chroot_exec update-alternatives --verbose --install /usr/sbin/iptables iptables /usr/sbin/iptables-legacy 1 \ | |
|
16 | --slave /usr/sbin/iptables-save iptables-save /usr/sbin/iptables-legacy-save \ | |
|
17 | --slave /usr/sbin/iptables-restore iptables-restore /usr/sbin/iptables-legacy-restore | |
|
18 | # make sure iptables-legacy,iptables-legacy-restore and iptables-legacy-save are the used alternatives | |
|
19 | 14 |
|
|
20 | 15 | fi |
|
21 | 16 | |
|
22 | 17 | # Install iptables systemd service |
|
23 | 18 | install_readonly files/iptables/iptables.service "${ETC_DIR}/systemd/system/iptables.service" |
|
24 | 19 | |
|
25 | 20 | # Install flush-table script called by iptables service |
|
26 | 21 | install_exec files/iptables/flush-iptables.sh "${ETC_DIR}/iptables/flush-iptables.sh" |
|
27 | 22 | |
|
28 | 23 | # Install iptables rule file |
|
29 | 24 | install_readonly files/iptables/iptables.rules "${ETC_DIR}/iptables/iptables.rules" |
|
30 | 25 | |
|
31 | 26 | # Reload systemd configuration and enable iptables service |
|
32 | 27 | chroot_exec systemctl daemon-reload |
|
33 | 28 | chroot_exec systemctl enable iptables.service |
|
34 | 29 | |
|
35 | 30 | if [ "$ENABLE_IPV6" = true ] ; then |
|
36 | 31 | # Install ip6tables systemd service |
|
37 | 32 | install_readonly files/iptables/ip6tables.service "${ETC_DIR}/systemd/system/ip6tables.service" |
|
38 | 33 | |
|
39 | 34 | # Install ip6tables file |
|
40 | 35 | install_exec files/iptables/flush-ip6tables.sh "${ETC_DIR}/iptables/flush-ip6tables.sh" |
|
41 | 36 | |
|
42 | 37 | install_readonly files/iptables/ip6tables.rules "${ETC_DIR}/iptables/ip6tables.rules" |
|
43 | 38 | |
|
44 | 39 | # Reload systemd configuration and enable iptables service |
|
45 | 40 | chroot_exec systemctl daemon-reload |
|
46 | 41 | chroot_exec systemctl enable ip6tables.service |
|
47 | 42 | fi |
|
48 | 43 | |
|
49 | 44 | if [ "$ENABLE_SSHD" = false ] ; then |
|
50 | 45 | # Remove SSHD related iptables rules |
|
51 | 46 | sed -i "/^#/! {/SSH/ s/^/# /}" "${ETC_DIR}/iptables/iptables.rules" 2> /dev/null |
|
52 | 47 | sed -i "/^#/! {/SSH/ s/^/# /}" "${ETC_DIR}/iptables/ip6tables.rules" 2> /dev/null |
|
53 | 48 | fi |
|
54 | 49 | fi |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant