Recently I needed to implement functionality to operate a DHCP relay instead of
dnsmasq's DHCP server
on the virtual networks managed by libvirt.
The primary benefit of operating a relay is that the central DHCP and DNS servers for the
physical
network can manage IP address allocation and hostname resolution for the entire network
and, potentially, expose VMs via hostname and IP address
on the public network too, as well as being able to monitor VM instance creation for
resource planning.
I originally implemented this functionality on libvirt 0.9.8 included with Ubuntu 12.04 as
a hack to simply disable dnsmasq entirely and
use dhcp-helper[1] (the DHCP relay written by Simon Kelley, author of dnsmaq) although
I've constructed it so that another relay-agent could be used. After proving it works
well I've reworked the code
on the current libvirt master branch. If it's thought to be of use to the project
please let me know.
[1]
http://www.thekelleys.org.uk/dhcp-helper/
The following changes since commit 34f1a618a5c4507f27f3f467b723c9119c1db3c7:
conf: Avoid leaking of RNG device definition (2013-02-25 22:31:11 +0100)
are available in the git repository at:
git://github.com/iam-TJ/libvirt.git dhcp_relay_network
for you to fetch changes up to dfc0609403106712b205e60b53b29dc850cad68d:
docs: Describe the <dhcp> 'enable' and 'relay' attributes
(2013-02-27 20:35:06 +0000)
----------------------------------------------------------------
TJ (10):
conf: DHCP - add state for DHCP Relay and On/Off switch
conf: Network - add ability to read/write XML DHCP state
conf: Network - add pointers to enabled virNetworkIpDef DHCP settings
conf: Network - keep track of active DHCP stanza in virNetworkDef
network: Bridge - use IPv4 and IPv6 active DHCP stanza pointers
network: Bridge - Add support for a DHCP Relay Agent
network: Bridge - don't offer dnsmasq DHCP services when DHCP relay is enabled
configure: Add DHCPRELAY to the set of external program definitions
Add copyright attribution for DHCP relay functionality
docs: Describe the <dhcp> 'enable' and 'relay' attributes
configure.ac | 4 +++
docs/formatnetwork.html.in | 22 +++++++++++++-
src/conf/network_conf.c | 36 +++++++++++++++++++---
src/conf/network_conf.h | 7 +++++
src/network/bridge_driver.c | 215
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------
5 files changed, 229 insertions(+), 55 deletions(-)