Routes table for two network interfaces

Discussions related to using VirtualBox on Windows hosts.
Post Reply
arkkimede
Posts: 11
Joined: 9. Mar 2017, 18:09

Routes table for two network interfaces

Post by arkkimede »

Hi! I'm using a PC 64bit with Windows 10 where is installed VB and into VB an ubuntu 14.04.05 LTS.
Working with an embedded system, I have to connect this board with the PC (ubuntu) using an Ethernet cable but also I need the connection to internet offered by the pc. So, in VB I defined 2 network interfaces, the first one with nat, connection to internet through the pc, and the second one bridged to connect the embedded system with VBubuntu.
The problem is that simultaneously the two network interfaces do not work. Depending on what I have to do, I have to disable one of these interfaces.
A friend said me that probably i need to "instruct" the two interfaces where they have to go so, (probably) i need a routes table.
Could someone to help me?
Thank you in advance
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Routes table for two network interfaces

Post by scottgus1 »

If you just use the Bridged connection, and you connect the embedded device to the same network that the host is connected to, then the guest and host and embedded device will all be on the same network. They should all be able to talk to each other and the internet. Try disabling the NAT network and connecting the device to your LAN.
arkkimede
Posts: 11
Joined: 9. Mar 2017, 18:09

Re: Routes table for two network interfaces

Post by arkkimede »

The question is that I can not have both the network interface working.
I have to disable the nat if I want to communicate with the embedded system or the bridged if I want to connect to internet.

How to have both and simultaneously the network interfaces working?
Thanks
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Routes table for two network interfaces

Post by scottgus1 »

I know of no reason why you can't have Bridged and NAT in the same guest. I have had such a setup before and it worked.

Unfortunately many folks can and do mess up their network setup far beyond what Virtualbox controls, which might make your setup break while mine works.

Please explain exactly how your embedded device is connected.
BillG
Volunteer
Posts: 5105
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Routes table for two network interfaces

Post by BillG »

I agree. Adding static routes will do nothing for this because it is not a routing problem. What static routes could you possibly use?

What IP addresses are you using on the bridged devices?
Bill
arkkimede
Posts: 11
Joined: 9. Mar 2017, 18:09

Re: Routes table for two network interfaces

Post by arkkimede »

I try to report what I mean.

The system is a PC Toshiba Portegé Win10 64bit with internet connection using a SIM installed in the PC.
On this pc is installed Virtual Box and in Virtual Box is installed a virtual machine with Ubuntu 14:04.

On this virtual machine there is a first Network Interface (NI) configured NAT an a second NI configured with bridged and using the configuration interface of ubuntu, I set this second NI in order to share network with the embedded system

The embedded system is a Raspberry PI3 with Raspbian Jessie Lite operative system.
Using an Ethernet cable I connect PC and Raspberry PI.

In this configuration (connecting the PC to internet) on Ubuntu (Virtual Box) if I execute sudo apt-get update I do not have any internet connection.

Similar to the RPI that have and if address but no internet connection.

If I configure the two NI like NAT, Ubuntu is able to connect to internet but RPI no.

Now the question is:

It is possible, using a Virtual machine on Virtual box, keeping the internet connection on the Host PC and share the net with the embedded system connected via Ethernet cable?
If yes what configuration I have to set.
Thank you for any clarification and support.
BillG
Volunteer
Posts: 5105
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Routes table for two network interfaces

Post by BillG »

Thank you for the additional information. I think it is possible, but not by using VirtualBox NAT settings. You will need an extra step to allow the Raspberry to see the Internet. The common networking term to describe this problem is that you are two hops from the Internet. You need another level of routing or a different networking configuration.

The neatest solution, in my mind, would be to run a additional vm as a router and have both the Ubuntu and the Raspberry behind that router. The other solution would be to run routing software in the Ubuntu vm or in the host machine but there could be problems with some of these because your Internet connection is wireless. Bridged networking does not always work properly with wireless connections.

The solution which does not require bridging to the wireless connection is routing through the host OS. This is not easy because Microsoft does not include any routing software in a Windows client OS except ICS, which is very limited (but would probably do the job for you). Or you could install third party routing software in the host and run it as a NAT router.

If you did either of these things, the setup would be simple. The Ubuntu vm would need only one interface bridged to the Ethernet NIC of the host (where the Raspberry connects). Both the Ubuntu guest and the Raspberry would get their IP config from NAT/ICS and would be in the same subnet, so that they could see each other and the host, and have Internet access through NAT on the host.
Bill
arkkimede
Posts: 11
Joined: 9. Mar 2017, 18:09

Re: Routes table for two network interfaces

Post by arkkimede »

Hi Bill, thank you for your answer, is exactly what I was searching.
I think that the solution is running the ubuntu and the Raspbebby Pi behind a vm router.
Please, could you indicate me if I can find a guide to do that?
I found this example http://www.brianlinkletter.com/how-to-u ... a-network/ that is more complex respect to what I need (3 pc and 3 routers).
Thank you again.
BillG
Volunteer
Posts: 5105
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Routes table for two network interfaces

Post by BillG »

Yes that would be fine as long as you can successfully bridge the "public" NIC of your virtual router to your wireless connection. This is essential so that your virtual router has Internet access.

I would use a virtual appliance such as pfSense. It is fairly easy to configure as a NAT router and works well in VirtualBox.

The networking setup is fairly simple. The public interface of the virtual router is bridged to your Internet connection so that it has Internet access. The private interface is bridged to the Ethernet NIC of the host. The Raspberry should have Internet access as soon as you plug it in and start it. It will get its config from NAT. Your Ubuntu vm (with only one NIC) should also work automatically when you bridge it to the Ethernet NIC of the host (so that it is in the same network as the Raspberry) then start it.

And I agree the example you mention is too complex for your needs.
Bill
BillG
Volunteer
Posts: 5105
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Routes table for two network interfaces

Post by BillG »

You will probably not be able to use bridged mode if you Internet connection is using a SIM card. But in a simple setup like this, you should be able to use VirtualBox NAT for the public connection of your virtual router. I had never used it because all my hosts have Ethernet cable connections and I use bridged. However I was confident that a NAT connection would work. ( I have used a NAT router behind another NAT router before).

The good news is that pfSense works perfectly for the guests when the public NIC is using VirtualBox NAT.
pfsense.PNG
WindowsClient.PNG
As you can see from the attachments, the pfSense router is using a VirtualBox NAT address on its public interface and a 192.168.1.x address as its private IP. The client gets 192.168.1.100 from DHCP and has Internet access.
Bill
arkkimede
Posts: 11
Joined: 9. Mar 2017, 18:09

Re: Routes table for two network interfaces

Post by arkkimede »

Thank you very much Bill.
I'm not very skilled in this topic but with yours suggestions and googling on internet about pfSense, I hope to achieve to share the network between PC, VM and RPI3.

If I will not able to do that, the last solution is to have a multi boot pc that can be used in Windows or Linux, avoiding to use virtual machine and Virtual Box.
This last solution is not the maximum but I can not stop here for long time.

Thank you again Bill.
Post Reply