Page 1 of 1

Multiple network interfaces for Linux guests

Posted: 31. Jul 2013, 11:34
by Milad
Is it possible to have both bridged mode and NAT enabled on a virtualbox linux guest? I want bridged adapter as the default one to access my guest's home directory from other computers on the network (using samba), and at the same time I need guest to access the host locally. Does this even make sense?

I tried enabling both adapters in VirtualBox and I can see both of them in my guest now. I can ping the first one (192.168.39.107) from my windows host but not the second one (10.0.3.15).

Code: Select all

$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:10:ad:0d  
          inet addr:192.168.39.107  Bcast:192.168.39.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe10:ad0d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:302443 errors:0 dropped:0 overruns:0 frame:0
          TX packets:64619 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:113996112 (113.9 MB)  TX bytes:34120651 (34.1 MB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:99:1c:13  
          inet addr:10.0.3.15  Bcast:10.0.3.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe99:1c13/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1477 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1785 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:930120 (930.1 KB)  TX bytes:215640 (215.6 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:65536  Metric:1
          RX packets:8864 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8864 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:19021832 (19.0 MB)  TX bytes:19021832 (19.0 MB)
My /etc/interfaces does not seem to have much in it:

Code: Select all

$ more /etc/network/interfaces 
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
And some other diagnostics (which don't make sense to me):

Code: Select all

$ netstat -i
Kernel Interface table
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500 0    303846      0      0 0         64931      0      0      0 BMRU
eth1       1500 0      1478      0      0 0          1795      0      0      0 BMRU
lo        65536 0      8911      0      0 0          8911      0      0      0 LRU


$ netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         192.168.39.254  0.0.0.0         UG        0 0          0 eth0
10.0.3.0        *               255.255.255.0   U         0 0          0 eth1
link-local      *               255.255.0.0     U         0 0          0 eth1
192.168.39.0    *               255.255.255.0   U         0 0          0 eth0

Re: Multiple network interfaces for Linux guests

Posted: 31. Jul 2013, 11:59
by BillG
To be frank, it doesn't make any sense to me. There are valid reasons for having more than one network interface in a vm, but I can't see one here. Why can't you access the host from the guest (and vice versa) from your bridged adapter? Why would accessing the host be any different from accessing any other machine on the network?

In any case, the preferred option to access the host from the guest would be host only, not NAT. NAT is the default setting because it gives the guest access to the Internet, but you have that already if you use bridged.

Re: Multiple network interfaces for Linux guests

Posted: 31. Jul 2013, 12:23
by Milad
Well, I'm running this sort of simulator application on my windows host which advertises its services as private IPs, which means they're not accessible through the whole network. Now if I just have a NAT interface, I can easily see and connect to those services but not when I have bridged and NAT at the same time. I hope it makes more sense now.

Re: Multiple network interfaces for Linux guests

Posted: 31. Jul 2013, 14:35
by noteirak
Well I guess your gateway on the bridge interferes with the gateway on the NAT. The setup is a bad idea tbh. Choose which one is best for you.

Re: Multiple network interfaces for Linux guests

Posted: 31. Jul 2013, 15:31
by Milad
How can I fix the gateways then? As you have probably guessed by now I'm by no means a networking expert. And is there a better setup to achieve the same thing?

Re: Multiple network interfaces for Linux guests

Posted: 31. Jul 2013, 19:53
by noteirak
Don't use NAT AND Bridged mode. Choose one, whichever suits your needs best - that would be Bridged here

Re: Multiple network interfaces for Linux guests

Posted: 1. Aug 2013, 07:00
by BillG
What does not work if you use bridged mode only? In bridged mode the guest should behave just like any other machine on the network.