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

How to configure CentOS7 Network for Virtual Box

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of Virtual Box how to configure CentOS7 network, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this article on how to configure CentOS7 network in Virtual Box. Let's take a look.

Virtual box's optional network access methods include:

Nat Network address Translation Mode (nat,network address translation)

Bridged adapter bridging mode

Internal internal network mode

Host-only adapter host mode

Specific differences there are a lot of information on the Internet, no longer described, the following is the most direct and effective configuration, the configuration of the centos7 virtual machine inside the external network, and the host and centos7 virtual machine can also connect. Whether it is learning or using, it can basically be satisfied. No nonsense, just go to the picture!

Set up virtual box

The best way is to use two network cards, nat (the virtual machine accesses the Internet, using the 10.0.2.x segment) and host-only (the virtual machine and the host communicate with each other, using the 192.168.56.x segment). Set up the network in the preferences. The configuration is as follows:

Next, for the network settings of the centos7 virtual machine, add network card 1 and network card 2, and select the connection method and the corresponding network card respectively:

Note that you write down two mac addresses, which you need to use later in the network configuration file.

Centos7 Network configuration nat Network

After turning on the computer, we visited ping www.baidu.com and found that it was not successful. View the network configuration through the ip addr command.

We can find that the enp0s3 network card (nat) is not working, and the default port of host-only is 192.168.56.101 (described later). Let's first solve the problem of virtual machine access to the Internet.

When you enter the cd / etc/etc/sysconfig/network-scripts/ directory, you can see that there are only ifcfg-enp0s3 configuration files, edit the file, change onboot=no to yes, add bootproto to dhcp, save, exit, and restart the network. Then ping, through, and look at the network configuration, you can see that the enp0s3 network card has been turned on.

You can see that the address corresponding to hwaddr in the default configuration file is the nat network card, so at the beginning, it is said that the nat network card is not working, and host-only will be "turned on" by default and specify the address.

Centos7 Network configuration host-only Network

The virtual network card 192.168.56.1 on the ping host has no problem and is connected, but although we see that the host-only network card has been "turned on", the host cannot access the virtual machine (cannot ping). At this time, we need to use our second network card host-only to complete the host access to the virtual machine.

If there is no ifcfg-enp0s3 file under the cd / etc/sysconfig/network-scripts/ directory, make a copy of ifcfg-enp0s3, rename it to ifcfg-enp0s8, and modify it as follows:

1. Modify hwadr to the mac address of the host-only Nic.

two。 Change bootproto to static.

3. Change name to enp0s8.

4. Modify uuid (you can change a value at will, as long as it is not the same as the previous one).

5. Add ipaddr, which can be made by yourself, and can be used by hosts to connect to virtual machines.

6. Add netmask=255.255.255.0.

Restart the network after modification. You can view the ip addr network configuration by command. You can see that both NICs are working, and the host page can ping the virtual machine.

This is the end of the article on "how to configure the CentOS7 network with Virtual Box". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to configure CentOS7 network in Virtual Box". If you want to learn more knowledge, you are welcome to follow the industry information channel.

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

Development

Wechat

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

12
Report