Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a quick question. I have a bunch of VM's (VMWare Workstation) running on a Ubuntu server and have found that VMWare NAT (DHCP) service is unreliable and slow. I have to do use NAT instead of Bridging because I don't have enough static IP's for all the VMs.

Is it possible to setup the Linux Host (Ubuntu) to be a DHCP server but only for the local VM's?

The server has 2 NIC's so if I set eth0 to be a static IP, which connects to the outside work, and eth1 to listen for DHCP. Now, I am thinking if I don't want DHCP to broadcast I would just not connect a cable to eth1 and setup the VM's to connect to eth1 for the DHCP addresses. That way DHCP would not broadcast through my network but be listening on that interface.

Would that setup work?

EDIT

I have to use NAT or DHCP for the Guest VM's because the servers are in a data-center which does not offer DHCP and we don't have enough static IP's.

Thanks.

share|improve this question
    
Why can't you use bridging and let the VMs get their IP addresses from the DHCP server that supplies the rest of the network? –  John Gardeniers Oct 19 '11 at 21:06
    
Hey John, good question. I would do that but unfortunately the servers are in a data-center that does not offer DHCP. All the Host servers are connecting to the outside world via switch and static IP's. –  thiesdiggity Oct 19 '11 at 21:11
add comment

3 Answers

I'm sure you could use iptables to simply block any incoming DHCP requests from other machines but another option is to set up your DHCP server with just enough scope to supply your VMs, which should have reservations set for each. That way there will be no other addresses which can be handed out, even if the server did happen to receive a request.

share|improve this answer
    
That is a very interesting thought, thanks. However, would that cause a lot of un-needed/wanted network activity? Does the DHCP server broadcast or listen for DHCP packets? Wouldn't it just be better to not have a network cable connected to the DHCP interface? That way for every new VM we add we don't have to worry about the DHCP reservation piece. –  thiesdiggity Oct 19 '11 at 22:19
    
the network load induced by DHCP is neglectable. –  Antoine Benkemoun Oct 20 '11 at 19:36
    
@Antoine, I don't believe we're discussing network load. However, it would be most undesirable for other machines to receive addresses that are not valid for anything but those VMs, hence the need to prevent it. –  John Gardeniers Oct 20 '11 at 20:34
    
Oops sorry. My bad. Read through too quickly. –  Antoine Benkemoun Oct 20 '11 at 20:49
add comment

If you need just simple DHCP server, I would suggest using dnsmasq ( http://thekelleys.org.uk/dnsmasq/doc.html ). Its a powerful DNS forwarder but comes with integrated DHCP server. I am not sure if you can disable the DNS part completely but should it be problem you can configure it on a different port.

Configuring DHCP is one config option ( --dhcp-range ), and its the same with more advanced features.

share|improve this answer
add comment

In my experience using Virtualbox 4.x under a NAT situation, Virtualbox creates a virtual network inside the Host with its own IP range and Gateway (gateway being the host with a static ip) which the VMs live within. All external access is through the NAT'ing gateway on a virtual network adapter separate from any physical adapters and cables.

Therefore it is possible under Virtualbox, knowing the internal NAT network details, to disable the Virtualbox DHCP server and provide your own from within the virtual network.

DHCP will not traverse outside of a gateway unless it is specifically routed, for example through a VPN tunnel.

I cannot comment specifically on VMWare but I assume it works in a similar fashion.

Should this be successful you will need to ensure the VM providing DHCP gives the same network details as the host otherwise you will loose access to them via the network. However with my little experience of VMWare, you should have a console session available in order to configure the DHCP machine should you loose network access.

share|improve this answer
    
Sorry, I should state, this is not the host providing the DHCP, but an internal VM. However, Linux DHCP allows you to configure adapters to respond to, simply configure the service to respond on the virtual adapter only, this will stop DHCP to the outside. –  Drew Anderson Oct 20 '11 at 19:35
    
Thanks Drew! Do you (or anyone else) by chance know how to configure the Host DHCP to only respond to a virtual adapter (eth0:1)? I am assuming its the same way as a physical interface but one would reference etho:1 in the /etc/default/dhcp3-server file. Is that correct? –  thiesdiggity Oct 20 '11 at 22:53
    
I'm not entirely sure, you could look at this page help.ubuntu.com/community/dhcp3-server as it mentions using and selecting multiple interfaces. It could be as simple as providing a different range and subnet for your VMs (different from the outside world) and targeting those subnets in the dhcp3 file. There is also this page: linuxhomenetworking.com/wiki/index.php/… ... Good luck! –  Drew Anderson Oct 21 '11 at 7:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.