Difference between revisions of "Vnx-plugin-dhcp"

From VNX
Jump to: navigation, search
(DHCP Plugin Example Scenario)
(DHCP Plugin Example Scenario)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{Title|DHCP Plugin}}
 
{{Title|DHCP Plugin}}
 
...to be completed...
 
 
<!--
 
http://www.techienote.com/2010/11/ddns-dhcp-server-on-ubuntu.html
 
-->
 
  
 
<big>
 
<big>
Line 30: Line 24:
 
<pre>
 
<pre>
 
...
 
...
CHANGE!!
+
<vm name="r1" type="dhcp3-isc">
<vm name="r1" type="quagga" subtype="lib-install">
+
    <server>
  <hostname>r1</hostname>
+
      <subnet>
  <password>xxxx</password>
+
        <network>10.0.1.0/24</network>
  <network area="0.0.0.0">10.0.0.0/16</network>
+
        <range>
  <passive_if>eth1</passive_if>  
+
          <first>10.0.1.10</first>
  <binaries>
+
          <last>10.0.1.20</last>
    <zebra>/usr/lib/quagga/zebra</zebra>
+
        </range>
    <ospfd>/usr/lib/quagga/ospfd</ospfd>
+
        <router>10.0.1.1</router>
  </binaries>
+
        <dns>10.0.1.2</dns>
</vm>
+
        <domain>dominio1.org</domain>
 +
      </subnet>
 +
    </server>
 +
  </vm>
 
...
 
...
 
</pre>
 
</pre>
Line 48: Line 45:
 
== DHCP Plugin Example Scenario ==
 
== DHCP Plugin Example Scenario ==
  
DHCP Plugin example is a simple scenario made of two routers (r1 and r2) and two hosts (h1 and h2) designed to show the capabilities of the plugin. r1 runs a DHCP server; r2 runs a DHCP relay and h1 and h2 autoconfigure themselves using DHCP. The example is included in VNX distribution.
+
DHCP Plugin example is a simple scenario made of two routers (r1 and r2) and two hosts (h1 and h2) designed to show the capabilities of the plugin. r1 runs a DHCP server; r2 runs a DHCP relay that retransmits requests to r1; and h1 and h2 autoconfigure themselves from r1 and r2 using DHCP. This example is included in VNX distribution.
  
 
<center>
 
<center>
Line 57: Line 54:
 
To start the scenario, just type:
 
To start the scenario, just type:
 
  cd /usr/share/vnx/plugins/examples
 
  cd /usr/share/vnx/plugins/examples
  vnx -f example_ospf-plugin.xml -v -t
+
  vnx -f example_dhcp-plugin.xml -v -t
Once started, you can check the conectivity among h1 and h2 hosts:
+
 
 +
Note: in case you get an error related with the existance of '/root/.ssh/id_dsa.pub' file, either create that file executing "ssh-keygen -t dsa" or delete or modify the <ssh_key> tag on the scenario.
 +
 
 +
Once started, you can check that the hosts have been configured:
 
<pre>
 
<pre>
root@h1:~# traceroute -n 10.0.2.2
+
root@h1:~# ifconfig eth1
traceroute to 10.0.2.2 (10.0.2.2), 30 hops max, 60 byte packets
+
eth1      Link encap:Ethernet direcciónHW 02:fd:00:04:03:01  
  1 10.0.1.1  2.520 ms  2.388 ms 2.297 ms
+
          Direc. inet:10.0.1.10 Difus.:10.0.1.255 Másc:255.255.255.0
10.0.0.2 2.214 ms  2.133 ms  2.059 ms
+
          Dirección inet6: fe80::fd:ff:fe04:301/64 Alcance:Enlace
3  10.0.2.2  1.939 ms  1.502 ms  0.779 ms
+
          ....
 
</pre>
 
</pre>
Or check that the quagga ospf daemon is running on r1 and r2 and the neighbourhood between them is stablished:
+
And the daemons are running over r1 and r2:
 
<pre>
 
