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 method of CentOS7 Network configuration under VirtualBox

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article will explain in detail the methods of CentOS7 network configuration under VirtualBox. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

The methods described in this paper are also applicable in RHEL6.5, RHEL7 and CentOS6.5.

1. Tools: VirtualBox, virtual machine: CentOS7

Network configuration in the 2.VirtualBox tool

(1) VirtualBox global settings: manage-> Global Settings-> Network-> Host only (host-only)

Note: since the purpose of my configuration is to build the network environment of OpenStack, I have created a new network card Virtualbox Host-Only Ethernet Adapter # 2 here as the management network of openstack. If you only want to configure one network card, you can directly use the Host-Only network Virtualbox Host-Only Ethernet Adapter that already exists in VirtualBox.

The Virtualbox Host-Only Ethernet Adapter settings of the first Nic are as follows:

The Virtualbox Host-Only Ethernet Adapter#2 settings of the new second Nic are as follows:

And the DHCP server option of both network cards is not enabled.

(2) in order to connect to the external network, share the local wireless network with VirtualBox Host-Only Network, that is, the first network card.

(3) configure the network card for the virtual machine in VirtualBox:

Network card 1:

Nic 2 (you don't need to do this if you don't need two NICs):

Note that the MAC addresses of the two network cards are different. Remembering them will help you determine which network card corresponds to which configuration file in the next step (the ether in the ifconfig command is followed by the MAC address).

3. Network configuration in the virtual machine

(1) configuration of ifcfg-xxx files

Because two network cards are assigned to the virtual machine in virtualbox, you can see two network configuration files ifcfg-xxx in the virtual machine.

The two files are configured as follows

Ifcfg-enp0s3 (you can see from the MAC address that it corresponds to the Virtualbox Host-Only Ethernet Adapter in VirtualBox):

Note: BOOTPROTO can also be set to static so that the configured IP is static.

Ifcfg-enp0s8:

(2) configuration of / etc/resolv.conf file

Modify DNS to add a domain name server to the / etc/resolv.conf file so that the virtual machine can connect to the external network

Nameserver 192.168.137.1

(3) restart the network: service network restart, and then use the ifconfig command to view

Note: sometimes even if the ifcfg-xxx files are configured correctly, and the network is restarted with the service network restart command, and you use the ifconfig command to see that the IP is still not configured as you want, you can use the ifdown command (such as ifdown enp0s3) to close the network card first, and then use the ifup command to turn it on. If not, you need to go back to see if the file is really configured correctly.

4. Network testing:

(1) ping himself

Ping-c 4 10.0.0.11

Ping-c 4 192.168.137.110

Ping-c 4 controller (need to add ip to hostname mapping in / etc/hosts file)

(2) ping public network

At this point, the network configuration is complete.

This is the end of this article on "the method of CentOS7 network configuration under VirtualBox". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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