LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-17-2012, 07:48 AM   #1
Brandon9000
Member
 
Registered: Apr 2012
Location: Florida
Distribution: Many
Posts: 111

Rep: Reputation: Disabled
Restarting a Network in Systemd


In distributions which use initd, I have learned to restart my network by entering:

service network restart

or

service networking restart.

In systemd systems, what would be the equivalents? Quickly glancing at a Fedora17 virtual I have on hand which uses systemd, I see no .service file named network. When I enter:

systemctl status network

it says that it's dead based on inspecting /etc/init.d/network, but since the network is clearly up, that is probably no longer the measure. How do I restart a network with a systemctl command which is valid for most systems?
 
Old 10-17-2012, 09:31 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Isn't it 'systemctl restart network.service' or 'systemctl restart NetManager.service'?
 
Old 10-17-2012, 09:35 AM   #3
Brandon9000
Member
 
Registered: Apr 2012
Location: Florida
Distribution: Many
Posts: 111

Original Poster
Rep: Reputation: Disabled
Hi.

When I do systemctl status network.service, it tells me that it's dead, even though the network is absolutely working, and makes it pretty clear that it's only checking the network script in /etc/init.d, which is probably not in use on a systemd system. "Systemctl status NetworkManager.service" shows it up and running, but I do not know if it is the ubiquitous implementation of the network in systemd systems. I am writing some code to be used in a wide variety of systems using systemd, and I need to know that what I do will work most places.
 
Old 10-17-2012, 10:49 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Brandon9000 View Post
"Systemctl status NetworkManager.service" shows it up and running, but I do not know if it is the ubiquitous implementation of the network in systemd systems.
NM precedes Systemd by a couple of releases. It AFAIK is installed and activated by default. If users elect not to use it that should be seen as an explicit local customization and therefore deviation from the standard IMO. Somewhere in /etc/sysconfig/ configuration files should show use as in "NM=no" or "NetManager=yes".


Quote:
Originally Posted by Brandon9000 View Post
I am writing some code to be used in a wide variety of systems using systemd, and I need to know that what I do will work most places.
Yes, I saw your other thread.
 
Old 10-17-2012, 11:58 AM   #5
Brandon9000
Member
 
Registered: Apr 2012
Location: Florida
Distribution: Many
Posts: 111

Original Poster
Rep: Reputation: Disabled
If it's the default, then I can probably use for situations where I have to re-start the network when systemd is in use. Thanks!
 
Old 10-17-2012, 12:32 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
NP, please mark this thread "solved", TIA.
 
Old 10-17-2012, 12:33 PM   #7
Brandon9000
Member
 
Registered: Apr 2012
Location: Florida
Distribution: Many
Posts: 111

Original Poster
Rep: Reputation: Disabled
How do I do that?
 
Old 10-17-2012, 12:41 PM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Should be an option right above this threads first post under the "Thread Tools" header?
 
Old 10-17-2012, 02:02 PM   #9
Brandon9000
Member
 
Registered: Apr 2012
Location: Florida
Distribution: Many
Posts: 111

Original Poster
Rep: Reputation: Disabled
There might be a problem. I checked an openSUSE 12.1 systemd virtual I have. The network was working and it was using /etc/init.d for the network. When I entered

systemctl status Network.Manager.service

it showed:

NetworkManager.service - Network Manager
Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled)
Active: failed since Wed, 17 Oct 2012 10:47:46 -0400; 4h 11min ago

but

systemctl status network.service

showed:

network.service - LSB: Configure the localfs depending network interfaces
Loaded: loaded (/etc/init.d/network)
Active: active (running) since Wed, 17 Oct 2012 14:48:03 -0400; 5min ago
Process: 623 ExecStart=/etc/init.d/network start (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/network.service
└ 2295 /sbin/dhcpcd --netconfig -L -E -HHH -c /etc/sysconfig/network/scripts/dh

This leads me to believe that NetworkManager may not be the universal default network for systemd systems.
 
Old 10-19-2012, 12:28 PM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Saying "there might be a problem" appears to be an understatement:
- Mageia Release 2 responded to 'systemctl status network.service'. It didn't have NetworkManager installed but I'm not sure if that was the default or that the upgrade from Mandriva caused it. It didn't show any "NETWORKMANAGER=" variables in /etc to grep for.
- OpenSUSE=12.1 like you said responded to 'systemctl status network.service'. It didn't have NetworkManager installed (defaults to NetConfig / ifup apparently) but /etc/sysconfig/network/config has a "NETWORKMANAGER=no" variable you can grep for.
- As expected Fedora 18 didn't respond to 'systemctl status network.service' but to 'systemctl status NetworkManager.service'. And nothing in /etc showed any NETWORKMANAGER= variables to grep for...
 
Old 10-19-2012, 12:33 PM   #11
Brandon9000
Member
 
Registered: Apr 2012
Location: Florida
Distribution: Many
Posts: 111

Original Poster
Rep: Reputation: Disabled
Thanks for your help with this. As of this moment, I am actively trying to figure out an algorithm whereby a program can restart a network once it establishes that services are being controlled by systemd. I would just go ahead and restart the network with both methods consecutively but for the fear that both types of network manager would come up and fight with each other.
 
Old 10-19-2012, 08:28 PM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Since all those systems use D-Bus how about a call to org.freedesktop.networkManager to see if it's enabled?
Or else check if 'nmcli' is installed. If it's not you have your answer, else have it display service status?
 
Old 10-23-2012, 03:58 PM   #13
Brandon9000
Member
 
Registered: Apr 2012
Location: Florida
Distribution: Many
Posts: 111

Original Poster
Rep: Reputation: Disabled
Good ideas. How might I make a call to NetworkManager? I am not very familiar with it.

Oh, wait. That won't work. If I query it and it doesn't respond, it may just mean that it is accidentally down, not that it isn't supposed to be up.

Last edited by Brandon9000; 10-23-2012 at 04:13 PM.
 
Old 10-24-2012, 09:43 AM   #14
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Brandon9000 View Post
Oh, wait. That won't work. If I query it and it doesn't respond, it may just mean that it is accidentally down, not that it isn't supposed to be up.
Since there's no equivalent that concludes my help on the matter. I do think you've got enough options now for your your decision tree wrt the feature checking and error handling branches, right?
 
Old 10-24-2012, 01:04 PM   #15
Brandon9000
Member
 
Registered: Apr 2012
Location: Florida
Distribution: Many
Posts: 111

Original Poster
Rep: Reputation: Disabled
Thanks for your help.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Restarting Network Service carlosinfl Debian 8 08-05-2012 09:37 AM
Boot Delay 30min: systemd-analyze blame systemd-tmpfiles-setup.service BGHolmes Fedora 0 07-27-2011 09:02 AM
Problem in network in CentOS after restarting network sidkapoor2000 Linux - Networking 3 07-01-2009 12:27 AM
Restarting network vitalstrike82 Slackware 4 11-07-2008 10:29 AM
restarting my network linuxboy_inside Linux - Networking 3 01-06-2004 05:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration