Enabling rc.local shell script on systemd by booting Debian system to load firewall rules
Create or edit the file /etc/rc.local
$ pico /etc/rc.local
Then add this to file
#!/bin/sh
#
# rc.local
#
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# add your commands # load firewall rules at boot
iptables-restore < /etc/iptables/iptables
# last line must be exit 0
exit 0
Save and close the file
Then make the file executable with the chmod command:
$ chmod +x /etc/rc.local
Reload the systemd manager configuration
$ systemctl daemon-reload
Start the rc-local daemon
$ systemctl start rc-local
Check the status of rc-local to confirm everything is OK
$ systemctl status rc-local
You should then get output like below stating the it is active and exited normal:
root@n1:~# systemctl status rc-local
● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/lib/systemd/system/rc-local.service; enabled-runtime; preset: enabled)
Drop-In: /usr/lib/systemd/system/rc-local.service.d
└─debian.conf
Active: active (exited) since Mon xxxx-xx-xx 05:43:47 CEST; 9s ago
Docs: man:systemd-rc-local-generator(8)
Process: 17656 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
CPU: 3ms
xxx xx 05:43:47 ns1 systemd[1]: Starting rc-local.service - /etc/rc.local Compatibility...
xxx xx 05:43:47 ns1 systemd[1]: Started rc-local.service - /etc/rc.local Compatibility.
Previous page: Change the SSH port
Next page: Apache 2.4 Enable mod_deflate on Debian 10