<pre>
root@r1:~# vtysh
+
root@r1:~# ps uax | grep dhcpd
Hello, this is Quagga (version 0.99.17).
+
dhcpd      841  0.0  0.9  4668  2320 ?        Ss  23:28  0:00 /usr/sbin/dhcp -q -pf /var/run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf
Copyright 1996-2005 Kunihiro Ishiguro, et al.
 
  
r1# sh ip ospf  neighbor  
+
r2:~# ps uax | grep dhcrelay
    Neighbor ID Pri State          Dead Time Address        Interface            RXmtL RqstL DBsmL
+
root      2110 0.0 0.7  3160  456 ?        Ss  23:27  0:00 /usr/sbin/dhcrelay3 -q 10.0.0.1
10.0.0.2          1 Full/DR          37.119s 10.0.0.2        eth2:10.0.0.1           0    0    0
 
r1#
 
 
</pre>
 
</pre>
  
 
To know the scenario commands made available to the user by the plugin, you can use the "exe-info" mode of VNX:
 
To know the scenario commands made available to the user by the plugin, you can use the "exe-info" mode of VNX:
 
<pre>
 
<pre>
# vnx -f example_ospf-plugin.xml --exe-info
+
 
 +
# vnx -f example_dhcp-plugin.xml --exe-info
 
----------------------------------------------------------------------------------
 
----------------------------------------------------------------------------------
 
Virtual Networks over LinuX (VNX) -- http://www.dit.upm.es/vnx - vnx@dit.upm.es
 
Virtual Networks over LinuX (VNX) -- http://www.dit.upm.es/vnx - vnx@dit.upm.es
Version: 2.0b.893 (built on 11/09/2011_03:14)
+
Version: 2.0b.894 (built on 11/09/2011_12:20)
 
----------------------------------------------------------------------------------
 
----------------------------------------------------------------------------------
 
Using configuration file: /etc/vnx.conf
 
Using configuration file: /etc/vnx.conf
Line 92: Line 90:
 
VNX exe-info mode:
 
VNX exe-info mode:
  
User-defined command sequences for scenario 'example_ospf-plugin'
+
User-defined command sequences for scenario 'example_dhcp_plugin'
 
----------------------------------------------------------------------------------
 
----------------------------------------------------------------------------------
 
  stop-www                Stop apache2 web server
 
  stop-www                Stop apache2 web server
 
  start-www                Start apache2 web server
 
  start-www                Start apache2 web server
  
Plugin 'ospf' command sequences for scenario 'example_ospf-plugin'
+
Plugin 'dhcp' command sequences for scenario 'example_dhcp_plugin'
 
----------------------------------------------------------------------------------
 
----------------------------------------------------------------------------------
  restart                  Restarts OSPF daemons
+
dhcp-server-stop        Stops DHCP servers
  stop                    Stops OSPF daemons
+
on_shutdown              Stops all DHCP daemons
  ospf-redoconf            Plugin specific synonym of 'redoconf'
+
dhcp-relay-start        Starts DHCP relays
  ospf-restart             Plugin specific synonym of 'restart'
+
dhcp-stop                Synonym of stop
  ospf-stop                Plugin specific synonym of 'stop'
+
dhcp-start              Synonym of start
on_shutdown              Stops OSPF daemons (executed before shutdown)
+
dhcp-client-restart      Releases client IP configurations and rexecutes DHCP clients
  on_boot                  Creates OSPF config files and starts daemons (executed after startup)
+
dhcp-relay-stop          Stops DHCP relays
  ospf-on_boot            Plugin specific synonym of 'on_boot'
+
  restart                  Restarts all DHCP daemons and clients
  redoconf                Recreate the OSPF config files
+
dhcp-client-start        Executes DHCP clients
  ospf-start              Plugin specific synonym of 'start'
+
dhcp-relay-force-reload  Restarts DHCP relays using 'force-reload'
  start                    Starts OSPF daemons
+
  stop                    Stops all DHCP daemons and releases client configurations
 +
  dhcp-server-force-reload Restarts DHCP servers using 'force-reload'
 +
  dhcp-relay-restart       Restarts DHCP relays
 +
  dhcp-restart            Synonym of restart
 +
  on_boot                  Creates DHCP config files and starts services
 +
dhcp-server-start        Starts DHCP servers
 +
  dhcp-client-stop        Releases client IP configurations
 +
  redoconf                Creates DHCP config files
 +
  dhcp-server-restart      Restarts DHCP servers
 +
  start                    Starts all DHCP daemons and clients
 
----------------------------------------------------------------------------------
 
----------------------------------------------------------------------------------
 
Total time elapsed: 0 seconds
 
Total time elapsed: 0 seconds
 
</pre>
 
</pre>
  
For example, you can stop the daemon in r1 with:
+
For example, you can edit example_dhcp-plugin-conf.xml to change the range of addresses asigned to subnet 10.0.1.0/24. Just edit the value of <first> tag and change it to 10.0.1.15 and reload the configuration file with:
vnx -f example_ospf-plugin.xml -v -x ospf-stop -M r1
+
  vnx -f example_dhcp-plugin.xml -v -x redoconf -M r1
and edit example_ospf-plugin-conf.xml to make any change to r1 OSPF configuration (for example, change the hostname ro router1) and reload the configuration file with:
+
After 'redoconf' command you can check the changes have been made to configuration files by accessing r1 and having a look at /etc/dhcp/dhcp.conf file.
  vnx -f example_ospf-plugin.xml -v -x redoconf -M r1
 
After 'redoconf' command you can check the changes have been made to configuration files by accessing r1 and having a look at /etc/quagga/zebra.conf and /etc/quagga/ospfd.conf files).
 
  
Finally, you can start the daemon with the new configuration with:
+
After that, you can restart the DHCP server in r1 with:
  vnx -f example_ospf-plugin.xml -v -x ospf-start -M r1
+
vnx -f example_dhcp-plugin.xml -v -x dhcp-server-restart -M r1
 +
An renew the address of h1 with:
 +
  vnx -f example_dhcp-plugin.xml -vvv -x dhcp-client-restart -M h1
  
Note: typically plugins provide the same basic 'start|stop|restart' commands with two sequence names: general (i.e. start) and specific (i.e. ospf-start). Both execute the same actions, but the specific one is used when you want to execute commands only over a specific plugin. Selecting the general one will tipically execute commands over all plugings and some user-defined commands.
+
Note: typically plugins provide the same basic 'start|stop|restart' commands with two sequence names: general (i.e. start) and specific (i.e. dhcp-start). Both execute the same actions, but the specific one is used when you want to execute commands only over a specific plugin. Selecting the general one will tipically execute commands over all plugings and some user-defined commands.
  
 
=== Scenario Specification ===
 
=== Scenario Specification ===
Line 129: Line 136:
 
<pre>
 
<pre>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
 +
 
<!--
 
<!--
 
~~~~~~~~~~~~~~~~~~~~
 
~~~~~~~~~~~~~~~~~~~~
Line 134: Line 142:
 
~~~~~~~~~~~~~~~~~~~~
 
~~~~~~~~~~~~~~~~~~~~
  
Name:        example_ospf-plugin
+
Name:        example_dhcp-plugin
Description: Example scenario to show the use of ospf plugin. It is made of two
+
Description: Simple example that shows dhcp plugin capabilities.
            routers: r1 (ubuntu) and r2(uml) and two hosts: h1 (ubuntu) and h2 (uml). 
 
  
 
This file is part of the Virtual Networks over LinuX (VNX) Project distribution.  
 
This file is part of the Virtual Networks over LinuX (VNX) Project distribution.  
Line 145: Line 152:
 
SPAIN
 
SPAIN
 
-->
 
-->
 +
 
<vnx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 
<vnx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 
   xsi:noNamespaceSchemaLocation="/usr/share/xml/vnx/vnx-2.00.xsd">
 
   xsi:noNamespaceSchemaLocation="/usr/share/xml/vnx/vnx-2.00.xsd">
 
   <global>
 
   <global>
 
     <version>2.0</version>
 
     <version>2.0</version>
     <scenario_name>example_ospf-plugin</scenario_name>
