routing in virtualbox

Discussions about using Linux guests in VirtualBox.
gulamerah
Posts: 17
Joined: 7. Apr 2013, 15:57
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: various ubuntu varian

routing in virtualbox

Post by gulamerah »

Hi all,
i intend to configure linux as a router where network C in to simulate internet/intermediate router. i've set static routing from network A to network B and it works.
when i turn of network C i don't know why network A still can ping network B.
i want to know what's the appropriate interface to use when we want to connect 2 different network and why network A and B still connected?

my host: win7
guest (network A, network B, router C ) : debian wheezy
adapter : bridged networking

network A ---- router C --- network B

network A : 172.168.0.0
network B : 172.168.10.0
Last edited by gulamerah on 23. Nov 2013, 19:05, edited 1 time in total.
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: routing in virtualbox

Post by noteirak »

If you want network C to be a mandatory step between A and B, then don't put them on the same Bridged interface. You can use internal networks for this kind of setup, unless the host is the router, and then you could use two different host-only interfaces. Or you could even make this work with two bridged interfaces
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
gulamerah
Posts: 17
Joined: 7. Apr 2013, 15:57
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: various ubuntu varian

Re: routing in virtualbox

Post by gulamerah »

thanks for the reply,

yes i mean to make network C (router C) to be mandatory, so traffic from A pass through C to B.
but i'm not really understand about "make this work with two bridged interfaces".
does it mean to use 2 adapter in C ? one connect to A and the other connect to B?
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: routing in virtualbox

Post by noteirak »

gulamerah wrote:does it mean to use 2 adapter in C ? one connect to A and the other connect to B?
Yes, else they can reach each other directly. So you do need two interface so there is a gap, that your linux router will fill.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
gulamerah
Posts: 17
Joined: 7. Apr 2013, 15:57
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: various ubuntu varian

Re: routing in virtualbox

Post by gulamerah »

noteirak wrote:
gulamerah wrote:does it mean to use 2 adapter in C ? one connect to A and the other connect to B?
Yes, else they can reach each other directly. So you do need two interface so there is a gap, that your linux router will fill.
thanks, i did like you said.
but the problem is eventhough router C is turned off the network still connected. if we connect it as in real world (with cable) , the connection is supposed to loss right? so router C is just meaningless becausei can't simulate router C as an intermediate router.
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: routing in virtualbox

Post by noteirak »

IP configuration has to be right of course, but that is out of scope of this forum.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
gulamerah
Posts: 17
Joined: 7. Apr 2013, 15:57
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: various ubuntu varian

Re: routing in virtualbox

Post by gulamerah »

i'm confident my setting is right. the network connect succcessfully ( from A to B ) .
my question is , eventhough without the presence of router C the network connection between A and B is still exist.
i want to test a network where the topology has an intermediate network (router C) . in my condition, it seems virtualbox just forward the traffic.
what's the appropriate way to set that??? if it's in real world, i know it just need some routing and it's done.

sorry if my questions quite confusing as i'm new to virtualization things
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: routing in virtualbox

Post by noteirak »

If I wanted to do it in Virtualbox, I would use 3 VM and 2 internal networks as follow :

VM 1 ---- [ intnet "A" ] ---- VM 2 ---- [ intnet "B" ] ---- VM 3

VM 1 would have IP 10.0.0.1/24 on intnet A
VM 2 would have IP 10.0.0.2/24 on intnet A
VM 2 would have IP 10.0.1.2/24 on intnet B
VM 3 would have IP 10.0.1.1/24 on intnet B

VM 1 would have 10.0.0.2 as GW
VM 3 would have 10.0.1.2 as GW
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
gulamerah
Posts: 17
Joined: 7. Apr 2013, 15:57
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: various ubuntu varian

Re: routing in virtualbox

Post by gulamerah »

noteirak wrote:If I wanted to do it in Virtualbox, I would use 3 VM and 2 internal networks as follow :

VM 1 ---- [ intnet "A" ] ---- VM 2 ---- [ intnet "B" ] ---- VM 3

VM 1 would have IP 10.0.0.1/24 on intnet A
VM 2 would have IP 10.0.0.2/24 on intnet A
VM 2 would have IP 10.0.1.2/24 on intnet B
VM 3 would have IP 10.0.1.1/24 on intnet B

VM 1 would have 10.0.0.2 as GW
VM 3 would have 10.0.1.2 as GW
by 2 internet network, does it mean internal network with different name?
i'll give it a try and post the result later
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: routing in virtualbox

Post by noteirak »

gulamerah wrote:does it mean internal network with different name?
Yes it does
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
gulamerah
Posts: 17
Joined: 7. Apr 2013, 15:57
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: various ubuntu varian

Re: routing in virtualbox

Post by gulamerah »

the ping won't pass through to the other side.
VM 1 can ping VM 2 address (both)
VM 3 can ping VM 2 address (both)
but VM1 can't ping VM 3. it said unreachable

i set VM1 and VM3 interfaces 'internal networking" on adapter 2 on virtualbox. so the ip is on eth1.
the interfaces setting :
VM1 :
address 172.168.0.1
netmask 255.255.255.0

VM2 :
address 172.168.10.1
netmask 255.255.255.0

i use static routing
VM 1 : ip route add 172.168.0.0/24 dev eth1
VM 2 : ip route add 172.168.10.0/24 dev eth1
VM 3 no routing because it's directly connected to both.

what could be wrong in this setting??
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: routing in virtualbox

Post by noteirak »

gulamerah wrote:it said unreachable
That means your routing VM is not doing its job.

Please note that Routing & IP addressing are out of scope of this forum. We cover Virtualbox configuration, which is good in your case, but anything else is not part of the virtualization realm.
If you need support on this, you should bring this to a networking forum.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
gulamerah
Posts: 17
Joined: 7. Apr 2013, 15:57
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: various ubuntu varian

Re: routing in virtualbox

Post by gulamerah »

noteirak wrote:
gulamerah wrote:it said unreachable
That means your routing VM is not doing its job.

Please note that Routing & IP addressing are out of scope of this forum. We cover Virtualbox configuration, which is good in your case, but anything else is not part of the virtualization realm.
If you need support on this, you should bring this to a networking forum.
thanks for the help noteirak.
i think this is still in the scope of this forum because what confusing here is the usage of network adapter.
i'm sure the routing i mentioned before should be working in real world.
but why not in testing environment in virtualbox?
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: routing in virtualbox

Post by noteirak »

VM1 & VM3 should only be configured with one adapater, as internal network, on networks with different names.
VM2 should have at least 2 adapters, both as internal network, on the networks of VM1 & VM2.
VM2 can have extra adapters to have an access to the outside world.

This is the configuration you need to have in Virthalbox. The rest is up to you to configure properly on the IP side.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
gulamerah
Posts: 17
Joined: 7. Apr 2013, 15:57
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: various ubuntu varian

Re: routing in virtualbox

Post by gulamerah »

noteirak wrote:VM1 & VM3 should only be configured with one adapater, as internal network, on networks with different names.
VM2 should have at least 2 adapters, both as internal network, on the networks of VM1 & VM2.
VM2 can have extra adapters to have an access to the outside world.

This is the configuration you need to have in Virthalbox. The rest is up to you to configure properly on the IP side.
i tested it but with failure. have you tested it before??
i wonder maybe VM2 (the router) need something like vyatta????
Post Reply