Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The new virtual machine cannot execute ifconfig

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

That is, when initializing, we found that the yum source was wrong, so that we could not install wget,ifconfig, etc.

The yum source has now been re-downloaded from another virtual machine, but xshell cannot connect to the newly installed 7.6 machine and cannot replace the downloaded CentOS-Base.repo

1. Make sure that the virtual machine mode is changed to nat, which is connected with the local network. If the bridge mode is used, the IP may not be obtained.

2. Change the ONBOOT permission in the / etc/sysconfig/network-scripts/ifcfg-ens33 file to yes

Restart the gateway service network restart

3. The new machines iptables and selinux must be turned off first, or you will encounter all kinds of strange problems and report the log correctly.

Systemctl stop NetworkManagersystemctl disable NetworkManager

4, set up the firewall

Turn off the firewall

First of all, permanently shut down.

Systemctl disable firewalld.service

Then turn off the current firewall

Systemctl stop firewalld.service

For security reasons, the author chooses to set up a firewall whitelist:

Firewall-cmd-permanent-add-rich-rule= "rule family=" ipv4 "source address=" 192.168.1.8 "port protocol=" tcp "port=" 22 "accept" firewall-cmd-permanent-add-rich-rule= "rule family=" ipv4 "source address=" 192.168.1.8 "port protocol=" tcp "port=" 21 "accept"

Restart the firewall

Systemctl restart firewalld.service

Show a list of firewalls

Firewall-cmd-list-all

Close selinux

Check the selinux status first

Sestatus-v can see SELinux status enabled (default)

Modify / etc/selinux/config to change SELINUX=enforcing to SELINUX=disabled

Then restart the virtual machine.

Note: the permanent shutdown of the above two security services is only suitable for the smooth access of virtual machines in their own experimental environment, which should not be done in the actual production environment.

Still can't connect after rebooting the firewall, check your local address again.

Ip addr

Check the ip address before there is an own dragon, now use the newly discovered address to ping from the local machine:

5. Download new yum source files and install them

When downloading the yum source on another machine, the author chooses Ali's yum source address:

Back up the original YUM source configuration file

Mv / etc/yum.repos.d/CentOS-Base.repo / etc/yum.repos.d/CentOS-Base.repo.backup

Delete the original file

Rm-f / etc/yum.repos.d/CentOS-Base.repo

Get Ali YUM source

Wget-O / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

6. Make the new yum source effective

Clear the previous yum cache

Yum clean all

Load a new yum cache

Yum makecache

Execute yum to install ifconfig

Yum install net-tools

The command is displayed successfully:

Ifconfig

Conclusion: the new machines iptables and selinux must be turned off first, or you will encounter all kinds of strange problems and report the log correctly.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report