+
     <scenario_name>example_dhcp_plugin</scenario_name>
 
     <ssh_key>~/.ssh/id_dsa.pub</ssh_key>
 
     <ssh_key>~/.ssh/id_dsa.pub</ssh_key>
 
     <automac offset="4"/>
 
     <automac offset="4"/>
Line 158: Line 166:
 
     <vm_defaults>
 
     <vm_defaults>
 
         <console id="0" display="no"/>
 
         <console id="0" display="no"/>
<console id="1" display="yes"/>
+
        <console id="1" display="yes"/>
 +
        <exec_mode type="uml">mconsole</exec_mode>
 +
        <exec_mode type="libvirt" subtype="kvm">cdrom</exec_mode>
 +
        <exec_mode type="libvirt" subtype="kvm" os="windows">cdrom</exec_mode>
 +
        <exec_mode type="libvirt" subtype="kvm" os="olive">sdisk</exec_mode>
 
     </vm_defaults>
 
     </vm_defaults>
     <extension plugin="ospf" conf="example_ospf-plugin-conf.xml" />
+
     <extension plugin="dhcp" conf="example_dhcp-plugin-conf.xml" />
 +
   
 +
    <help>
 +
        <exec_help seq='start-www'>Start apache2 web server</exec_help>
 +
        <exec_help seq='stop-www'>Stop apache2 web server</exec_help>
 +
    </help>
 +
 
 
   </global>
 
   </global>
 
      
 
      
Line 179: Line 197:
 
       <ipv6>2001:db8:12::1/64</ipv6>
 
       <ipv6>2001:db8:12::1/64</ipv6>
 
     </if>
 
     </if>
 +
    <route type="ipv4" gw="10.0.0.2">10.0.2.0/24</route>   
 
     <forwarding type="ip" />
 
     <forwarding type="ip" />
 +
    <filetree seq="start-www" root="/var/www/" user="www-data" group="www-data" perms="644">conf/txtfile</filetree>
 +
    <exec seq="start-www" type="verbatim" ostype="system">service apache2 start</exec>
 +
    <exec seq="stop-www" type="verbatim"  ostype="system">service apache2 stop</exec>   
 
   </vm>
 
   </vm>
  
Line 194: Line 216:
 
       <ipv6>2001:db8:12::2/64</ipv6>
 
       <ipv6>2001:db8:12::2/64</ipv6>
 
     </if>
 
     </if>
 +
    <route type="ipv4" gw="10.0.0.1">10.0.1.0/24</route>   
 
     <forwarding type="ip" />
 
     <forwarding type="ip" />
 
   </vm>
 
   </vm>
Line 201: Line 224:
 
     <mem>256M</mem>
 
     <mem>256M</mem>
 
     <if id="1" net="lan1">
 
     <if id="1" net="lan1">
       <ipv4>10.0.1.2/24</ipv4>
+
       <!--ipv4>10.0.1.2/24</ipv4>
       <ipv6>2001:db8:1::2/64</ipv6>
+
       <ipv6>2001:db8:1::2/64</ipv6-->
 
     </if>
 
     </if>
     <route type="ipv4" gw="10.0.1.1">default</route>     
+
     <!--route type="ipv4" gw="10.0.1.1">default</route>     
     <route type="ipv6" gw="2001:db8:1::1">default</route>       
+
     <route type="ipv6" gw="2001:db8:1::1">default</route-->       
 
   </vm>
 
   </vm>
  
Line 213: Line 236:
 
     <kernel>/usr/share/vnx/kernels/linux</kernel>
 
     <kernel>/usr/share/vnx/kernels/linux</kernel>
 
     <if id="1" net="lan2">
 
     <if id="1" net="lan2">
       <ipv4>10.0.2.2/24</ipv4>
+
       <!--ipv4>10.0.2.2/24</ipv4>
       <ipv6>2001:db8:2::2/64</ipv6>
