6

I'm trying use a network bridge adapter for my VM (fresh Ubuntu server 16.04 LTS install) within the latest version of Virtualbox (v5.0.20). Running ifconfig -a gives the following output:

ifconfig

As you can see the IP-address is 192.168.3.59, which is being assigned by the DHCP server of my host network (subnet 192.168.3). So everything seems to work just fine, but when I'm trying to ping to 8.8.8.8, for example, I get the following error message:

Connect: network is unreachable

I've tried different adapter settings, disabling the firewall, created new VM's and Googled everything I could think of; however, nothing solved the problem.

Some more information which may be useful:

  • The host PC runs on Windows 10
  • The interfaces (/etc/network/interfaces) file is untouched
  • Using two adapters (NAT and host-only) works, but this is not what I need
  • I have an old VM (Ubuntu 14.03) working just fine with the bridge adapter

Any help/suggestions would be greatly appreciated!

Edit: added routing table

ip route show outputs the following:

172.23.23.0/24 via 192.168.3.108 dev enp0s3
192.168.3.0/24 dev enp0s3 proto kernel scope link src 192.168.3.59
2
  • This could be routing table issue - Your VM doesn't know where to send packets destined for 8.8.8.8. Add that to the question please ( for example by pasting output of 'ip route show' )
    – Marek Rost
    Commented May 12, 2016 at 13:12
  • @MarekRost I've updated my answer with the routing table.
    – JasonK
    Commented May 17, 2016 at 7:47

2 Answers 2

5

You're missing default route for traffic outside the scope of the subnet. Run following command as privileged user:

ip route add default via ip-of-router-on-local-network dev enp0s3

This should allow you to ping google's servers and make outside connections. Making this setting permanent (to persist after reboot) will depend on the method your VM connects, but this should work on most systems: http://www.linuxquestions.org/questions/linux-networking-3/permanently-add-static-route-16769/

4
  • 1
    You've definetly pointed me in the right direction with the routing table, thanks alot! I've ended up adding sudo ip route add default via 0.0.0.0 dev enp0s3 to etc/network/interfaces. Pretty weird that this route should be added manually, my old VM has added this route by default.
    – JasonK
    Commented May 17, 2016 at 8:24
  • You're welcome. I'm not sure your solution will work though . /etc/network/interfaces isn't parsed as regular shell script. And even if - sudo is unlikely to work as well, since it won't be run by your normal user. Instead try setting the GATEWAY variable in this file to your router, hopefully this will create the default route.
    – Marek Rost
    Commented May 17, 2016 at 8:29
  • Adding up ip route add default via 0.0.0.0 dev enp0s3 works, but setting the gateway doesn't seem to work. Another fun fact is that this problem is only occuring on Ubuntu 16.04, everything works fine on 14.04.4 LTS.
    – JasonK
    Commented May 18, 2016 at 11:57
  • Hmm - this could be due to Ubuntu's transition from upstart init to systemd init. In systemd static network configuration is loaded from /etc/systemd/network/<your-name>.network. Service responsible for loading these settings is systemd-networkd. Consult man page for futher details.
    – Marek Rost
    Commented May 18, 2016 at 12:13
0

Edit the file /etc/sysconfig/network-scripts/ifcfg-enp0s3 changing ONBOOT=no to ONBOOT=yes

vim /etc/sysconfig/network-scripts/ifcfg-enp0s3

1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Oct 23, 2023 at 3:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .