Gateway VM

Discussions related to using VirtualBox on Linux hosts.
Post Reply
mashcaster
Posts: 39
Joined: 25. Dec 2008, 15:06

Gateway VM

Post by mashcaster »

Is it possible to setup a gateway VM in VirtualBox which will serve as a gateway server for all other VMs?
isama
Posts: 2
Joined: 10. Jan 2009, 15:54

Post by isama »

yes, it is possible, you just hook up all vm's to a internal network and one (the vm that will be the router) should be connected to your internal network and to your host (nat/host interface)

I am trying to figure out how to do this on my laptop :)
mashcaster
Posts: 39
Joined: 25. Dec 2008, 15:06

Post by mashcaster »

Please post back if you figure this out.
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Post by Sasquatch »

mashcaster wrote:Please post back if you figure this out.
Why not start yourself? If you know how to setup a gateway on a physical machine, it's not that hard to do it on a virtual one.

If you want it for your physical machines, you need HIF. Else internal networking is what you need. There are plenty of tutorials on the web which describe exactly what to do.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
mashcaster
Posts: 39
Joined: 25. Dec 2008, 15:06

Post by mashcaster »

Sasquatch wrote:
mashcaster wrote:Please post back if you figure this out.
Why not start yourself? If you know how to setup a gateway on a physical machine, it's not that hard to do it on a virtual one.

If you want it for your physical machines, you need HIF. Else internal networking is what you need. There are plenty of tutorials on the web which describe exactly what to do.
I have tried, but I can't get it to work.
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Post by Sasquatch »

Then you can at least post what you have tried.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
mashcaster
Posts: 39
Joined: 25. Dec 2008, 15:06

Post by mashcaster »

No prob

I installed debian etch in a VM with 2 NICs and changed the /etc/network/interfaces file to the following:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
address 192.168.1.1
netmask 255.255.255.0
eth0 for external connections
eth1 for internal connections

ifconfig returns this
eth0
Link encap:Ethernet Hwaddr 08:00:27:6A:B4:9A
inet addr:10.0.2.15 Bcast 10.0.2.255 Mask 255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets 2 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txquenelen:1000
RX bytes:1180 (1.1 KiB) TX bytes:684 (684.0 b)
Interrupt:11 Base address:0xc020

eth1
Link encap:Ethernet Hwaddr 08:00:27:34:99:41
inet addr:192.168.1.1 Bcast 192.168.1.255 Mask 255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets 0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txquenelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:11 Base address:0xc060

lo
Link encap:Local Loopback
inet addr127.0.0.1 Mask 255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets 0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txquenelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
cat /etc/resolv.conf returns:
nameserver 10.0.2.3
echo 1 > /proc/sys/net/ipv4/ip_forward

returns nothing

I can connect to the internet and I can ping to this server from another VM, but I cannot get the other VM to connect to the internet via this gateway VM.

What I am doing wrong?
mashcaster
Posts: 39
Joined: 25. Dec 2008, 15:06

Post by mashcaster »

Am I allowed to *BUMP* threads?
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Post by Sasquatch »

What are the network settings on the other VM? How are the two VMs connected with each other?
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
mashcaster
Posts: 39
Joined: 25. Dec 2008, 15:06

Post by mashcaster »

I have the gateway with 2 virtual nics

nic1 = eth0 = net
nic2 = eth1 = internal network
network name = intnet

the standard network pc vm has 1 nic

nic1 = eth0 = internal network
network name = intnet
mashcaster
Posts: 39
Joined: 25. Dec 2008, 15:06

Post by mashcaster »

Hesitant *bump*
chronoboy
Posts: 89
Joined: 21. Jul 2008, 07:11
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows
Location: Canada

Post by chronoboy »

On the Gateway VM there is more to do than just enabling the ip forwarding in the kernel. You will need to change some iptables. Read this very simple HowTo on TLDP.org for configuring your iptables on the Gateway VM:

http://www.tldp.org/HOWTO/Masquerading- ... index.html

Next, on your client VMs, the VMs which connect through the gateway, be sure to assign them each a static IP address and set their gateway IP to your Gateway VM's IP.

Some simple troubleshooting steps would be:
  • Can you ping the Gateway VM from the client?
    When you do a ping to an outside IP address rather than domain name, does it respond?
    What DNS servers are set on the client VMs?
    Have you attempted a traceroute to the Host?
Give these ideas a try. I know I was able to set-up a Gateway VM before. I used Debian as the Gateway, and had Windows clients connect through it.

Good luck.
mashcaster
Posts: 39
Joined: 25. Dec 2008, 15:06

Post by mashcaster »

Is there no "full" guide I can follow which tells me exactly how to set this up from start to finish. I have been trying to join many guides together to get this to work, and it seems I am missing bits out.

Please help.
Post Reply