+
       <ipv6>2001:db8:2::2/64</ipv6-->
 
     </if>
 
     </if>
     <route type="ipv4" gw="10.0.2.1">default</route>     
+
     <!--route type="ipv4" gw="10.0.2.1">default</route>     
     <route type="ipv6" gw="2001:db8:2::1">default</route>       
+
     <route type="ipv6" gw="2001:db8:2::1">default</route-->       
 
   </vm>
 
   </vm>
 
    
 
    
Line 236: Line 259:
  
 
<pre>
 
<pre>
<ospf_conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
<dhcp_conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="/usr/share/xml/vnx/ospf.xsd">
+
   xsi:noNamespaceSchemaLocation="/usr/share/xml/vnx/dhcp.xsd">
  
  <vm name="r1" type="quagga" subtype="lib-install">
+
  <vm name="r1" type="dhcp3-isc">
       <hostname>r1</hostname>
+
    <server>
      <password>xxxx</password>
+
       <subnet>
       <network area="0.0.0.0">10.0.0.0/16</network>
+
        <network>10.0.1.0/24</network>
       <passive_if>eth1</passive_if>  
+
        <range>
      <binaries>
+
          <first>10.0.1.10</first>
        <zebra>/usr/lib/quagga/zebra</zebra>
+
          <last>10.0.1.20</last>
        <ospfd>/usr/lib/quagga/ospfd</ospfd>
+
        </range>
      </binaries>
+
        <router>10.0.1.1</router>
  </vm>
+
        <dns>10.0.1.2</dns>
 +
        <domain>dominio1.org</domain>
 +
       </subnet>
 +
      <subnet>
 +
        <network>10.0.2.0/24</network>
 +
        <range>
 +
          <first>10.0.2.10</first>
 +
          <last>10.0.2.20</last>
 +
        </range>
 +
        <router>10.0.2.1</router>
 +
        <host name="Unicum" mac="AA:BB:CC:DD:EE:FF" ip="10.0.2.28"/>
 +
      </subnet>
 +
      <subnet>
 +
        <network>10.0.0.0/30</network>
 +
       </subnet>
 +
    </server>
 +
  </vm>
 +
 
 +
  <vm name="h1" type="dhcp3">
 +
    <client>
 +
      <if>eth1</if>
 +
    </client>
 +
  </vm>
 +
 
 +
  <vm name="r2" type="dhcp3">
 +
    <relay>
 +
      <toserver>10.0.0.1</toserver>
 +
    </relay>
 +
  </vm>
 +
 
 +
  <vm name="h2" type="dhcp3">
 +
    <client>
 +
      <if>eth1</if>
 +
    </client>
 +
  </vm>
  
  <vm name="r2" type="quagga" subtype="lib-install">
+
</dhcp_conf>
      <hostname>r2</hostname>
 
      <password>xxxx</password>
 
      <network area="0.0.0.0">10.0.0.0/16</network>
 
      <passive_if>eth1</passive_if>
 
  </vm>
 
</ospf_conf>
 
 
</pre>  
 
</pre>  
  

Latest revision as of 10:16, 12 September 2011

DHCP Plugin

Authors:
David Fernández (david at dit.upm.es)
Jorge Somavilla (somavilla at dit.upm.es)
Miguel Ferrer (mferrer at dit.upm.es)
Francisco Jose Martin (fjmarin at dit.upm.es)
Fermín Galán (galan at dit.upm.es)
version 2.0, September 11th, 2011

Introduction

DHCP plugin is an example VNX extension plugin designed to facilitate the configuration of DHCP in virtual machines. It provides a simple XML language to express DHCP configurations which are independent of the DHCP implementation used in the virtual machine. At present, DHCP Plugin is implemented only for ISC DHCP based servers and relays, but can be extended to support other implementations.

To use DHCP plugin in a VNX scenario, you have to add the following tag after <vm_defaults> section of <global> tag:

<extension plugin="dhcp" conf="dhcp_conf.xml" />

The plugin configuration file or PCF contains the DHCP configuration written in a XML language. Using that language the configuration of a router looks like:

