1

Using a lot of CentOS 7 hosts on a very small subnet. I use only a small portion of the hosts at each time. The other portion of the hosts are powered off. However, occasionally the powered off hosts are booted accidentally and cause a duplicate IP situation.

Considering that I can't change the working procedure, I want to disable the networking completely on the powered off hosts if they are accidentally booted. I can change the /etc/sysconfig/network-scripts for each interface, but the names of interfaces vary between hosts and the number of interfaces is ~6 for each host.

So, how do I disable all networking?

1 Answer 1

2

I tried following on few VM's. It's probably overkill but you might try it.

for i in network.target network-online.target NetworkManager.service  NetworkManager-wait-online.service network.service; do 
systemctl disable $i
systemctl mask $i
done

After it VM's started without networking. Some notes:

  • Masked units must be unmasked before used.
  • I tried this only on CentOS 7 vms (libvirt && virtualbox vagrant images).
  • In the old days you could just set runlevel to multi-user (2, one without networking :)), but systemd (according to my knowledge) don't have a similar target (runlevel).

Edit:

As mentioned @GAD3R - NetworkManager-wait-online.service now is included

1
  • 1
    Fixed. I don't know If I could mention your profile in answer the @ in comments works, but not for answers :(. Jan 19, 2021 at 12:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .