In my Virtual Machine I have two network interfaces (both bridge mode, I need bridge mode because I want to create a server). One of them is Ethernet (eth0) and the other WiFi (wlan0) - In the guest (CentOS) they are represented as enp0s3 and enp0s8.I set static IPs for them, but the connection only works when my laptop is connected to an Ethernet cable. When I remove it and the laptop switches to WiFi, I get the problem, even with the interface enp0s8 (which in the VirtualBox config is wlan0)Host: Ubuntu 14.04Guest: CentOSVirtualBox Network Settings:* Adapter 1:   * Mode: Bridge  * eth0  * Network Card: Intel PRO/1000 MT Desktop (82540EM)  * MAC: 080027BAC610* Adapter 2  * Mode: Bridge  * wlan0  * Network Card: Intel PRO/1000 MT Desktop (82540EM)  * MAC: 080027F97DAE I have run the following commands:[root@localhost network-scripts]# ip a1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1    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 forever2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000    link/ether 08:00:27:ba:c6:10 brd ff:ff:ff:ff:ff:ff    inet 192.168.15.10/24 brd 192.168.15.255 scope global enp0s3       valid_lft forever preferred_lft forever    inet6 fe80::99a9:d4a6:23c4:df9d/64 scope link       valid_lft forever preferred_lft forever3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000    link/ether 08:00:27:f9:7d:ae brd ff:ff:ff:ff:ff:ff    inet 192.168.15.24/24 brd 192.168.15.255 scope global enp0s8       valid_lft forever preferred_lft forever    inet6 fe80::a00:27ff:fef9:7dae/64 scope link       valid_lft forever preferred_lft forever[root@localhost network-scripts]# tracepath 8.8.8.8 1?: [LOCALHOST]                                        pmtu 1500 1:  localhost.localdomain                              3006.372ms !H     Resume: pmtu 1500ifcfg-enp0s3 represents the first adapter (eth0)[root@localhost network-scripts]# cat ifcfg-enp0s3HWADDR=08:00:27:BA:C6:10TYPE=EthernetBOOTPROTO=staticIPADDR=192.168.15.10NETMASK=255.255.255.0DEFROUTE=yesPEERDNS=noDNS1=8.8.8.8DNS2=8.8.4.4GATEWAY=192.168.15.1PEERROUTES=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_PEERDNS=noIPV6_PEERROUTES=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=enp0s3UUID=6136f542-2b00-3fbd-a076-b80757d67316ONBOOT=yesAUTOCONNECT_PRIORITY=-999ifcfg-enp0s8 represents the second adapter (wlan0).DEVICE=enp0s8BOOTPRO=staticONBOOT=yesHWADDR=08:00:27:F9:7D:AEIPADDR=192.168.15.24NETMASK=255.255.255.0GATEWAY=192.168.15.1Also we have the command ip r and the result of /etc/resolv.conf[root@localhost network-scripts]# ip rdefault via 192.168.15.1 dev enp0s3  proto static  metric 100default via 192.168.15.1 dev enp0s8  proto static  metric 101192.168.15.0/24 dev enp0s3  proto kernel  scope link  src 192.168.15.10  metric 100192.168.15.0/24 dev enp0s8  proto kernel  scope link  src 192.168.15.24  metric 101[root@localhost network-scripts]# cat /etc/resolv.conf# Generated by NetworkManagernameserver 8.8.8.8nameserver 8.8.4.4How can I make the connection work regardless of whether or not an Ethernet cable is plugged in?
VirtualBox Bridge Networking: doesn't work when my laptop is on Wifi
ubuntu;centos;networking;wifi;virtualbox
Having two connections on the same network needs to be done carefully (why would the system route to/from the wifi connection if the eth one is on the same network). Try moving the ethernet onto a different network from the wifi.If you don't control the network and therefor can't change the addresses bring down the eth interface and then try to route:sudo ip link set eth0 down