...
<vm name="r1" type="dhcp3-isc">
    <server>
      <subnet>
        <network>10.0.1.0/24</network>
        <range>
          <first>10.0.1.10</first>
          <last>10.0.1.20</last>
        </range>
        <router>10.0.1.1</router>
        <dns>10.0.1.2</dns>
        <domain>dominio1.org</domain>
      </subnet>
    </server>
  </vm>
...

DHCP plugin just processes that configuration and translates it into the necessary DHCP configuration file (dhcp.conf) and manages the DHCP daemons. See the complete example below to know more about DHCP plugin capabilities.

DHCP Plugin Example Scenario

DHCP Plugin example is a simple scenario made of two routers (r1 and r2) and two hosts (h1 and h2) designed to show the capabilities of the plugin. r1 runs a DHCP server; r2 runs a DHCP relay that retransmits requests to r1; and h1 and h2 autoconfigure themselves from r1 and r2 using DHCP. This example is included in VNX distribution.

DHCP Plugin example scenario map
(generated using "vnx -f example_dhcp-plugin.xml -v --show-map")

To start the scenario, just type:

cd /usr/share/vnx/plugins/examples
vnx -f example_dhcp-plugin.xml -v -t

Note: in case you get an error related with the existance of '/root/.ssh/id_dsa.pub' file, either create that file executing "ssh-keygen -t dsa" or delete or modify the <ssh_key> tag on the scenario.

Once started, you can check that the hosts have been configured:

root@h1:~# ifconfig eth1
eth1      Link encap:Ethernet  direcciónHW 02:fd:00:04:03:01  
          Direc. inet:10.0.1.10  Difus.:10.0.1.255  Másc:255.255.255.0
          Dirección inet6: fe80::fd:ff:fe04:301/64 Alcance:Enlace
          ....

And the daemons are running over r1 and r2:

root@r1:~# ps uax | grep dhcpd
dhcpd      841  0.0  0.9   4668  2320 ?        Ss   23:28   0:00 /usr/sbin/dhcp -q -pf /var/run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf

r2:~# ps uax | grep dhcrelay
root      2110  0.0  0.7   3160   456 ?        Ss   23:27   0:00 /usr/sbin/dhcrelay3 -q 10.0.0.1

To know the scenario commands made available to the user by the plugin, you can use the "exe-info" mode of VNX:


# vnx -f example_dhcp-plugin.xml --exe-info
----------------------------------------------------------------------------------
Virtual Networks over LinuX (VNX) -- http://www.dit.upm.es/vnx - vnx@dit.upm.es
Version: 2.0b.894 (built on 11/09/2011_12:20)
----------------------------------------------------------------------------------
Using configuration file: /etc/vnx.conf
  TMP dir=/tmp
  VNX dir=/root/.vnx
----------------------------------------------------------------------------------

VNX exe-info mode:

User-defined command sequences for scenario 'example_dhcp_plugin'
----------------------------------------------------------------------------------
 stop-www                 Stop apache2 web server
 start-www                Start apache2 web server

Plugin 'dhcp' command sequences for scenario 'example_dhcp_plugin'
----------------------------------------------------------------------------------
 dhcp-server-stop         Stops DHCP servers
 on_shutdown              Stops all DHCP daemons
 dhcp-relay-start         Starts DHCP relays
 dhcp-stop                Synonym of stop
 dhcp-start               Synonym of start
 dhcp-client-restart      Releases client IP configurations and rexecutes DHCP clients
 dhcp-relay-stop          Stops DHCP relays
 restart                  Restarts all DHCP daemons and clients
 dhcp-client-start        Executes DHCP clients
 dhcp-relay-force-reload  Restarts DHCP relays using 'force-reload'
 stop                     Stops all DHCP daemons and releases client configurations
 dhcp-server-force-reload Restarts DHCP servers using 'force-reload'
 dhcp-relay-restart       Restarts DHCP relays
 dhcp-restart             Synonym of restart
 on_boot                  Creates DHCP config files and starts services
 dhcp-server-start        Starts DHCP servers
 dhcp-client-stop         Releases client IP configurations
 redoconf                 Creates DHCP config files
 dhcp-server-restart      Restarts DHCP servers
 start                    Starts all DHCP daemons and clients
