The previous article, "Installing CENTOS7 process Records in VirtualBox", describes how to install VirtualBox and install CentOS7 in VirtualBox, but is limited to a number of issues that do not unfold, In this article you will expand on setup issues for VirtualBox and CentOS.
VirtualBox supported virtual machine file types
Vdi:virtual Disk Image, which is the virtual machine file type that VirtualBox uses by default.
VMDK: This is the virtual machine file type that VMware uses by default.
VHD: This is the virtual machine file type that is used by Microsoft to produce virtual machine software by default.
Choose which one to look at when creating a virtual machine, but I generally prefer vmdk because I can give the VMDK file to virtualization management directly into the company's virtual machine resource pool when it is successful. Of course, after creation, it is possible to convert between three formats via the VBoxManage.exe provided by VirtualBox, which is located in the VirtualBox installation directory.
VirtualBox supported virtual machine CPU Settings
The virtual machine created by default only uses 1 cores, sometimes in the case of host hardware is better, in order to have a good experience, you can set multi-core multi-threading, My computer is 4 core 8 threads, so the maximum can be set to 4, as shown in:
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/96/B0/wKioL1kkSszyFN4yAACodFqx5b0101.png-wh_500x0-wm_ 3-wmp_4-s_2137363837.png "title=" Virtualbox_cpu_config.png "alt=" Wkiol1kksszyfn4yaacodfqx5b0101.png-wh_50 "/>
VirtualBox supported virtual Machine Network access mode
When you click on the "Network" option, you will see the following screen:
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/96/B0/wKioL1kkSuXB_mnwAAC7wyNMLMM821.png-wh_500x0-wm_ 3-wmp_4-s_1294929849.png "title=" Virtualbox_network_config01.png "alt=" Wkiol1kksuxb_mnwaac7wynmlmm821.png-wh_50 " />
There are four more important settings in the interface:
Connection mode.
The interface name.
Control chip.
Promiscuous mode.
virtual Machine network connection mode
VirtualBox supports 7 modes of access:
Network address translation nat–network addresses translation (NAT)
Bridging network card –bridged networking
Internal network –internal Networking
Host only (HOST-ONLY) adapter –host-only networking.
Universal Drive –generic Networking
The VirtualBox network connection type setting interface is as follows:
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/96/B0/wKioL1kkSwWT7GJXAACxio1b568954.png-wh_500x0-wm_ 3-wmp_4-s_1859059574.png "title=" Virtualbox_network_config02.png "alt=" Wkiol1kkswwt7gjxaacxio1b568954.png-wh_50 " />
A simple comparison of these types of network connections is as follows:
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/96/B0/wKioL1kkSxijwcAYAABdNWuyn4o224.png-wh_500x0-wm_ 3-wmp_4-s_288360418.png "title=" Virtualbox_network_type.png "alt=" Wkiol1kksxijwcayaabdnwuyn4o224.png-wh_50 "/>
Virtual Machine Network Connection interface name
This is actually the NIC on the current host. In bridged mode, VirtualBox uses a single driver from the host to process network data. Filters the virtual machine's data from the network data. So in bridging mode, be sure to select the network card that is currently in use.
Virtual Machine Network connection control chip
There are several interface names in VirtualBox:
AMD pcnet PCI II (am79c970a);
AMD pcnet FAST III (am79c973, the default):
Intel pro/1000 MT Desktop (82540EM);
Intel pro/1000 T Server (82543GC);
Intel pro/1000 MT Server (82545EM);
Paravirtualized network adapter (virtio-net)
AMD pcnet FAST III (am79c973) is recommended by default because it is supported by almost all operating systems, even the GNU GRUB boot Manager. The Intel Pro Series is designed to support systems that are no longer powered by the operating system, such as Windows Vista. Intel pro/1000 MT Desktop supports Windows Vista and later Windows systems, and Intel pro/1000 T Server can be recognized by Windows XP without the need for driver installation, and Intel pro/1000 M T Server supports the import of OVF format files from other platforms.
Paravirtualized network Adapter (virtio-net) is very special, if you choose Paravirtualized Network Adapter (virtio-net), then you need to ensure that there is a corresponding, Special software interface, to achieve the corresponding network processing.
Virtual Machine Network connection promiscuous mode selection
Promiscuous mode (English: Promiscuous mode) is a term in a computer network. Refers to the ability of a machine's network card to receive all traffic that passes through it, regardless of whether its destination address is it.
General computer network cards are working in non-promiscuous mode, at this time the network card only accept the destination address from the Internet port point to their own data. When the NIC is operating in promiscuous mode, the NIC captures all data from the interface and gives it to the appropriate driver.
All allowed: All data, regardless of whether the destination address is itself, is sent to the virtual machine and the host respectively.
Allow virtual computers: all data (regardless of whether the destination address is itself) is sent only to the virtual machine.
Deny: Both the virtual machine and the host receive only the destination address as their own data.
According to the description of VirtualBox, in bridging mode, the virtual machine is filtered directly from the packet received by the host to be sent to its own packet, in order to ensure that the virtual machines can receive their own packets, it is recommended to select all Allow.
Note: When a host uses WiFi to connect to the network, most wireless cards do not support promiscuous mode, so the host computer may not be able to surf the internet when it uses wireless connectivity to the network. Online read some people's article said is through the lookback to achieve, I tried several times did not succeed, do not know where the problem.
security settings for CentOS7
After using the bridging mode, the following configuration is recommended on the learning machine
Turn off SELinux
SELinux is a security architecture that is integrated into the Linux Kernel 2.6.x through the LSM (Linux Security Modules) framework. It is a joint project of the NSA (United States National Security Agency) and the SELinux community. Decide whether or not to close in a production environment as needed, or close it in a learning environment. In CentOS7 this setting in the/etc/sysconfig/selinux file, you can change "selinux=enforcing" to "selinux=disabled" by software such as Vim.
shutting down the firewall
There is also a firewall similar to Windows in CentOS, Iptables, which is used by default before CentOS7, and firewall by default after CentOS7, you can disable the firewall by performing systemctl disable FIREWALLD. Otherwise, by default, even if you install server software such as Apache or Nginx or tomcat, you will find that you are still unable to access the corresponding port on other terminals, because the firewall is turned on by default and fewer ports (such as 22 ports, SSH connection) are enabled.
Note: The above is used to shut down the Seliunx and shut down the firewall is only suitable for learning Linux server-related knowledge of the machine, production environment on-machine or honest configuration.
Network settings for CentOS7
set IP for CentOS7
According to my experience, under CENTOS7, the default network IP configuration file name may change, you can view the file under the/etc/sysconfig/network-scripts directory:
The command is as follows:
Ls-lh/etc/sysconfig/network-scripts
The effect on my virtual machine is as follows:
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M00/96/AF/wKiom1kkS2GCb2_GAADBZoBkksE708.png-wh_500x0-wm_ 3-wmp_4-s_3766055436.png "title=" Centos7_network_config01.png "alt=" wkiom1kks2gcb2_gaadbzobkkse708.png-wh_50 "/ >
This configuration file usually begins with "IFCFG-ENP" file, in my virtual machine for "IFCFG-ENP0S3", can be edited by Vim. Because I set up a router in the home, for the convenience of operation so VirtualBox used the bridge mode, The router IP address is 12.168.60.1, so the static IP address of CentOS is also in the 192.168.60 network segment (the reason for using static IP is that you don't want to look at its dynamic IP every time you log in to CentOS7 via SSH).
I mentioned in my previous article that the/ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ENP0S3 by default when VirtualBox installs CentOS7:
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/96/B0/wKioL1kkS3jzXgDWAACrgo-m0FE239.png-wh_500x0-wm_ 3-wmp_4-s_680234943.png "title=" Virtualbox_network_config04.png "alt=" wkiol1kks3jzxgdwaacrgo-m0fe239.png-wh_50 "/ >
This is another configuration information on CentOS that can access the virtual network normally:
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/96/AF/wKiom1kkS4mwfGC3AAAtYk3Za2Y074.png-wh_500x0-wm_ 3-wmp_4-s_2308211522.png "title=" Virtualbox_network_config05.png "alt=" Wkiom1kks4mwfgc3aaatyk3za2y074.png-wh_50 " />
Compared with the main difference is as follows:
"Bootproto=dhcp" to "bootproto=static", that is, the dynamic assignment of IP address changed to a fixed IP address (otherwise each IP address changes, also have to change the IP address in the SSH client settings, rather cumbersome);
"Onboot=no" is changed to "Onboot=yes", indicating that the system automatically connects to the existing network after booting;
Added "ipaddr=192.168.60.148", you need to specify a fixed IP address because the Get IP mode is changed from dynamic mode to fixed IP. Note: The actual IP address should be set according to the current network segment settings.
Added "Prefix=24", which represents the subnet mask. We know that the IP4 is represented by 4 bytes, which translates it to 10 when it is used for easy identification, such as 192.168.1.1, and each byte is 8bit, here 24 means that if the network segment in the first 24bit of the other IP and its strict match, then the two IP is in the same subnet segment, in the configuration of the Windows network when the same meaning of the subnet mask is: 255.255.255.0.
Added "gateway=192.168.60.1" to indicate the gateway address. Note: The actual IP address according to the current network segment settings, I set the home router to 192.168.60 network segment, rather than the default router 192.168.1 network segment.
set up domain name resolution
CENTOS7 Domain name resolution server settings information saved in the/etc/resolv.conf file, can be modified by vim/etc/resolv.conf, is my current virtual machine domain name resolution settings:
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/96/B0/wKioL1kkS6aQIoYjAAAjY8inGnM560.png-wh_500x0-wm_ 3-wmp_4-s_1070738037.png "title=" Virtualbox_network_config06.png "alt=" Wkiol1kks6aqioyjaaajy8ingnm560.png-wh_50 " />
The lookup principle of the domain name resolution server is consistent with the event handling rules in the general program: if the nearest rule definition can be processed, then it is handled by the nearest handler, otherwise bubbling to the upper level handler. The DNS service is not used in both host and virtual machines, although 192.168.1.1 and 192.168.60.1 are set up as DNS servers, but for external domain names they are not able to resolve, they try to look up for DNS servers that can resolve external domain names. For the sake of insurance, it is recommended to add the DNS provided by the telecom operator in the city.
Set host name
The hostname settings for CentOS are stored in/etc/hostname and can be modified by Vim/etc/hostname, as follows:
[Email protected] ~]# Vim/etc/hostname
Centos7
Unlike the graphical user interface settings in Windows, when you change the IP configuration of a virtual machine in the way above, you need to restart the network to take effect, and the command to restart the network is:
Systemctl Restart Network.service
Multiple NIC settings for VirtualBox
In the VirtualBox can support multiple network cards, the general situation may be of little use, but in some cases this is still useful, such as my current situation: home to pull a telecommunications broadband, for the convenience of the whole family mobile Internet wireless router erected in the living room, while the notebook in the study, As mentioned earlier, promiscuous mode is not supported when using bridging mode in wifi conditions, that is, packets that cannot be filtered from packets received by the host to a virtual machine (the host and virtual machines can communicate in bridged mode). There are two options: one, the use of NAT mode virtual machine and host can be Internet access, but on the host can not access the virtual machine through the SSH client, the use of great inconvenience; second, the use of bridged networking (bridge) is a host to access the virtual machine and the Internet (can use the SSH client) , but the virtual machine is unable to surf the internet.
Inadvertently found that the telecommunications broadband light cat to take care of the general family situation provides two access ports, respectively support the Internet and ITV. This ITV I used for a few years, and now useless, so in light cat in a cable to the living room wireless router, one to the study network cable slot and finally connected to the notebook. So the notebook in the study can use WiFi and wired at the same time, so the virtual machine in the CentOS7 configured with a dual network card, so that in the virtual machine using WiFi, host and virtual machine can be online, and host can access the virtual machine through SSH and so on.
This is why two network configurations are possible (IFCFG-ENP0S3 and ifcfg-wired_connection_1, respectively) when the ls-lh/etc/sysconfig/network-scripts is executed earlier.
The following is an animated demonstration of all the configurations in this article:
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/96/AF/wKiom1kkTFXBldV0AAn5ysAd8Ak827.gif-wh_500x0-wm_ 3-wmp_4-s_1264298513.gif "title=" Virtualbox_cpu_config_demo.gif "alt=" wkiom1kktfxbldv0aan5ysad8ak827.gif-wh_50 "/ >
This article is from the "Zhou Gong (Zhou Jinchao) column" blog, please be sure to keep this source http://zhoufoxcn.blog.51cto.com/792419/1928803
Developer Linux (2): Install CentOS7 system settings in VirtualBox