Recently I wanted to create a Centos 7 Virtual machine on my Macbook Air (OS El Capitain – 10.11.3), as usual I downloaded an Iso from the net (The minimal Centos 7 Iso Installation).
And as I will want to access my Virtual machine from other computers I wanted to bridge the network.
But I don’t know why I can’t retrieve an IP address from my DHCP Server, so I defined a static IP Address and the network worked fine.
Define the Bridge Adapter in Virtual Box
First in the configuration of the virtual machine on VirtualBox, I attached a network card bridged on the Wi-Fi (en0: Wi-Fi (Airport)).
Define Static Ip Address in Centos 7
First you need to find the name of the interface bridged, so in the virtual machine simply execute the command :
You should obtain something like this :
1: lo: mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s3: mtu 1500 qdisc pfifo_fast state UP qlen 1000 <1>
The name enp0s3 is what we are looking for.
So now you can edit the file :
TYPE="Ethernet" BOOTPROTO="static" <1> IPADDR=192.168.1.211 <2> NETMASK=255.255.255.0 <3> 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="enp0s3" UUID="2191ba05-10f0-4ac2-a0d5-2b060003cc7b" DEVICE="enp0s3" ONBOOT="yes" <4>
- static mean that you want to set the Ip address manually
- This is the IP Address you want for your virtual machine, in my case it is : 192.168.1.211
- The netmask depends on your network setting, usually you can set the same of your host computer
- Be sure to have the ONBOOT option set to yes for starting the network on virtual machine boot.
And finally you need to active the network by editing the file :
# Created by anaconda NETWORKING=yes HOSTNAME=centos1 GATEWAY=192.168.1.1 <1>
- The IP address of the gateway depends on your network configuration.
And now you can restart the network :
Or reboot your virtual machine.
And Test ping pinging some ip (192.168.1.1 / 220.127.116.11)/ domain names : (www.google.com).
And now you can access to your virtual machine.
I don’t know why i can’t obtain an IP address from my DHCP using bridged networking on Wi-Fi, but the Static IP is a satisfying workaround for me.