dhcp3 server script

Ted Lemon Ted.Lemon at nominum.com
Thu Mar 6 14:26:22 UTC 2008


Type "man dhclient-script" to get documentation on this.   What I do  
is to add a /etc/dhclient-exit-hooks script, like the one I've  
included below.   My script updates the NAT on NetBSD; you should be  
able to do something similar on your operating system.   If you're  
running linux, you should be able to hack this script and put it in / 
etc/dhcp3/dhclient-exit-hooks.d; read the /etc/dhcp3/dhclient-exit- 
hooks.d/debug script to see what this looks like.


#!/bin/sh
#
# $NetBSD: dhclient-script,v 1.12 2006/10/08 17:09:32 riz Exp $

reconfigure_nat() {
        echo map sip0 10.0.10.0/24 -\> $new_ip_address/32 \
                portmap tcp 10000:50000
        (echo map sip0 10.0.10.0/24 -\> $new_ip_address/32 \
                portmap tcp/udp 10000:50000; \
         echo map sip0 10.0.10.0/24 -\> $new_ip_address/32; \
         echo) |ipnat -v -CF -f -
}

case "$reason" in
BOUND|RENEW|REBIND|REBOOT)
        if [ \( -z "$old_ip_address" \) -o \
            \( "x$old_ip_address" != "x$new_ip_address" \) -o \
            \( "x$reason" = "xBOUND" \) -o \( "x$reason" = "xREBOOT"  
\) ]; then
                reconfigure_nat
                sysctl -w net.inet.ip.forwarding=1
        fi
        ;;

EXPIRE|FAIL|RELEASE|STOP|TIMEOUT)
        if [ ! -z "$old_ip_address" ]; then
                echo |ipnat -v -CF -f -
                sysctl -w net.inet.ip.forwarding=0
        fi
        ;;
*)
        ;;
esac





More information about the dhcp-hackers mailing list