virtual network with VirtualBox

marco.borsatino at libero.it marco.borsatino at libero.it
Sat Feb 6 10:31:32 UTC 2010


Hi. Sorry for my bad english.
I'm experimenting with a WinXP host and a virtual network using VirtualBox 3.1.2.56127; I'v created 3 virtual FreeBSD 8.0 PC.
The REAL PC is connected to the internet with an ADSL router; real router has a static IP 192.168.0.1; real PC NIC address is 192.168.0.2.
The first virtual PC works as a gateway between two nets with this configuration:
- 1 NIC in NAT -  DHCP - assigned addres 10.0.2.15 (the standard IP automatically assigned by VirtualBox 3.1.2)
- 1 NIC in Internal Network - IP 172.16.1.1/24
- 1 NIC in Internal Network - IP 172.16.2.1/24
This configuration lets me go on the internet and gives me access to the clients on the 2 nets.
Both virtual clients ping the others virtual PCs and both clients can access FTP area of the others virtual PCs.
>From the virtual gateway I can access the real host webServer (which is not important).
This is (part) of the gateway's /etc/rc.conf:
hostname="fbsdgw.marbosoft.org"
#this is my real ADSL router
defaultrouter="192.168.0.1"      
ifconfig_em0="DHCP"
ifconfig_em1="inet 172.16.1.1netmask 255.255.255.0"
ifconfig_em2="inet 172.16.2.1netmask 255.255.255.0"
gateway_enable="YES"
This is first "client"'s rc.conf:
hostname="fbsdnw11.marbosoft.org"
ifconfig_em0="inet 172.16.1.2netmask 255.255.255.0"
defaultrouter="fbsdgw"
My basic idea is to create a virtual network which uses real PC ad it's ADSL router (I'm working at home) only to allow my virtual gateway to access the internet (which is possible).
I'm not interested in comumunicating with real PC. I'd like to simulate a Small Office situation with a gateway, which should be the only one with an internet access (later I will, maybe, configure a firewall, a DNS server, a DHCP server, a NFS server, a Samba server ... and so on); the client virtual PCs should go on the internet through the gateway.
The problem is that virtual gateway accesses the internet, but le virtual client don't.
This is the output for netstat -r from virtual gateway

Routing tables
 Internet:
 Destination        Gateway            Flags    Refs      Use  Netif Expire
 default            10.0.2.2           UGS         1       61    em0
 10.0.2.0           link#1             U           0        0    em0
 10.0.2.15          link#1             UHS         0        0    lo0
 localhost          link#4             UH          0       20    lo0
 172.16.1.0         link#2             U           0        0    em1
 fbsdgw             link#2             UHS         0        0    lo0
 172.16.2.0         link#3             U           0        0    em2
 172.16.2.1         link#3             UHS         0        0    lo0

I think that  10.0.2.2 is the address of VirtualBox DHCP.

I've tried to configure em0 as a NIC with a bridge, but I've failed (probably for a fault of kowledge aboud bridges).
Thank you for any help.
Marco




More information about the freebsd-virtualization mailing list