Hi, I am trying to setup network to access the guest running on VirtualBox from internet. My current setup is as follows :- eth1 - Internet eth0 - LAN
I set up network to work properly on VirtualBox following the how-to on gentoo-wiki[1] and was able to access the guest from outside. But, since eth0 is bridged to br0, the other PC on the LAN isn't able to access the internet. I don't have any more network cards. What would be the best way to tackle this? Should I create eth1:0? Any other solutions?
[1] http://www.gentoo-wiki.com/HOWTO_VirtualBox
Mehul Ved wrote:
Hi, I am trying to setup network to access the guest running on VirtualBox from internet. My current setup is as follows :- eth1 - Internet eth0 - LAN
I set up network to work properly on VirtualBox following the how-to on gentoo-wiki[1] and was able to access the guest from outside. But, since eth0 is bridged to br0, the other PC on the LAN isn't able to access the internet. I don't have any more network cards. What would be the best way to tackle this? Should I create eth1:0? Any other solutions?
Which is the other PC on the LAN? Are you referring to the host OS? If your guest OS can access the net, your host using br0 will also do it as br0 is the common passage.
BTW, how did you link eth1 for Internet Connection Sharing? I have always wondered how ICS is done in GNU/Linux.
On Sun Jun 29, 2008 at 11:07:16PM +0530, Rony wrote:
Which is the other PC on the LAN?
Other PC is my sister's PC, which receives internet connection through my PC.
----->Cable Modem--->My Pc(eth1)--->My PC(eth0) ---->Sister's PC
Are you referring to the host OS?
Host OS is sabayon and guest OS is Arch, running within VirtualBox on Sabayon.
BTW, how did you link eth1 for Internet Connection Sharing? I have always wondered how ICS is done in GNU/Linux.
1) Set up my static IP on eth1 2) Gave an IP of 192.168.0.1 to eth0 and 192.168.0.2 to the PC on the LAN. 3) Made sure that the PC's on the LAN ping each other. 4) Set up Masqueading with IP Tables iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE I believe this can be done by GUI tools too but never looked into them. 5) Enable ip forwarding echo "1" > /proc/sys/net/ipv4/ip_forward This will allow packets to pass b/w interfaces.
Mehul Ved wrote:
On Sun Jun 29, 2008 at 11:07:16PM +0530, Rony wrote:
Which is the other PC on the LAN?
Other PC is my sister's PC, which receives internet connection through my PC.
----->Cable Modem--->My Pc(eth1)--->My PC(eth0) ---->Sister's PC
So now br0 is your interface that will talk to your LAN pcs. Are br0 and your LAN pcs on the same subnet?
Are you referring to the host OS?
Host OS is sabayon and guest OS is Arch, running within VirtualBox on Sabayon.
BTW, how did you link eth1 for Internet Connection Sharing? I have always wondered how ICS is done in GNU/Linux.
- Set up my static IP on eth1
- Gave an IP of 192.168.0.1 to eth0 and 192.168.0.2 to the PC on the LAN.
- Made sure that the PC's on the LAN ping each other.
- Set up Masqueading with IP Tables
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE I believe this can be done by GUI tools too but never looked into them.
Wow I didn't know it was that simple, only one line. Since the internet device and the LAN device is not mentioned in your command line, does the system assume internet device as the one which has default route and the LAN is the one that matches subnet?
- Enable ip forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward This will allow packets to pass b/w interfaces.
Just curious to know, after IP forwarding eth1 (internet) does your host OS have access to the net?
On Mon Jun 30, 2008 at 05:29:58PM +0530, Rony wrote:
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE I believe this can be done by GUI tools too but never looked into them.
Wow I didn't know it was that simple, only one line. Since the internet device and the LAN device is not mentioned in your command line, does the system assume internet device as the one which has default route and the LAN is the one that matches subnet?
You need not mention the device cos NAT handles all the request originating from 192.168.0.0/24 and Masquerade's them. Iptables will take care of the NAT tables. So, no need to specify interfaces.
- Enable ip forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward This will allow packets to pass b/w interfaces.
Just curious to know, after IP forwarding eth1 (internet) does your host OS have access to the net?
Yes, after the above steps, both the PC's are online. Only the requests originating from 192.168.0.0/24(in this case) are forwarded, not the others. But, this method has a drawback that the PC doing the forwarding needs to stay online when other PC's need to go online. So, this isn't the ideal setup in most cases but it will work fine in my case since my PC is on 24/7.