OpenVZ Forum


Home » General » Support » *RESOLVED* Using dhcpd within VE without relay agent possible?
*RESOLVED* Using dhcpd within VE without relay agent possible? [message #14982] Mon, 16 July 2007 07:55 Go to next message
sebastian.esser is currently offline  sebastian.esser
Messages: 9
Registered: May 2007
Junior Member
Hi!

I'm trying to get dhcpd working within a VE.
After configuring an virtual ethernet device and setting up /etc/dhcpd.conf the server comes up without any error.

Unfortunately no client receives a ip address from the dhcp daemon. I suppose the only connection between the VE and the linked network is the hardware node's routing table, which doesn't forward broadcast messages.

Does anyone know if there is any way to get the dhcp daemon operate proberly within a VE without using an DHCP relay agent?

Thanks in advance

Sebastian

[Updated on: Fri, 20 July 2007 08:39] by Moderator

Report message to a moderator

Re: Using dhcpd within VE without relay agent possible? [message #14984 is a reply to message #14982] Mon, 16 July 2007 08:20 Go to previous messageGo to next message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
Hello,

In your scenario you should create a bridge between your physical devices and veths on HN.

Some information about bridges is here: http://wiki.openvz.org/Virtual_Ethernet_device#Create_bridge _device

When you'll set a DHCP-server inside the VE up, it'll be great if you'll write an article about it at http://wiki.openvz.org Wink

Thank you!
Vasily
Re: Using dhcpd within VE without relay agent possible? [message #14986 is a reply to message #14984] Mon, 16 July 2007 08:35 Go to previous messageGo to next message
sebastian.esser is currently offline  sebastian.esser
Messages: 9
Registered: May 2007
Junior Member
Hello Vasily,

thank you for the quick answer.
I hoped for a way without actions on the HN's side Sad

Sure, as soon as i've making up an operating dhcpd wihtin my VE, i'll write down a short procedure instruction Smile

Bye
Sebastian
Re: Using dhcpd within VE without relay agent possible? [message #15046 is a reply to message #14986] Tue, 17 July 2007 14:37 Go to previous messageGo to next message
sebastian.esser is currently offline  sebastian.esser
Messages: 9
Registered: May 2007
Junior Member
I decided against the ethernet bridge. I need a more transparent way, which implements an easy mechanismn to work with offline migrations. Thus I choose the use of a DHCP Relay Agent.

Here's my workaround:
Every HN which shall be able to shelter a VE with a running DHCP daemon inside has to be equipped with a proper DHCP Relay Agent.
On CentOS 4 these two services (dhcpd and dhcrelay) are provided through the RPM package dhcp

This scenario allows only one VE with an DHCP daemon per HN and only one VE with DHCP daemon per group of HNs. The latter constraint could be removed. E.g. by modifying the "mount" Action Script /etc/vz/conf/101.mount in a manner that the Relay Agent's configuration will be overwritten. In that case you'll have to ensure there's no other VE with a running DHCP daemon on the HN.

First I've set up an applicable VE with the DHCP daemon dhcpd...
vzctl create 101 \
  --ostemplate=centos-4-i386-minimal \
  --hostname=ve001.foo.bar

vzctl set 101 \
  --name=ve001 \
  --netif_add eth0 \
  --nameserver=192.168.1.1 \
  --searchdomain=foo.bar \
  --save

vzyum 101 install dhcp
vzctl exec 101 chkconfig --level 3 dhcpd on
vzctl exec 101 service dhcpd start


Quote:

To get rid of the error message "/etc/init.d/dhcpd: line 17: [: =: unary operator expected" while starting/stopping the daemon apply the following patch within the VE:
-
-- BEGIN /etc/init.d/dhcpd.patch ---
*** /etc/init.d/dhcpd.ORIGIN        2007-07-17 14:33:06.000000000 +0200
--- /etc/init.d/dhcpd       2007-07-17 14:33:36.000000000 +0200
***************
*** 15,19 ****
  
  # Check that networking is up.
! [ ${NETWORKING} = "no" ] && exit 0
  
  [ -f /usr/sbin/dhcpd ] || exit 0
--- 15,19 ----
  
  # Check that networking is up.
! [ "${NETWORKING}" = "no" ] && exit 0
  
  [ -f /usr/sbin/dhcpd ] || exit 0
--- END /etc/init.d/dhcpd.patch ---


After reading the advices about virtual ethernet devices on http://wiki.openvz.org/Veth (especially
http://wiki.openvz.org/Veth#Making_a_veth-device_persistent and http://wiki.openvz.org/Veth#Simple_configuration_with_virtua l_ethernet_device) I've modified the VE's main configuration file,...
--- SNIP /etc/vz/conf/101.conf ---
CONFIG_CUSTOMIZED="yes"
VETH_IP_ADDRESS="192.168.1.2"
--- END /etc/vz/conf/101.conf ---

created a "start" Action Script...
--- BEGIN /etc/vz/conf/101.start ---
#!/bin/bash

#
# OpenVZ Action Script 101.start
#

# Setup network devices
/sbin/ifconfig eth0 0
/sbin/ip addr add 192.168.1.2 dev eth0
/sbin/ip route add default dev eth0
--- END /etc/vz/conf/101.start ---

and created an "mount" Action Script...
--- BEGIN /etc/vz/conf/101.mount ---
#!/bin/bash

#
# OpenVZ Action Script 101.mount
#

[ -f /etc/sysconfig/vz ] || exit 1
[ -f $VE_CONFFILE ] || exit 1

. /etc/sysconfig/vz
. $VE_CONFFILE

/bin/echo 1 > /proc/sys/net/ipv4/conf/eth0/forwarding
/bin/echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp

# Define / get checksums for comparing
declare DHCRELAY_MD5SUM_PATCHED="1d50d252d6501fede6aa2dcca3bc1138  /etc/sysconfig/dhcrelay"
declare DHCRELAY_MD5SUM_CURRENT=$(md5sum /etc/sysconfig/dhcrelay)

# Apply the patch if dhcrelay isn't already configured.
# If the patching fails (maybe modified otherwise) exit with
# return code 127.
if [[ "$DHCRELAY_MD5SUM_CURRENT" != "$DHCRELAY_MD5SUM_PATCHED" ]]
then
  (patch -Np0 || exit 127) <<- \
	EOF
	*** /etc/sysconfig/dhcrelay.ORIGIN	2007-07-19 12:01:16.000000000 +0200
	--- /etc/sysconfig/dhcrelay	2007-07-19 12:02:10.000000000 +0200
	***************
	*** 1,3 ****
	  # Command line options here
	! INTERFACES=""
	! DHCPSERVERS=""
	--- 1,3 ----
	  # Command line options here
	! INTERFACES="eth0 veth${VEID}.0"
	! DHCPSERVERS="$HOSTNAME"
	EOF
fi

# Start the DHCP Relay Agent on the HN after waiting 5 seconds
# to ensure the VE has been mounted and is running.
(sleep 5; echo; service dhcrelay start) &
--- END /etc/vz/conf/101.mount ---

The "mount" Action Script prepares the virtual ethernet device and establishes (if necessary) the prober configuration for the DHCP Relay Agent. The virtual ethernet device has to exist before the Relay Agent starts. That's why the start of the Relay Agent will be put into the background with a delay.

--- BEGIN /etc/vz/conf/101.umount ---
#!/bin/bash

#
# OpenVZ Action Script 101.umount
#

[ -f /etc/sysconfig/vz ] || exit 1
[ -f $VE_CONFFILE ] || exit 1

. /etc/sysconfig/vz
. $VE_CONFFILE

service dhcrelay stop || :
--- END /etc/vz/conf/101.umount ---

Now it's possible to migrate this VE in offline mode:
vzmigrate -r yes target.foo.bar 101
Re: Using dhcpd within VE without relay agent possible? [message #15153 is a reply to message #15046] Fri, 20 July 2007 08:39 Go to previous messageGo to next message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
Hello,

Thank you for this information! It is very useful and can help a lot of users.

Probably, I can ask you to create an article at http://wiki.openvz.org based on your post? Smile

Thank you very much,
Vasily
Re: Using dhcpd within VE without relay agent possible? [message #15251 is a reply to message #15153] Tue, 24 July 2007 12:20 Go to previous message
sebastian.esser is currently offline  sebastian.esser
Messages: 9
Registered: May 2007
Junior Member
Hello Vasily,

I'll publish my experiences about setup a working dhcp daemon whithin a VE to the Wiki as soon as my current projects give me a little more time.

I'll promise to keep it in mind : )

Bye
Sebastian
Previous Topic: smbfs/ cifs inside VE
Next Topic: *RESOLVED* Accessing physical serial port from within a VE
Goto Forum:
  


Current Time: Sun Nov 10 12:37:25 GMT 2024

Total time taken to generate the page: 0.03484 seconds