Hey Oz.
This may look complicated, but I made it as simple as I could. I wrote two systemd service files for you.
This suspend unit file stops the network components prior to suspending.
Create Systemd Suspend Unit File:
In a terminal type the following:
sudo nano /etc/systemd/system/network-suspend.service
Paste the script contents below with a right click. Exit with CTRL + X and press Y to save.
Systemd suspend unit service file contents:
#/etc/systemd/system/network-suspend.service
#sudo systemctl enable network-suspend.service
[Unit]
Description=Stop network components prior to suspending
Before=sleep.target
[Service]
Type=oneshot
ExecStart=/bin/systemctl stop NetworkManager.service; ip link set enp2s0 down; modprobe -r r8169
[Install]
WantedBy=sleep.target
Next, make the service file executable and owned by root.
sudo chown root:root /etc/systemd/system/network-suspend.service
sudo chmod +x /etc/systemd/system/network-suspend.service
Then, enable the service:
sudo systemctl enable network-suspend.service
This resume unit file restarts the network components after resuming from suspend.
Create Systemd Resume Unit File:
In a terminal type the following:
sudo nano /etc/systemd/system/network-resume.service
Paste the script contents below with a right click. Exit with CTRL + X and press Y to save.
Systemd resume unit service file contents:
#/etc/systemd/system/network-resume.service
#sudo systemctl enable network-resume.service
[[Unit]
Description=Start network components after resuming
After=suspend.target
[Service]
Type=oneshot
ExecStartPre=/bin/sleep 15s
ExecStart=/bin/modprobe r8169; ip link set enp2s0 up; systemctl start NetworkManager.service
[Install]
WantedBy=suspend.target
Next, make the service file executable and owned by root.
sudo chown root:root /etc/systemd/system/network-resume.service
sudo chmod +x /etc/systemd/system/network-resume.service
Then, enable the service:
sudo systemctl enable network-resume.service
Then reboot.
(edit)
Recently people have reported these services as not working correctly. Upon investigation it became apparent the reason why was because they had missed the blacklisting step earlier in the thread. This is a very long thread, but you must apply all the important steps for it to be successful.
These services were written for the r18169 driver. If you are using the r8168 driver you must either switch to the 8169 driver, or alter the service units to load/unload the r8168 module instead.