[Unit] Description=Iptables Helper After=network.target [Service] Environment="HOME=/root" WorkingDirectory=/opt/iptables-helper ExecStartPre=/bin/bash -c "[ -f /etc/iptables.rule ] && iptables-restore /etc/iptables.rule || exit 0;" ExecStart=/opt/iptables-helper/iptables-helper ExecStartPost=/bin/bash -c "iptables-save | tee /etc/iptables.rule > /dev/null" Restart=on-failure KillMode=process RestartSec=5s [Install] WantedBy=multi-user.target