[Resolved] Networking with 2 NICs

Discussions related to using VirtualBox on Linux hosts.
Post Reply
acb764se
Posts: 3
Joined: 27. Sep 2019, 11:14

[Resolved] Networking with 2 NICs

Post by acb764se »

Hi network-wizards!

My desktop (the host) runs Xubuntu Bionic beaver, and has 2 wired network cards. The main one is connected to the world via my home router (I am posting this through it!) and to my other 2 home PCs, and the auxiliary card _usually_ goes to a separate network containing my home security cameras but for now, because of this debugging, there is only one camera, directly connected with its cable without hubs and other stuff. My host can ping the camera allright and fetch its pictures.

In the VirtualBox I run a CentOS6 minimal guest, but can't get to ping the camera, and of course i don't get the pictures. I tried several configurations, the one that looks more promising is:
  1. Both host and guest set on the aux. card static IP 192.168.1.1, the camera has 192.168.1.9, masks are 255.255.255.0, and pinging the interface works on both host and guest.
  2. The aux NIC (Adapter 2 in VirtualBox "network" settings) is attached to "Internal network", the main card (adapter 1) is attached to NAT, and the guest too sees the world OK.
Is it possible that the guest looks for the camera through adapter 1, ending up on the WWW? How does the guest decide where to look for the camera (and BTW, how the host does it? IP similarity????)

How can I get my guest to see the camera(s)? Thanks for your help!
Last edited by socratis on 1. Oct 2019, 21:24, edited 1 time in total.
Reason: Marked as [Resolved].
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Networking with 2 NICs

Post by socratis »

You have a private network between you and your camera:
[quote]             Host NIC1 --> World
             Host NIC2 --> Camera[/quote]
What you need to do, is to get the CentOS to use "Bridged" mode over the 2nd NIC:
[quote]             Host NIC1 --> World
             Host NIC2 --> Camera
                    |
Guest --> Bridged --+[/quote]
Now, since there's no DHCP server or anything like that, you got to configure your CentOS guest manually. If the camera has an IP of 192.168.1.9, I'd use a 192.168.1.20 (or something not used) with a netmask of 255.255.255.0.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
acb764se
Posts: 3
Joined: 27. Sep 2019, 11:14

Re: Networking with 2 NICs

Post by acb764se »

Hi, and thanks for the answer!

In the meantime, after spending a whole weekend reading on the web about networks and stuff (much I did not know, and even more I had misunderstood) I was able to tackle the VirtualBox pages themselves(*). They are actually quite clear (after my reading, not before). They say:

The virtual machine receives its network address and configuration on the private network from a DHCP server integrated into Oracle VM VirtualBox. The IP address thus assigned to the virtual machine is usually on a completely different network than the host.

So I describe here for the record what i did, I am sure your solution would work too:

1) what i was trying to do with my cameras (read them via adapter 2) from the guest was quite analogous to what I _already_ did with my adapter 1, "getting to the guest what was beyond", so I had to configure _both_adapters_ as NAT in VirtualBox. As a beginning.

2) In the guest, I had to setup adapter 2 with "BOOTPROTO=dhcp", and _not_ assign a static 192.168.1.1 to it, as done in the host. I had a wrong idea that VirtualBox would somehow "lend" my adapter 2 to the guest, and the 2 IPs needed be the same in the host and the guest.

(a detail: the subnet created by VirtualBox, and governed by its own DHCP, is by default 10.0.etc.etc! If instead it had been 192.168.1.etc, then my "static IP" soluiion would have worked. Maybe!)

In any case, with the above choices I am able to work with my cameras in the guest, without losing connection with the web. :D :D :D

Thank you again for your help!




(*) https://www.virtualbox.org/manual/ch06.html
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Networking with 2 NICs

Post by socratis »

Glad I could help. Marking as [Resolved].
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Post Reply