LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   A question about bringing down the network card (https://www.linuxquestions.org/questions/linux-newbie-8/a-question-about-bringing-down-the-network-card-4175733541/)

Jason.nix 02-05-2024 01:16 AM

A question about bringing down the network card
 
Hello,
Why do some services not work when I bring down a NIC and bring it up again and I have to restart the network service?

Thank you.

pan64 02-05-2024 03:18 AM

would be nice to give use more details.

Jason.nix 02-05-2024 08:25 AM

Quote:

Originally Posted by pan64 (Post 6481453)
would be nice to give use more details.

Hello,
Thank you so much for your reply.
I bring down a NIC and bring it up again, but the v2ray service didn't work until I restart the network service.

jayjwa 02-05-2024 10:09 AM

I'm not familiar with v2ray, but likely once it sees there's no network to use it drops off. Restarting the network likely restarts all services that depend on it. This would be up to your init system. Personally, I don't see the reason to stop the network itself unless it's shutdown time for the machine.

Jason.nix 02-05-2024 10:52 AM

Quote:

Originally Posted by jayjwa (Post 6481545)
I'm not familiar with v2ray, but likely once it sees there's no network to use it drops off. Restarting the network likely restarts all services that depend on it. This would be up to your init system. Personally, I don't see the reason to stop the network itself unless it's shutdown time for the machine.

Hello,
Thank you so much for your reply.
Do you think the same might happen to other services like Apache?

chrism01 02-06-2024 08:56 PM

I'm with jayjwa...

Basically, restarting the Network svc is usually a last resort (unless you're shutting down / rebooting the box).

Attempt to fix whatever svc is having an issue, inc restarting the svc if needed.

Ofc any svc that is network dependent is going to fail if you yank the network out from under it.. unless it's a very quick restart, in which case it might(!) be able to recover.
However, that's a case-by-case thing.

computersavvy 02-06-2024 10:32 PM

Another thing to consider, especially if using dhcp

There are times when taking a network interface down and back up may give it a new IP.

Any service that has an active connection at the time the card is taken down will have that connection broken by taking the interface down.
Bringing it back up does not restore those connections The service is left with a connection that was interrupted and is waiting for the other end to reply or respond but there is no longer a complete connection so it hangs.

This is just the way services that use tcp work -- an active connection that is broken remains broken -- so if you have need to disable the network you should first stop all services that use the network.

Jason.nix 02-07-2024 05:18 AM

Quote:

Originally Posted by computersavvy (Post 6481928)
Another thing to consider, especially if using dhcp

There are times when taking a network interface down and back up may give it a new IP.

Any service that has an active connection at the time the card is taken down will have that connection broken by taking the interface down.
Bringing it back up does not restore those connections The service is left with a connection that was interrupted and is waiting for the other end to reply or respond but there is no longer a complete connection so it hangs.

This is just the way services that use tcp work -- an active connection that is broken remains broken -- so if you have need to disable the network you should first stop all services that use the network.

Hello,
Thank you so much for your reply.
So if we stop the Apache service and run it again, then people have to refresh the website!
How about the UDP protocol?

computersavvy 02-07-2024 08:24 AM

Quote:

Originally Posted by Jason.nix (Post 6481985)
Hello,
Thank you so much for your reply.
So if we stop the Apache service and run it again, then people have to refresh the website!
How about the UDP protocol?

If you bring down the network interface they have to reconnect.
If you stop apache and restart it they have to reconnect.
Both those are from the client end.

From the server end:
If apache has an active connection it may stall when the interface is removed but does not stall when it is stopped and restarted.
Rebooting a system brings services down in an orderly manner and restarts them the same way.
Downing a network interface while the service is running is a sudden disorderly disconnect and can have unanticipated results.


All times are GMT -5. The time now is 01:48 PM.