fix: set iptables rules after reboot

This commit is contained in:
Peter Galonza 2025-03-29 22:59:12 +03:00
parent 2a6e6a1e24
commit 92296188af
No known key found for this signature in database
GPG key ID: C85D94460DBECFA2
2 changed files with 49 additions and 2 deletions

View file

@ -7,3 +7,40 @@ if ! sudo docker network ls | grep -q amnezia-dns-net; then sudo docker network
--opt com.docker.network.bridge.name=amn0 \
amnezia-dns-net;\
fi
if ! grep -q "#!/bin/bash" /opt/amnezia/setup_host_firewall.sh; then
sudo sed -i '1i\#!/bin/bash\n' /opt/amnezia/setup_host_firewall.sh
fi
if lsmod | grep -qw nf_tables; then
sudo update-alternatives --set iptables /usr/sbin/iptables-nft
sudo cat > /etc/systemd/system/setup-host-firewall.service << EOF
[Unit]
Description=Run setup_host_firewall.sh
PartOf=nftables.service
After=nftables.service
[Service]
Type=oneshot
ExecStart=/opt/amnezia/setup_host_firewall.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOF
else
sudo cat > /etc/systemd/system/setup-host-firewall.service << EOF
[Unit]
Description=Run setup_host_firewall.sh
[Service]
Type=oneshot
ExecStart=/opt/amnezia/setup_host_firewall.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOF
fi
sudo systemctl enable setup-host-firewall.service