Install router and DHCP on VM

This is for discussing general topics about how to use VirtualBox.
Post Reply
satimis
Posts: 513
Joined: 12. Jun 2007, 03:41

Install router and DHCP on VM

Post by satimis »

Hi all,

Host - Ubuntu 12.04
VM - Ubuntu 12.04
Virtualizer - Oracle VirtualBox

I'm prepared installing router and DHCP server. Can I install them on a VM instead on the Host? I expect keeping the Host clean only for running Oracle VirtualBox.

Tutorial:-

Router
https://help.ubuntu.com/community/Router


DHCP server:
Dynamic Host Configuration Protocol (DHCP)
https://help.ubuntu.com/12.04/serverguide/dhcp.html

Setting up a DHCP server on Ubuntu 12.04 (Precise Pangolin) server
http://lani78.com/2012/07/23/setting-up ... in-server/

Please advise. Thanks

Rgds
satimis
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Install router and DHCP on VM

Post by BillG »

Yes you can, as long as you make sure that the NICs in the vm are connected to the correct networks.

What network will the DHCP server operate in and what networks are you routing between?
Bill
satimis
Posts: 513
Joined: 12. Jun 2007, 03:41

Re: Install router and DHCP on VM

Post by satimis »

BillG wrote:Yes you can, as long as you make sure that the NICs in the vm are connected to the correct networks.
Hi,

Thanks for your advice.

Performed following test :
(Documentation referred
Router Guide
Setting up an Ubuntu Wired/Wireless Router
https://help.ubuntu.com/community/Router
)

VM - Ubuntu 12.04

$ cat /etc/network/interfaces

Code: Select all

auto lo
iface lo inet loopback

auto eth1
iface eth1 inet static
    address 2xx.2xx.2xx.1xx
    netmask 255.255.255.0
    gateway 2xx.2xx.2xx.1xx

auto eth2
iface eth2 inet static
    address 192.168.0.1
    network 192.168.0.0
    netmask 255.255.255.0
    broadcast 192.168.0.255

auto br0
iface br0 inet static
    address 192.168.0.1
    network 192.168.0.0
    netmask 255.255.255.0
    broadcast 192.168.0.255
Two NIC detected as eth1 and eth2

Host - Debian 7.3
$ cat /etc/network/interfaces

Code: Select all

auto lo
iface lo inet loopback
Settings -> Network
Adapter 1
Attached to: NAT

Adapter 2
Attached to: Internal Network

Pulled out the cable connecting Cable Modem to Router and connected it to "network card 1". Unable to connect ISP server.

Also tried "network card 2", with same result.
What network will the DHCP server operate in and what networks are you routing between?
The VMs are mirror of the websites hosted on Godaddy. They are not up round the clock. I have only one static IP. The domain on Godaddy will point to the Static IP when the VM is up running. I have to foward all ports to the VM so that users can browse it.

satimis
Last edited by satimis on 24. Feb 2014, 13:20, edited 2 times in total.
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Install router and DHCP on VM

Post by BillG »

There is no point in setting a public IP on a NIC in a vm if it is set to NAT. You need to find some way to get the vm to bridge directly to the public network. I have never done that when the NIC needs to connect directly to the Internet through a modem, so I don't know if it is possible or not.

If it is possible, you would need to bridge the NIC in the vm to the physical NIC, then connect the vm directly to the Internet through the modem. The vm would get a public IP directly from the ISP (instead of the host making the Internet connection).
Bill
satimis
Posts: 513
Joined: 12. Jun 2007, 03:41

Re: Install router and DHCP on VM

Post by satimis »

BillG wrote:There is no point in setting a public IP on a NIC in a vm if it is set to NAT. You need to find some way to get the vm to bridge directly to the public network. I have never done that when the NIC needs to connect directly to the Internet through a modem, so I don't know if it is possible or not.
I have tried selecting;
Adapter 1
Attached to: Bridged Adapter
Name: eth0
(Here I'm confused. The 1st NIC is named eth0 and 2nd NIC eth1
On VM they are named eth1 and eth2 respectively)

Pulled the WAN to NIC socket connection to Internet was lost on both Host and VM.
If it is possible, you would need to bridge the NIC in the vm to the physical NIC, then connect the vm directly to the Internet through the modem. The vm would get a public IP directly from the ISP (instead of the host making the Internet connection).
I have no clue how to do it. Any advice? Thanks

satimis
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Install router and DHCP on VM

Post by BillG »

I think that you are out of your depth with the routing without the added problems of virtual networks. I would use the host directly unless you can find someone local to "hold your hand".
Bill
satimis
Posts: 513
Joined: 12. Jun 2007, 03:41

Re: Install router and DHCP on VM

Post by satimis »

BillG wrote: - snip -
I would use the host directly unless you can find someone local to "hold your hand".
It works on PC. However I expect keeping the Host clean only for running VirtualBox. Otherwise I would purchase a router as a folk on Ubuntu forum suggested before, saving my headache.

satimis
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Install router and DHCP on VM

Post by BillG »

That would certainly be a good move. Working on a local LAN is far easier than using a direct connection via modem from the host.
Bill
satimis
Posts: 513
Joined: 12. Jun 2007, 03:41

Re: Install router and DHCP on VM

Post by satimis »

Hi,

I found following documents which are quite interesting to me:

1)
Notes/Virtual Linux Router with VirtualBox
http://wiki.smalleycreative.com/Notes/V ... VirtualBox

2)
Tutorials:Using Linux Virtual Machine instead of router for VPN
http://wiki.hidemyass.com/Tutorials:Usi ... er_for_VPN

3)
Creating a Virtual Network of Linux Guests using VirtualBox
http://sandilands.info/sgordon/creating ... virtualbox

I haven't gone through all of them deeply. On 3) it seems needing 3 NICs?

satimis
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Install router and DHCP on VM

Post by BillG »

If you really want to run a vm as a router under VirtualBox,have a look at the pfSense appliance. pfsense.com
Bill
Post Reply