CentOS: How is it possible to reset all your network configuration?
VirtualBox supports 2 methods of returning a VM to a known-good configuration which would be handy for experimentations like the one described in the question:
- snapshots
- cloning
This SO Q&A explains the difference between them: https://stackoverflow.com/questions/23813688/virtualbox-clone-vs-snapshot-vs-backup
The exact methods of using them may differ depending on host/guest OS and version, related searches should be used to locate the appropriate details.
For example here's a pretty good article on using snapshots with a windows7 guest: http://www.howtogeek.com/150258/how-to-save-time-by-using-snapshots-in-virtualbox/
Related videos on Youtube
Eric Shields
Updated on September 18, 2022Comments
-
Eric Shields almost 2 years
I'm not really sure the best question to ask in my situation, so let's go with "How is it possible to delete all your network commands?". Here's the situation:
I have a CentOS 7 minimalist CLI webserver running out of a VirtualBox VM. I was attempting to learn how to use SELinux to set up a proper minimal permissions user for an ircd-hybrid chat server. Next thing I know, I can't log in via SSH. I figured I just managed to break extended permissions, but, long story short, that wasn't the problem.
As it turns out, I somehow have no networking commands on my system any more! I can't ping google. nmcli is gone. ifconfig, ip, network.service NetworkManager.service, almost literally anything Google has pointed me to for setting up networks is just... gone. I do still have the network config file I created (
/etc/sysconfig/network-scripts/ifcfg-enp0s3
), and I do have the broader scope commands, like systemctl, but without the service file that doesn't help.If you have any ideas for how to restore my networking package without being able to use the network, that would be great. But my bigger question is: How in the heck could I have done this in the first place? Could a yum install (say, for settroubleshoot, the selinux troubleshooting package) somehow uninstall another package?
Here's the output of
rpm -qa | grep net
(shortened slightly because I can't copy/paste from a VM terminal, apparently):nettle-2.7.1.4 libnfnetlink-1.0.1 libnetfilter_conntrack-1.0.4 glib-networking-2.40.0
Using root to search my entire system for the above mentioned commands (ex nmcli) returns empty. I'm probably going to just rebuild my server (I have all the important configs pushed to a git repo), but I'd love to know how to not do this again!
Update: I have since gone ahead and rebuilt the OS the same way in a new VM, and confirmed that I have the following (truncated to the important 2):
$ systemctl --all | grep network network.service network.target
On the old box, only network.target is present. Also:
$ rpm -qa | grep net nettle-2.7.1-4.el7.x86_64 libnfnetlink-1.0.1-4.el7.x86_64 libnetfilter_conntrack-1.0.4-2.el7.x86_64 glib-networking-2.40.0-1.el7.x86_64 dracut-network-033-240.el7.x86_64
And the commands ip and nmcli are present. So something did happen to remove all that and I'm not just crazy thinking that they were there.
Update 2: While setting up my new box, I discovered that if I
sudo yum remove iptables
, it actually removes NetworkManager as well, which is where the nmcli command comes from. It did not, however, remove network.service, nor break my connection when removed. So either something else still happened, or it was waiting for a server reboot to completely remove stuff (which I wasn't going to risk).-
Eric Shields about 9 yearsWith all the search results for checking what packages I have, I can't believe I never thought to look at the logs specific to yum... I don't have direct access to the VM right now (I actually had to rebuild my host machine for other reasons) but I'll post what I find when I do.
-
-
cuonglm about 9 yearsWhile this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
-
Dan Cornilescu about 9 yearsAgreed. However duplicated information gradually becomes stale. Updated answer with info allowing focused searches for more up to date answers down the road.
-
Eric Shields about 9 yearsYou are absolutely right that I should have either made better use of snapshots, or otherwise done a more thorough backup. Unfortunately that doesn't answer the question of what actually happened, which is what I am hopeful to achieve.
-
Dan Cornilescu about 9 yearsHard to say without the whole cmd history. Since packages seems missing I can only guess that you may have tried to install some packages which had conflicting dependencies and one of a possible solution a package manager may offer is removing/replacing some of the the installed packages and their dependencies - I have seen such proposals on opensuse, for example, which would have ruined my system if followed.
-
Eric Shields about 9 yearsOh really? I didn't know that packages could actually overwrite things like that. I did discover on my new box that if I remove "iptables" (I have a router firewalled, so at least until I figure out that crazy program I don't need it), it actually removes NetworkManager, which includes nmcli. It does not remove the other stuff, like network.service, though, unless that happens after a reboot? Sounds like the morale of the story might be "Package managers aren't perfect, look closely at what the dependencies are doing!"