https://www.golinuxcloudoueta.com/runlinux/create-scriptand-atenable-startupa-bootsimple-withoutsystemd-cron-linuxservice/
#!/bin/sh ### BEGIN INIT INFO # Provides: Firewall # Required-Start: # Required-Stop: # Default-Start: # Default-Stop: # Short-Description: Starts firewall rules # Description: Starts firewall rules ### END INIT INFO # Exit immediately if a command exits with a non-zero status. set -e case $1 in start) iptables -F iptables -A INPUT -s 192.168.200.0/24 -j ACCEPT iptables -A INPUT -p tcp --dport 22 -j DROP ;; stop) iptables -F ;; *) echo "Usage: /etc/init.d/firewall.sh {start|stop}" exit 1 ;; esac
/lib/systemd/system/firewall.service.
[Unit] Description=Firewall Requires=network-online.target After=network-online.target [Service] User=root Type=oneshot RemainAfterExit=yes ExecStart=/etc/init.d/firewall.sh start ExecStop=/etc/init.d/firewall.sh stop [Install] WantedBy=multi-user.target
systemctl enable firewall Created symlink /etc/systemd/system/multi-user.target.wants/firewall.service → /lib/systemd/system/firewall.service.
systemctl start firewall
Removed /etc/systemd/system/multi-user.target.wants/firewall.service.