Link to home
Start Free TrialLog in
Avatar of kdavidm
kdavidm

asked on

SSH connection and network restart

I'm currently running FC4 and I ssh'd into the machine then performed a service network restart so I believe I should no longer be connected because it's shutting down the interfaces though I'm still connected when the interfaces are brought back up, so I'm curious as to how that is possible.
Avatar of Arty K
Arty K
Flag of Kazakhstan image

It's quiet interesting.

I can only suppose that when you will do '/etc/init.d/network stop' you will have all existing connections alive also. Try this (with care, having local access to that machine).

If so, than I can tell you what happens. When you call 'network restart' it's the same as 'network stop' then 'network start'
Network stop will execute '/etc/sysconfig/network-scripts/ifdown' for each interface.

'ifdown' script tries to shutdown interface: ip link set dev ${DEVICE} down
but does wait only for 5 seconds (it doesn't matter if device is really down or not)

waited=0
while ! check_device_down ${DEVICE} && [ "$waited" -lt 50 ] ; do
    usleep 10000
    waited=$(($waited+1))
done

Now even if device is still UP script continues.
Why device may be UP? Here is a weak point, I don't know exactly. But probably because there are applications that use that device and it is busy. Link marked as down, so only existing connections are working. That's why 'network stop' executes after all scripts on shutdown (when every networked application is closed).

How to force to shutdown interface? I guess forced 'rmmod' will help.



Network scripts are trying to bring down interfaces for 5 secondns
it looked connected, or it allowed you to type and answered after the network restart?

What I can see is ifconfig ethX down didn't worked well. If this is the only problem it gives, it's okay, but I would check to see if there are other problems also
SOLUTION
Avatar of alextoft
alextoft
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Best way to view this is the network is coming back up in the same configuration as when it went down. Due to the way the various network layers work, the connection is capable of continuing as before after the restart.

In order to forceably disconnect, you need to kill the shells associated with the ssh connections.

Also ssh is designed to be resilient.. (Many other applications will 'disconnect' you.)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bstrauss3
bstrauss3

RedHat and similar distributions are level based - the dependencies are coded by the K/S #s in /etc/init.d/rc?.d ...

So if you restart via init 3 (even if you are already at level 3), it will issue all the Ks and then the Ss - and so it will restart sshd.

Other distros, e.g. Gentoo actually encode dependencies directly in the startup scripts and so restarting net will automatically restart sshd.


Whether the restart is a good thing depends on the network change you've made.  If it changes the network configuration, such as DHCP assigining a new IP address, then you can have a broken sshd.  But if it's not that kind of change, leaving the connection up is a good thing if you break something doing remote administration...

-----Burton