Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Overview

This document will show you how to configure a DHCP server listening to multiple VLANs. However, Abiquo recommends that you use a DHCP relay server to provide VLAN configuration.

A DHCP server only allows 200 VLANs. If more VLANs are needed, you should set up a DHCP relay server.

Abiquo recommends that you always use a DHCP relay server to provide VLAN support because it is difficult to scale this DHCP Server-only Configuration.

Install needed packages

You need to install vconfig (this is used to create VLANs), which is available in the EPEL repository:

# yum install epel-release && yum makecache && yum clean all
# yum install vconfig
Create configuration scripts

To generate needed files, we will use Abiquo dhcpd config script.

# ./abiquo-dhcpd-config.py -h

Usage: abiquo-dhcpd-config.py [OPTIONS]...
Creates configuration files and start scripts for the DHCP server and VLANs.

-h	--help				This help screen.
-s	--service-interface=INTERFACE	Interface of the relay server connected to service network, where VLANs will be created.
-v	--vlan-range=VLANRANGE		VLAN range (e.g. 2-200).
-n	--service-network=IP		Network available for relay service interfaces (has to finish in 0).

It will generate 1 bash script (vlans-config) and 1 config file for DHCP server (/etc/sysconfig/dhcpd). For example:

DHCP server is connected to VLANs through eth1 (service network)
DHCP server listens to VLAN range 2-200
Network for service network interfaces: 10.0.0.0

The service network is used to identify each VLAN interface. This network has to be different from every other network that the DHCP server has access to.

# ./abiquo-dhcpd-config.py -s eth1 -v 2-200 -n 10.0.0.0
-- Generating file --

 * vlans-config		Script to generate VLANs and assign IPs
 * dhcpd		Script to configure dhcpd listen interfaces

-- End --
Configure DHCP server

Ensure that the vlans-config service always starts before the dhcpd service.

VLANs init script
# cp vlans-config /etc/init.d/
# chkconfig vlans-config on
# service vlans-config start
DHCP server
# cp dhcpd /etc/sysconfig/dhcpd
# service dhcpd restart
Add a single out-of-range VLAN tag

To create a single out-of-range VLAN tag e.g. a new public VLAN, edit your script at /etc/init.d/vlan-config and look for text like this:

start() {
    echo -n $"Starting $prog: "
    for i in `seq 1 199`; do
        vlan=$[0 + $i - 1 + 2]
        vconfig add eth0 $vlan
        ifconfig eth0.$vlan up
        ifconfig eth0.$vlan 10.0.0.$i netmask 255.255.255.255
    done
}

In the above example, we can see that the service interface is eth0, the range is 2-200 and the service IP is 10.0.0.0.

Following the example, if we want to add the VLAN Tag 500, we will add these lines:

vconfig add eth0 500
ifconfig eth0.500 up
ifconfig eth0.500 10.0.1.2 netmask 255.255.255.255

The result will look like this:

start() {
    echo -n $"Starting $prog: "
    for i in `seq 1 199`; do
        vlan=$[0 + $i - 1 + 2]
        vconfig add eth0 $vlan
        ifconfig eth0.$vlan up
        ifconfig eth0.$vlan 10.0.0.$i netmask 255.255.255.255
    done
vconfig add eth0 500
ifconfig eth0.500 up
ifconfig eth0.500 10.0.1.2 netmask 255.255.255.255
}

Now we will add the reverse command to stop the network. Look for text like this:

stop() {
    echo -n $"Stopping $prog: "

    killproc vlans-config

    for i in `seq 2 200`; do
        vconfig rem eth0.$i
    done
        

    RETVAL=$?
    echo
    return $RETVAL
}

And add these lines following the above example:

vconfig rem eth0.500

The result will look like this:

stop() {
    echo -n $"Stopping $prog: "

    killproc vlans-config

    for i in `seq 2 200`; do
        vconfig rem eth0.$i
    done
    vconfig rem eth0.500    

    RETVAL=$?
    echo
    return $RETVAL
}

Afterwards, save the file and restart the script. Now you need to add the VLAN you will be using to /etc/sysconfig/dhcpd:
Add it between the quotation marks to the end of any existing DHCPDARGS value (represented here as [...]):

DHCPDARGS="[...]"

Following the example above:

DHCPDARGS="[...] eth0.500"
  • No labels