Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
"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
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.
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.
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...
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.
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?
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.