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.
kdavidmAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NopiusCommented:
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
0
Gabriel OrozcoSolution ArchitectCommented:
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
0
alextoftCommented:
It's pretty logical really; all the output text from the init script just gets buffered until the interface comes back up. You're still authenticated, and the sshd doesn't have the faintest idea you just restarted the networking. Same as if you're happily talking away using something like xchat and you restart the networking, you don't suddenly get booted off irc.

Let's face it, it would be pretty annoying if you didn't have that facility if your company had a number of linux servers in different locations, or at a colo facility. Try that on windows through a terminal session, or vnc or whatever and it'll kick you off every time.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

guruyayaCommented:
Well, it`s fairly simple actually. As you might know the tcp/ip module is made of 4 layers. The link at the end of the page, is a bit more deep, yet the main thing we need to say about that, is that the part that makes sure that connection is stable, is not your network card, but a part of the kernel, that takes care of tcp connectivity.   when you restart netwoking, you restart the IP module, that has no issue dealing with the presistence of the connection.
For the example sake , let`s say that your connection is a mail office, and all you send is registered mail. You have sent some mail to a far away building, and got informed when they got the letter. Now lets say that we had a great fire in the post office at the building. You don`t get informed about that they got the mail, so you resend it. Now they`ve builet a new post office for the building, and the mail just go where it should. You can hardly tell it happent! That`s just how the networking goes: if you are not informed that the other side of the connection got your SSH packet, you automaticly resend it. That`s all!  

If it intrests you, this file ha good networking overview:
http://tldp.org/HOWTO/Networking-Overview-HOWTO.html
0
pjedmondCommented:
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.)
0
Gabriel OrozcoSolution ArchitectCommented:
good explanation from everyone

I did the test and found that in Redhat-like, (where the "service" command exists) this happends

In slackware it would not happend. if you want to restart your network, it will be disabled (FULLY) and then reenabled again, effectively disconnecting your session.

so, it depends on the distribution. If you see in the network restart script, you will notice there is provision for maintain existing connections.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bstrauss3Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.