Recently some days in learning about virtual machine VirtualBox, now share for your reference.
First, virtual machine network configuration
The default is to set the NIC 1: Mode NAT (corresponding to Ifcfg-eth0)
We can also set the network card 2, network card 3. Can be set after system installation is complete.
Network card 2 set loop network card, the realization of virtual machine and host LAN (corresponding ifcfg-eth1), so that even if no routers can be composed of LAN, can be SSH connection.
Host hosts are required to install Microsoftloopbackadapter. Participate in the Appendix.
The NIC 3 setting is connected to the Internet and is composed of a local area network (corresponding to ifcfg-eth2) with host hosts. Need to rely on the network and have a real router.
Second, CentOS ETH settings
Enter/etc/sysconfig/network-scripts directory, default only Ifcfg-eth0.
Copy Ifcfg-eth0 as Ifcfg-eth1, modified to:
Device=eth1
#HWADDR =08:00:27:31:f1:dc
type=ethernet
#UUID =b8f8e76e-1f8b-4cf5-9261-493bfc6b04ef
Onboot=yes
Nm_controlled=yes
bootproto=static
ipaddr= "192.168.12.10"
gateway= "192.168.12.1"
Copy Ifcfg-eth0 as Ifcfg-eth2, modified to:
Device=eth2
#HWADDR =08:00:27:31:f1:dc
type=ethernet
#UUID =b8f8e76e-1f8b-4cf5-9261-493bfc6b04ef
Onboot=yes
Nm_controlled=yes
Bootproto=dhcp
Once saved, use the command: Servicenetworkrestart Restart the network service, and if Ifcfg-eth1 and ifcfg-eth2 are displayed in green, the two settings are successful.
Network card file Content Sample Description:
Device=eth0 //Indicates the device name bootprot=static// Startup type dhcp|static
broadcast=192.168.1.203 //broadcast address
hwaddr=00:06:5b:fe:df:7c //Hardware MAC address
ipaddr=192.168.0.2 //ip address
netmask=255.255.255.0 //Subnet mask
network=192.168.0.0/ /network address
gateway=192.168.0.1 //gateway address Onboot=yes//whether to start the application
type= Ethernet //network type
To verify the results, you can enter ifconfig for verification:
[Root@localhost network-scripts]# ifconfig eth1 Link encap:ethernet, hwaddr 08:00:27:e9:68:b0 inet. 12.10 bcast:192.168.12.255 mask:255.255.255.0 Inet6 addr:fe80::a00:27ff:fee9:68b0/64 scope:link up BROADCAST
RUNNING multicast mtu:1500 metric:1 RX packets:1682 errors:0 dropped:0 overruns:0 frame:0 TX packets:775 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:134511 (131.3 Ki B) TX bytes:109027 (106.4 KiB) eth2 Link encap:ethernet hwaddr 08:00:27:2e:18:7a inet addr:192.168.36.85 Bcas t:192.168.36.255 mask:255.255.255.0 inet6 addr:fe80::a00:27ff:fe2e:187a/64 scope:link up BROADCAST MU
Lticast mtu:1500 metric:1 RX packets:885 errors:0 dropped:0 overruns:0 frame:0 TX packets:42 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:72712 (71.0 KiB) TX bytes:4156 (4.0 KiB) Lo Link encap:local loopback addr:127.0.0.1 mask:255.0.0.0 Inet6 Addr::: 1/128 scope:host up loopback RUNNING mtu:16436 metric:1 RX Packs
Ets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 RX bytes:1028 (1.0 KiB) TX bytes:1028 (1.0 KiB)
Can show the eth1 and eth2 the description succeeded.
Appendix:
Method of installing Microsoft Microsoftloopbackadapter (Loopback network card) on Windows7
1. Click the Start icon, enter Hdwwiz in the search result, right-click the program in the search results, and use the "Run as Administrator" method to start.
2. According to the Operating System wizard, select Install the hardware (advanced) that I manually select from the list.
3. In the hardware list, select network adapters.
4. Select "Microsoft" Vendor, and in the right network adapter list select "Microsoftloopbackadapter", next follow the wizard to complete the installation.
5. After the installation is complete, view the hardware manager, will have a new network card, this is the virtual network card.
Next, you need to make some configuration:
Open Network and Sharing Center-> change adapter settings, locate the network that identifies the Microsoftloopbackadapter, right-click the property, select Internet Protocol version 4 (TCP/IPV4), and click the properties below to edit as:
The gateway here is my own definition, 192.168.12.1, of course, can be changed to other, such as 192.168.13.1. Host IP Here is 192.168.12.2, the virtual machine can not be set for this. This corresponds to the virtual machine eth1, and Eth1 's IP comes from here. You can save it after you modify it.
Note that the loopback network card is best set before setting up the virtual machine network.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.