I have the following setup:
- Windows host running virtualbox
- Ubuntu server as a guest
I've enabled a second networking interface in Virtualbox - a bridged one - so I can connect to the instance via ssh, http etc
(note: this has always worked using ubuntu desktop using the GUI to configure networking, but now I'm using ubuntu server and doing it manually in ubuntu)
This is roughly what I do:
I have the instance running and I can, eg. ping stackoverflow.com and I get an IP address
I stop the server, enable the second adapter in virtualbox
I start the instance again
I can see that the interface is listed using ifconfig -a
I open /etc/network/interfaces
and add the eth1 controller, so my interfaces file looks like this:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet dhcp
and when I restart using /etc/init.d/networking restart
everything seems to work - ie. ifconfig gives me this:
eth0 Link encap:Ethernet HWaddr 08:00:27:ad:75:94
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fead:7594/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1074 errors:0 dropped:0 overruns:0 frame:0
TX packets:318 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1301455 (1.3 MB) TX bytes:26248 (26.2 KB)
eth1 Link encap:Ethernet HWaddr 08:00:27:73:f7:37
inet addr:192.168.1.149 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe73:f737/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:464 errors:0 dropped:0 overruns:0 frame:0
TX packets:243 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:65921 (65.9 KB) TX bytes:32173 (32.1 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
And I can connect to the instance using ssh, so networking is working..
however, DNS resolving seems to be not working, because when I ping any website (eg. stackoverflow.com) it just times out..
I checked /etc/resolv.conf and everything looks fine (in fact, looks the same as the one on my ubuntu desktop instance.
Any ideas?
Please provide the output of
sudo ip route list
. I think your queries leave the box on one interface while they come back on another and your kernel will throw them away..Try do disable the unbridged interface and retest the connectivity again:
If this doesn't work: are you able to ping to
8.8.8.8
?Update:
If you use bridged networking there is no need to use VirtualBox as NAT.
The problem was, as expected, that DNS is configured to ask via eth0, the shorter way is through eth1, so the answer comes via eth1. Your kernel however doesn't expect any message on eth1 and drops them..