You are not logged in.

#1 2012-05-11 20:43:01

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,616
Website

systemd close network connections on reboot/poweroff [solved]

What is the equivalent of:

NETWORK_PERSIST="yes"

for systemd? 

For example, I am connecting from my laptop to my server via ssh.  I want to restart the server from the ssh connection I just started.  After I issue the `systemctl reboot` command, the shell I used to connect to the server hangs.  I'd like it systemd to log me out gracefully.

# systemctl reboot

Broadcast message from facade@mars on pts/0 (Thu, 10 May 2012 11:59:24 -0400):

The system is going down for reboot NOW!

# Write failed: Broken pipe

Last edited by graysky (2012-05-12 13:34:53)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2012-05-12 11:22:36

maggie
Member
Registered: 2011-02-12
Posts: 255

Re: systemd close network connections on reboot/poweroff [solved]

Maybe something is not right in your network's service?

Offline

#3 2012-05-12 11:28:23

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,616
Website

Re: systemd close network connections on reboot/poweroff [solved]

Using static networking; template on wiki:

[Unit]
Description=Network Connectivity
Wants=network.target
Before=network.target
 
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network
ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway}
ExecStop=/sbin/ip addr flush dev ${interface}
ExecStop=/sbin/ip link set dev ${interface} down

[Install]
WantedBy=multi-user.target

CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#4 2012-05-12 11:55:18

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: systemd close network connections on reboot/poweroff [solved]

Are you using sshd.service? I'm using sshd.socket/sshd@.service and it logs me out fine when I reboot.
also see the comment in the sshd.service file : https://github.com/falconindy/systemd-a … hd.service

Offline

#5 2012-05-12 13:25:26

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: systemd close network connections on reboot/poweroff [solved]

You could try disabling systemd stopping this unit with DefaultDependencies=false. That way it won't conflict with shutdown.target, which is why the network is stopped as things stand now. You'll also want to make sure to cover the other half of what DefaultDependencies does for you now (making sure it doesn't try to start too early) by adding "Requires=systemd-journald.socket basic.target" and "After=systemd-journald.socket basic.target". (I did systemctl show network.service to see what these implicit dependencies actually were. You will also see the "Conflicts=shutdown.target" you want to disable in there.)

Another way would be to just remove the ExecStop lines, so that systemd wouldn't even know how to kill the network. But then, that would also prevent you from doing so manually, so this probably isn't that useful.

Offline

#6 2012-05-12 13:34:40

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,616
Website

Re: systemd close network connections on reboot/poweroff [solved]

65kid wrote:

Are you using sshd.service? I'm using sshd.socket/sshd@.service and it logs me out fine when I reboot.
also see the comment in the sshd.service file : https://github.com/falconindy/systemd-a … hd.service

Yeah, I was using sshd.service and your suggestion to use sshd.socket seems to have solved the problem.

$ sudo systemctl reboot
Connection to mars closed by remote host.
Connection to mars closed.

Thanks again 65kid.

Last edited by graysky (2012-05-12 13:35:09)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

Board footer

Powered by FluxBB