##// END OF EJS Templates
Merge remote-tracking branch 'origin/ref+fix' into ref+fix
Merge remote-tracking branch 'origin/ref+fix' into ref+fix

Fichier de la dernière révision:

r310:b38cfe8b34fd
r311:34ec6150691e Fusion
Show More
21-firewall.sh
52 lines | 2.0 KiB | application/x-sh | BashLexer
#
# Setup Firewall
#
# Load utility functions
. ./functions.sh
if [ "$ENABLE_IPTABLES" = true ] ; then
# Create iptables configuration directory
mkdir -p "${ETC_DIR}/iptables"
#In Jessie iptables is old enough
if ! [ "$RELEASE" = jessie ] ; then
# make sure iptables-legacy,iptables-legacy-restore and iptables-legacy-save are the used alternatives
chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy
#chroot_exec update-alternatives --verbose --set iptables-save /usr/sbin/iptables-legacy-save
#chroot_exec update-alternatives --verbose --set iptables-restore /usr/sbin/iptables-legacy-restore
fi
# Install iptables systemd service
install_readonly files/iptables/iptables.service "${ETC_DIR}/systemd/system/iptables.service"
# Install flush-table script called by iptables service
install_exec files/iptables/flush-iptables.sh "${ETC_DIR}/iptables/flush-iptables.sh"
# Install iptables rule file
install_readonly files/iptables/iptables.rules "${ETC_DIR}/iptables/iptables.rules"
# Reload systemd configuration and enable iptables service
chroot_exec systemctl daemon-reload
chroot_exec systemctl enable iptables.service
if [ "$ENABLE_IPV6" = true ] ; then
# Install ip6tables systemd service
install_readonly files/iptables/ip6tables.service "${ETC_DIR}/systemd/system/ip6tables.service"
# Install ip6tables file
install_exec files/iptables/flush-ip6tables.sh "${ETC_DIR}/iptables/flush-ip6tables.sh"
install_readonly files/iptables/ip6tables.rules "${ETC_DIR}/iptables/ip6tables.rules"
# Reload systemd configuration and enable iptables service
chroot_exec systemctl daemon-reload
chroot_exec systemctl enable ip6tables.service
fi
if [ "$ENABLE_SSHD" = false ] ; then
# Remove SSHD related iptables rules
sed -i "/^#/! {/SSH/ s/^/# /}" "${ETC_DIR}/iptables/iptables.rules" 2> /dev/null
sed -i "/^#/! {/SSH/ s/^/# /}" "${ETC_DIR}/iptables/ip6tables.rules" 2> /dev/null
fi
fi