ip-tools vs old ifconfig
Preamble: ip
and ifconfig
are utilities for controlling and monitoring networking. They are not typically used for reading/writing persistent configuration files - and this is why ip link
did not work. Persistent configuration management has to be accomplished by other means, such as NetworkManager
.
(It's likely needless to say, but, as a side note, iproute2
, which provides ip
, has been/is being adopted by many distributions as a replacement for net-tools
, which provides ifconfig
. They are often both shipped as default packages in distributions for compatibility reasons).
Why ifup
worked and systemctl restart NetworkManager
did not:
On CentOS (I have checked for CentOS 7), ifup
and ifdown
are provided by initscripts
; they operate on the scripts in /etc/sysconfig/network-scripts/
, provided by the same package. Thus, no surprise in ifup
being able to apply the changes you made there.
NetworkManager - the default networking service provider that CentOS inherited from upstream - on Red Hat and Fedora is configured to use the ifcfg-rh
plugin to read/write network configuration from /etc/sysconfig/network-scripts/ifcfg-*
. But it does not monitor those files.
man nm-settings-ifcfg-rh
warns that
Users can create or modify the ifcfg-rh connection files manually, even if that is not the recommended way of managing the profiles. However, if they choose to do that, they must inform NetworkManager about their changes (see monitor-connection-file in nm-settings(5), and nmcli con (re)load).
Thus, systemctl reload NetworkManager
is not supposed to reload the configuration of a network connection from file on CentOS. To do that you can invoke nmcli connection reload
or change NetworkManager
configuration as stated in man NetworkManager.conf
:
monitor-connection-files
Whether the configured settings plugin(s) should set up file monitors and immediately pick up changes made to connection files while NetworkManager is running. This is disabled by default; NetworkManager will only read the connection files at startup, and when explicitly requested via the ReloadConnections D-Bus call. [...]
ip
directly changes the state of the hardware, just like ifconfig
. The only difference between ifconfig
and ip
is that ip
has a different syntax, and supports some features ifconfig
doesn't.
ifup
and ifdown
, on the other hand, run a lot of scripts, read your /etc/network/interfaces
file and other configuration files, and act on that. That includes adding the static IP settings which you probably put into /etc/network/interfaces
.
In principle, Network Manager should pick up those, too, but I don't run Network Manager (most of the time it gets in my way), so I can't tell you why it didn't work.
So: if you want your network configuration files to be taken into consideration, use ifup
/ifdown
and Network Manager. If you want to directly change the interface settings, use ip
and ifconfig
.