Tag Archives: Host -only static address

VirtualBox + CentOS 7 virtual machine setting static IP address of host only NIC

I am not familiar with the use of VirtualBox. Every time I start the virtual machine, it will be automatically assigned a dynamic IP address (hosting-only), which is very inconvenient for me to use Hadoop and so on. I skipped this problem before, but it took me half a day to solve it finally today.
Specific treatment methods are as follows:
1. Start VirtualBox and select “Administration” –>; “Global Settings”, in the pop-up window, select “Network”, and then in the right window, select the “Host-only Network” TAB, as shown below;

If you don’t have a VirtualBox Host-only Ethernet Adapter, you can add it by clicking “+” on the right.
Then double-click the VirtualBox Host-Only Ethernet Adapter and the following image will pop up:

Select “DHCP Server” and uncheck the “Enable Server” status.


2. Start the virtual machine
Enp0s3 and enp0s8 represent two network cards: Enp0s3 and enp0s8 represent two network cards:
[hadoop@xhp1s2 ~]$ ifconfig
enp0s3: flags=4163< UP,BROADCAST,RUNNING,MULTICAST> MTU 1500
inet6 fe80::a00:27ff:fe4c:2f5b prefixlen 64 scopeid 0x20< link>
ether 08:00:27:4c:2f:5b TXQueuelen 1000 (Ethernet)
Packets 28 bytes 3361 (3.2 Kib)
R>rors 0 dropped 0 overruns 0 frame 0
Tx Pack>58 Bytes 6795 (6.6kib)
errors 0 dropped 0 overruns 0 carrier 0 Collision-losing 0
br> <>bb3 enp0s8: flags=4163< UP,BROADCAST,RUNNING,MULTICAST> MTU 1500
inet6 Fe80 :: A00:27ff: Fe46: D7F8 Prefixlen 64 scopeid 0x20< link>
ether 08:00:27:46: D7: F8 TXQueuelen 1000 (Ethernet)
Packets 24 bytes 6616 (6.4Kib)
R>rors 0 dropped 0 overruns 0 frame 0
Tx Pack>81 9555 bytes (9.3 KiB)
the TX errors 0 dropped overruns carrier collisions 0 0 0 0

In the directory CD /etc/sysconfig/network-scripts, you will see the presence of IFCFG-ENP0S3 file, copy a copy and change the name to IFCFG-ENP0S8, then edit IFCFG-ENP0S8, the final file contents are as follows:
TYPE=Ethernet
HWADDR= 08:00:27.46 :d7:f8 This indicates that the virtual network card address)
BOOTPROTO = static (here to change into the static)
DEFROUTE = yes
PEERDNS = yes
PEERROUTES = yes
IPV4_FAILURE_FATAL = no
IPV6INIT = yes
IPV6_AUTOCONF = yes
IPV6_DEFROUTE = yes
IPV6_PEERDNS = yes
IPV6_PEERROUTES = yes
IPV6_FAILURE_FATAL = no
NAME = enp0s8
UUID = 3 d54f693 – c56 bbef – 4-8984 – e0495a7c21s2 (this unlike enp0s3 coding)
DEVICE = enp0s8
ONBOOT = yes
IPADDR = 192.168.56.103
NETMASK = 255.255.255.0
GATEWAY = 192.168.56.1
Once this is done, start Service Network Restart and everything is OK.