I've got an Oracle Linux 7.2 guest inside VirtualBox, the host is Ubuntu 16.10. I configured 2 network adapters - first is a Bridged Adapter (enp0s3) to the wi-fi interface, second is a Host-only Adapter (enp0s8) with a static IP. After I start the virtual machine I can ssh into it through the Host-only Adapter, I even see that it connects to the wi-fi router and can ping it but I don't get a connection to the outside of my LAN until I restart the network service (in the guest OS). I tried to only restart the bridged adapter (ifdown enp0s3; ifup enp0s3) but it doesn't work.
So, anyone knows where to start looking for reasons and solutions? I would like the machine to connect to the internet automatically, without having to restart the network service every time.
➜ ~ vm
Waiting for VM "Oracle Linux 7.2" to power on...
VM "Oracle Linux 7.2" has been successfully started.
➜ ~ ping vm002 #IP of the guest Host-only Adapter
PING vm002 (192.168.56.2) 56(84) bytes of data.
64 bytes from vm002 (192.168.56.2): icmp_seq=6 ttl=64 time=0.187 ms
64 bytes from vm002 (192.168.56.2): icmp_seq=7 ttl=64 time=0.185 ms
--- vm002 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1599ms
rtt min/avg/max/mdev = 0.185/0.186/0.187/0.001 ms
➜ ~ ping 192.168.1.4 #IP of the guest on the LAN
PING 192.168.1.4 (192.168.1.4) 56(84) bytes of data.
64 bytes from 192.168.1.4: icmp_seq=1 ttl=64 time=0.178 ms
64 bytes from 192.168.1.4: icmp_seq=2 ttl=64 time=0.192 ms
64 bytes from 192.168.1.4: icmp_seq=3 ttl=64 time=0.194 ms
--- 192.168.1.4 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2045ms
rtt min/avg/max/mdev = 0.178/0.188/0.194/0.007 ms
▶ nmcli device status
DEVICE TYPE STATE CONNECTION
enp0s3 ethernet connected enp0s3
enp0s8 ethernet connected enp0s8
lo loopback unmanaged --
▶ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:48:21:1f brd ff:ff:ff:ff:ff:ff
inet 192.168.1.4/24 brd 192.168.1.255 scope global dynamic enp0s3
valid_lft 85908sec preferred_lft 85908sec
inet6 fe80::a00:27ff:fe48:211f/64 scope link tentative dadfailed
valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:7f:8b:5f brd ff:ff:ff:ff:ff:ff
inet 192.168.56.2/24 brd 192.168.56.255 scope global enp0s8
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe7f:8b5f/64 scope link
valid_lft forever preferred_lft forever
▶ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=7.07 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=6.88 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=7.33 ms
^C
--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 6.884/7.096/7.332/0.196 ms
▶ ping google.com
PING google.com (216.58.209.206) 56(84) bytes of data.
^C
--- google.com ping statistics ---
17 packets transmitted, 0 received, 100% packet loss, time 15999ms
▶ sudo service network restart
Restarting network (via systemctl): [ OK ]
▶ ping google.com
PING google.com (216.58.209.174) 56(84) bytes of data.
64 bytes from bud02s21-in-f174.1e100.net (216.58.209.174): icmp_seq=1 ttl=58 time=38.8 ms
64 bytes from bud02s21-in-f14.1e100.net (216.58.209.174): icmp_seq=2 ttl=58 time=43.1 ms
64 bytes from bud02s21-in-f14.1e100.net (216.58.209.174): icmp_seq=3 ttl=58 time=83.2 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 38.868/55.096/83.238/19.978 ms
▶ nmcli device status
DEVICE TYPE STATE CONNECTION
enp0s3 ethernet connected enp0s3
enp0s8 ethernet connected enp0s8
lo loopback unmanaged --
▶ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:48:21:1f brd ff:ff:ff:ff:ff:ff
inet 192.168.1.4/24 brd 192.168.1.255 scope global dynamic enp0s3
valid_lft 86377sec preferred_lft 86377sec
inet6 fe80::a00:27ff:fe48:211f/64 scope link tentative dadfailed
valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:7f:8b:5f brd ff:ff:ff:ff:ff:ff
inet 192.168.56.2/24 brd 192.168.56.255 scope global enp0s8
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe7f:8b5f/64 scope link
valid_lft forever preferred_lft forever