openec2 Article Description
Run a Script at Start Up – or reboot
Check rc.local capability is running:
systemctl status rc-local ● rc-local.service - /etc/rc.local Compatibility Loaded: loaded (/lib/systemd/system/rc-local.service; enabled-runtime; preset: enabled)
Add your script. e.g. ports.sh where you have a script that uses iptables/ipset to block port attacks of some sort:
vi /etc/rc.local #!/bin/sh -e sh /home/admin/ports.sh >/dev/null 2>&1 exit 0 [save and exit] chmod +x /etc/rc.local sync sync reboot
After reboot, in this case, run iptable -L -vn and you should see the output worked.