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