Today we will see how to use ISC dhcp server with the captive portal software CoovaChilli on ubuntu.

ISC DHCP server

Install:

First we need to install and setup ISC dhcp server

sudo apt-get update && sudo apt-get install isc-dhcp-server

Setup:

Change the default configuration by editing the config file

  sudo vim /etc/dhcp/dhcpd.conf
#
# Configuration file for ISC dhcpd for Debian
#
# Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as
# configuration file instead of this file.
#
#

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;

# option definitions common to all supported networks...
option domain-name "bazarnat.eu";
option domain-name-servers 8.8.8.8, 8.8.4.4;

default-lease-time 7200; # 2 hours for keep a clean pool
max-lease-time 21600;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

subnet 10.1.0.0 netmask 255.255.240.0 {
        range 10.1.0.10 10.1.15.250;
        option subnet-mask 255.255.240.0;
        option routers 10.1.0.1;
        option broadcast-address 10.1.15.255;
}

Specify the interface by editing the isc-dhcp-server file

  sudo vim /etc/default/isc-dhcp-server
# Defaults for isc-dhcp-server initscript

# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPD_CONF=/etc/dhcp/dhcpd.conf

# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPD_PID=/var/run/dhcpd.pid

# Additional options to start dhcpd with.
#       Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
#       Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="tun0"

Tools

Checking the dhcp leases

tail -f /var/lib/dhcp/dhcpd.leases

CoovaChilli

Edit the config file and comment the DHCP values

  sudo vim  /etc/chilli/config
    ###
    #   DHCP
    #

    #HS_DNS1=8.8.8.8
    #HS_DNS2=8.8.4.4
    #HS_DYNIP=10.1.0.10
    #HS_DYNIP_MASK=255.255.240.0

Edit the local file and put the external DHCP values

  sudo vim /etc/chilli/local.conf
    ###
    #   DHCP
    #

    dhcpgateway=10.5.0.1        #(external dhcp address)
    dhcpgatewayport=67
    dhcprelayagent=10.1.0.1     #(HS_UAMLISTEN=xxx.xxx.xxx.xxx in /etc/chilli/config)