----------------------------------------------------------------------------------
Total time elapsed: 0 seconds

For example, you can edit example_dhcp-plugin-conf.xml to change the range of addresses asigned to subnet 10.0.1.0/24. Just edit the value of <first> tag and change it to 10.0.1.15 and reload the configuration file with:

vnx -f example_dhcp-plugin.xml -v -x redoconf -M r1

After 'redoconf' command you can check the changes have been made to configuration files by accessing r1 and having a look at /etc/dhcp/dhcp.conf file.

After that, you can restart the DHCP server in r1 with:

vnx -f example_dhcp-plugin.xml -v -x dhcp-server-restart -M r1

An renew the address of h1 with:

vnx -f example_dhcp-plugin.xml -vvv -x dhcp-client-restart -M h1

Note: typically plugins provide the same basic 'start|stop|restart' commands with two sequence names: general (i.e. start) and specific (i.e. dhcp-start). Both execute the same actions, but the specific one is used when you want to execute commands only over a specific plugin. Selecting the general one will tipically execute commands over all plugings and some user-defined commands.

Scenario Specification

<?xml version="1.0" encoding="UTF-8"?>

<!--
~~~~~~~~~~~~~~~~~~~~
VNX Sample scenarios
~~~~~~~~~~~~~~~~~~~~

Name:        example_dhcp-plugin
Description: Simple example that shows dhcp plugin capabilities.  

