On one machine, I've prepared a
firewall.service systemd service that works fine on that machine running Debian 9.5.
Now I'm setting up another machine, also running Debian 9.5, using the exact same script, but refuses to run at startup and I can't seem to find any indication as to why.
Immediately following startup, here is some output, indicating to me only that systemd never tried starting the service in the first place:
[root@bigbrother ~]# journalctl -u firewall -- No entries -- [root@bigbrother ~]# systemctl status firewall ● firewall.service - Firewall setup via /etc/iptables.rules Loaded: loaded (/etc/systemd/system/firewall.service; enabled; vendor preset: enabled) Active: inactive (dead)
The firewall service is in
/etc/systemd/system/firewall.service on both machines and looks like this:
[Unit] Description=Firewall setup via /etc/iptables.rules After=network.target [Service] Type=oneshot ExecStart=/sbin/iptables-restore /etc/iptables.rules [Install] WantedBy=network-online.target
As you can see, it just runs an
iptables-restore command, and that's it. I used to run this with
/etc/rc.local earlier, but I guess one must keep up with fashion and use
systemd for such things (which is fine, when it works).
The service is indeed enabled:
[root@bigbrother ~]# systemctl disable firewall Removed /etc/systemd/system/network-online.target.wants/firewall.service. [root@bigbrother ~]# systemctl enable firewall Created symlink /etc/systemd/system/network-online.target.wants/firewall.service → /etc/systemd/system/firewall.service.
And it works fine when run manually:
[root@bigbrother ~]# systemctl start firewall [root@bigbrother ~]# systemctl status firewall ● firewall.service - Firewall setup via /etc/iptables.rules Loaded: loaded (/etc/systemd/system/firewall.service; disabled; vendor preset: enabled) Active: inactive (dead) Sep 09 17:10:52 bigbrother systemd: Starting Firewall setup via /etc/iptables.rules... Sep 09 17:10:53 bigbrother systemd: Started Firewall setup via /etc/iptables.rules.
What am I missing?
I've looked around at some similar questions here, but the one that gave me the most promise was actually a typo, so I'm totally lost at the moment. It's the same version of Debian that I'm running on a different server, so I find it hard to believe that this has something to do with the order of the services. Even so, I'll gladly take suggestions on that.