How to access network in the service file while system is shutdown or reboot?

I have a script which wanted to access network while system is shutdown or reboot.
Though the systemd service file Required network-online.target, but the script always failed to access the network.

Here is the service file:

[Unit]
Description=LSB: Some description
Requires=network-online.target network.service
After=network-online.target network.service

[Service]
Type=forking
ExecStart=/etc/init.d/my-monitor start
ExecStop=/etc/init.d/my-monitor stop
RemainAfterExit=yes
TimeoutSec=0

[Install]
WantedBy=default.target

And also I notice there is a service called network@ens.target and if I put it as a requirement.
The network access is OK.

So how could I access the network when system shutdown or reboot?

You should use Wants, not Requires here. Requires is too strong. Although end result is the same.

And also I notice there is a service called network@ens.target

service, not target

and if I put it as a requirement.
The network access is OK.

So how could I access the network when system shutdown or reboot?

That’s another reincarnation of bug https://bugzilla.novell.com/show_bug.cgi?id=857031
Network interfaces are configured by network@if.service, but those services themselves do not have any dependency on network-online.target so they are stopped early during shutdown. See https://forums.opensuse.org/english/get-technical-help-here/network-internet/493946-arrrgh-systemd-4.html#post2612702 for a workaround. If it works for you, please add comment to above mentioned bug.

Thanks.
It works.