This file is part of the Virtual Networks over LinuX (VNX) Project distribution. 
(www: http://www.dit.upm.es/vnx - e-mail: vnx@dit.upm.es) 

Departamento de Ingenieria de Sistemas Telematicos (DIT)
Universidad Politecnica de Madrid
SPAIN
-->

<vnx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="/usr/share/xml/vnx/vnx-2.00.xsd">
  <global>
    <version>2.0</version>
    <scenario_name>example_dhcp_plugin</scenario_name>
    <ssh_key>~/.ssh/id_dsa.pub</ssh_key>
    <automac offset="4"/>
    <!--vm_mgmt type="none" /-->
    <vm_mgmt type="private" network="10.250.0.0" mask="24" offset="16">
       <host_mapping />
    </vm_mgmt> 
    <vm_defaults>
        <console id="0" display="no"/>
        <console id="1" display="yes"/>
        <exec_mode type="uml">mconsole</exec_mode>
        <exec_mode type="libvirt" subtype="kvm">cdrom</exec_mode>
        <exec_mode type="libvirt" subtype="kvm" os="windows">cdrom</exec_mode>
        <exec_mode type="libvirt" subtype="kvm" os="olive">sdisk</exec_mode>
    </vm_defaults>
    <extension plugin="dhcp" conf="example_dhcp-plugin-conf.xml" />
    
    <help>
        <exec_help seq='start-www'>Start apache2 web server</exec_help>
        <exec_help seq='stop-www'>Stop apache2 web server</exec_help>
    </help>

  </global>
    
  <net name="lan1" mode="virtual_bridge" />
  <net name="lan2" mode="virtual_bridge" />
  <net name="ptp12" mode="virtual_bridge" />
  
  <!-- NODES -->
  <vm name="r1" type="libvirt" subtype="kvm" os="linux" exec_mode="cdrom">
    <filesystem type="cow">/usr/share/vnx/filesystems/rootfs_ubuntu</filesystem>
    <mem>256M</mem>
    <if id="1" net="lan1">
      <ipv4>10.0.1.1/24</ipv4>
      <ipv6>2001:db8:1::1/64</ipv6>
    </if>
    <if id="2" net="ptp12">
      <ipv4>10.0.0.1/30</ipv4>
      <ipv6>2001:db8:12::1/64</ipv6>
    </if>
    <route type="ipv4" gw="10.0.0.2">10.0.2.0/24</route>    
    <forwarding type="ip" />
    <filetree seq="start-www" root="/var/www/" user="www-data" group="www-data" perms="644">conf/txtfile</filetree>
    <exec seq="start-www" type="verbatim" ostype="system">service apache2 start</exec>
    <exec seq="stop-www" type="verbatim"  ostype="system">service apache2 stop</exec>    
  </vm>

  <vm name="r2" type="uml" subtype="" os="" exec_mode="mconsole">
    <filesystem type="cow">/usr/share/vnx/filesystems/rootfs_uml</filesystem>
    <mem>64M</mem>
    <kernel>/usr/share/vnx/kernels/linux</kernel>
    <if id="1" net="lan2" name="fxp0">
      <ipv4>10.0.2.1/24</ipv4>
      <ipv6>2001:db8:2::1/64</ipv6>
    </if>
    <if id="2" net="ptp12" name="fxp1">
      <ipv4>10.0.0.2/30</ipv4>
      <ipv6>2001:db8:12::2/64</ipv6>
    </if>
    <route type="ipv4" gw="10.0.0.1">10.0.1.0/24</route>    
    <forwarding type="ip" />
  </vm>

  <vm name="h1" type="libvirt" subtype="kvm" os="linux" exec_mode="cdrom">
    <filesystem type="cow">/usr/share/vnx/filesystems/rootfs_ubuntu</filesystem>
    <mem>256M</mem>
    <if id="1" net="lan1">
      <!--ipv4>10.0.1.2/24</ipv4>
      <ipv6>2001:db8:1::2/64</ipv6-->
    </if>
    <!--route type="ipv4" gw="10.0.1.1">default</route>    
    <route type="ipv6" gw="2001:db8:1::1">default</route-->       
  </vm>

  <vm name="h2" type="uml" exec_mode="mconsole">
    <filesystem type="cow">/usr/share/vnx/filesystems/rootfs_uml</filesystem>
    <mem>64M</mem>
    <kernel>/usr/share/vnx/kernels/linux</kernel>
    <if id="1" net="lan2">
      <!--ipv4>10.0.2.2/24</ipv4>
      <ipv6>2001:db8:2::2/64</ipv6-->
    </if>
    <!--route type="ipv4" gw="10.0.2.1">default</route>    
    <route type="ipv6" gw="2001:db8:2::1">default</route-->       
  </vm>
  

  <host>
    <hostif net="lan1">
       <ipv4>10.0.1.3/24</ipv4>
       <ipv6>2001:db8:1::3/64</ipv6>
    </hostif>
    <route type="ipv4" gw="10.0.1.1">10.0.0.0/16</route>    
    <route type="ipv6" gw="2001:db8:1::1">2001:db8::/32</route>    
  </host>
  
</vnx>

Plugin Configuration File (PCF)

<dhcp_conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="/usr/share/xml/vnx/dhcp.xsd">

  <vm name="r1" type="dhcp3-isc">
    <server>
      <subnet>
        <network>10.0.1.0/24</network>
        <range>
          <first>10.0.1.10</first>
          <last>10.0.1.20</last>
        </range>
        <router>10.0.1.1</router>
        <dns>10.0.1.2</dns>
        <domain>dominio1.org</domain>
      </subnet>
      <subnet>
        <network>10.0.2.0/24</network>
        <range>
          <first>10.0.2.10</first>
          <last>10.0.2.20</last>
        </range>
        <router>10.0.2.1</router>
        <host name="Unicum" mac="AA:BB:CC:DD:EE:FF" ip="10.0.2.28"/>
      </subnet>
      <subnet>
        <network>10.0.0.0/30</network>
      </subnet>
    </server>
  </vm>

  <vm name="h1" type="dhcp3">
    <client>
      <if>eth1</if>
    </client>
  </vm>

  <vm name="r2" type="dhcp3">
    <relay>
      <toserver>10.0.0.1</toserver>
    </relay>
  </vm>

  <vm name="h2" type="dhcp3">
    <client>
      <if>eth1</if>
    </client>
  </vm>

</dhcp_conf>