Centos 9 under Parallel Desktop pings the network and configures the whole process of static IP

1. Discover problems

1. Cannot find network card configuration file

/etc/sysconfig/network-scriptsThe configuration file of the network card cannot be found in the directory .

[parallels@localhost network-scripts]$ ls 
readme-ifcfg-rh.txt

2. The network restart command has been unable to be executed successfully.

[root@cool-wangtongzhou system-connections]# service network restart 
Redirecting to /bin/systemctl restart network. service 
Failed to restart network. service: Unit network.service not found.

2. Analyze the problem

In order to ping the virtual machine, I searched for information for a day and encountered all kinds of fancy problems. In addition to the above problems, I also encountered some trivial problems, and I learned a lot in the process.
From Xiaobai’s perspective, I wrote the following two articles:

  1. When switching the root user according to centos in Parallel Desktop, the password is correct, but the switch is always unsuccessful and su: Authentication failure is displayed.
  2. What is DHCP? What does it do? Its working mode? working principle?

During the ping process, I encountered some problems and made some attempts:

  • I encountered the problem of not being able to find the virtual machine network card. I have never found the eth series network card that netizens mentioned. There is only one txt file in the /etc/sysconfig/network-scripts path, and I have not seen any network card related configurations. document
  • So I defined the eth0 configuration file myself, but where is its network card? I don't understand either.
  • service network restartSuch systemctl restart networkcommands cannot be used in centos9, so Failed will always be displayed.
  • Tried turning off the firewall, to no avail
  • I was thinking of reinstalling the system, but it was too troublesome, so I put it aside for now.
  • I'm thinking about trying another virtual machine software. After all, Parallels Desktop still doesn't have as many reference articles as VMware, but I wonder if I will encounter similar problems with VMware? If you don't solve it here, you will encounter the same problem if you go to another software, so it is better to solve it here.
  • Recently, the school had a Hadoop course, and I was thinking, how do I build a cluster behind my Parallels Desktop? Can I only open one virtual machine?

The school’s network was not very easy to use, so I searched on my mobile phone about how to build a cluster for Parallels Desktop virtual machines, and saw this article: Using virtual machines to build a Hadoop distributed cluster based on Ubuntu22.04

There is one place that caught my attention:

So I thought about whether it might be a problem with the system version. Sure enough, (it’s showing off, haha!!), I found it after searching. In centos9, the command cannot be used to configure the networkservice network restart card . It has also changed. /etc/sysconfig/network-scriptsThe configuration file of the network card cannot be found in the directory. You need to /etc/NetworkManager/system-connectionsgo to the directory to find it.

After reading the information for a day, people were really confused. Unexpectedly, the next day, I searched with another keyword on my mobile phone, and I was able to get some inspiration.


Summarize:

  • Search results are related to equipment and keywords
  • The answers can basically be found. Some people should have stepped on these basic operations, but sometimes they are not found.

When you are tired of studying, just change your mind tomorrow and continue learning, change your attitude and continue learning, you will always find the answer, you will always find a solution! !

3. Solve problems

System environment

system Version
Host macOS, dual-core Intel Core i5 macOS Monterey version 12.2
Virtual machine PD Parallels Desktop 18 for Mac
Install system centos9 on the virtual machine Centos Stream release 9 for x86_64 architecture

1. Open the network card configuration file

You can see that the corresponding network card configuration file here is enp0s5.connection. You can use the corresponding directory to check your own network card configuration file.

Paste the code:

[parallels@localhost ~]$ cd /etc/NetworkManager/system-connections
[parallels@localhost system-connections]$ ls
enp0s5.nmconnection
[parallels@localhost system-connections]$ sudo vim /etc/NetworkManager/system-connections/enp0s5.nmconnection

2. Modify ipv4 configuration

Press to ienter INSERT模式, and then you can start editing. If you want to exit, just press esc, then press Save, enter :and wqsave the modified content. Later I will take the time to write down the basic operations of Linux to share with you.

Configure one of them [ipv4]for manual mode and set it ip:

Please add image description

The IP address here should be between 起始地址and 结束地址( 偏好设置check inside, use is Shared模式).

Note: In the configuration file, do not add spaces without authorization, which may cause unrecognition.

3. Reload the network card configuration file

[parallels@localhost ~]$ sudo nmcli c reload
[parallels@localhost ~]$ sudo nmcli c up enp0s5

Use to ifconfigview the network card configuration information and the modification is successful.
Please add image description


4. Ping successfully and you can access the Internet normally.


4. Questions

1. How to determine whether you have set a static IP

A: If the IPv4 address is set manually, it is a static IP address.

2. Is DHCP used when fixing static IP? I saw the following article saying that it needs to be canceled in the configuration?

Paralles virtual machine installation and network configuration – setting static IP
Answer: DHCP is divided into 静态分配IP地址and 动态分配IP地址. What is set
here is to set the IP address configuration to a static IPipv4manual手动模式


5. Reference materials

  1. CentOS Stream 9 configure static IP
  2. centOS7 enables (runs) NetworkManager to manage the network
  3. Paralles virtual machine installation and network configuration – set static IP
  4. Super detailed solution to the problem of network connection between virtual machine and host and mutual ping failure
  5. How to check CentOS version

Guess you like

Origin blog.csdn.net/e2788666/article/details/131178353