Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Oct 1998 18:53:24 -0600
From:      Oscar Bonilla <obonilla@guate.net>
To:        bernt@usa.net
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   setting up dhcp
Message-ID:  <36200184.E84181D3@guate.net>

next in thread | raw e-mail | index | archive | help
first of all you have to install the client from the pkgs 
what i have is : isc-dhcp-1.0.0 

the client is installed in
/usr/local/sbin/dhclient
that's the command you'll have to run... but not yet!!

first you have to create some files in /etc

edit /etc/dhclient.conf and fill it whith something like this:

-----------------------------------------

interface "XXXX" {
        request subnet-mask, routers,
                domain-name, domain-name-servers, host-name;
        require subnet-mask, domain-name-servers, routers;
        script "/etc/dhclient-script";
} 
------------------------------------------

where XXXX is the name of your network interface (ed0 for example)
the request line is what you ask to the dhcp server to give you.
the require line says the minimum you will accept, and the script
line tells dhclient which script to call when configuring this 
interface.

next you have to create /etc/dhclient-script and fill it whith something
like this:

----------------------------

#!/bin/sh

case $reason in
'PREINIT')
        ifconfig $interface netmask 255.255.255.255 up
        echo "dhcp preinit" >/dev/console
        ;;
'BOUND')
        ifconfig $interface delete
        ifconfig $interface $new_ip_address netmask $new_subnet_mask up
        route add default $new_routers
        echo "domain $new_domain_name" >/etc/resolv.conf
        echo $new_domain_name_servers | sed 's/ /\
/g' | awk '{print "nameserver " $1}' >>/etc/resolv.conf
        echo "dhcp bound" >/dev/console
        ;;
'REBIND')
        ifconfig $interface delete
        ifconfig $interface $new_ip_address netmask $new_subnet_mask up
        route add default $new_routers
        echo "domain $new_domain_name" >/etc/resolv.conf
        echo $new_domain_name_servers | sed 's/ /\
/g' | awk '{print "nameserver " $1}' >>/etc/resolv.conf
        echo "dhcp rebound" >/dev/console
        ;;
'REBOOT')
        ifconfig $interface delete
        ifconfig $interface $new_ip_address netmask $new_subnet_mask up
        route add default $new_routers
        echo "domain $new_domain_name" >/etc/resolv.conf
        echo $new_domain_name_servers | sed 's/ /\
/g' | awk '{print "nameserver " $1}' >>/etc/resolv.conf
        echo "dhcp reboot" >/dev/console
        ;;
*)
        echo $reason: unhandled >/dev/console
        ;;
esac       

----------------------------------------------------

note that i only handle a bunch of responses. if you want to handle'em
all read the man page for dhclient

now you should be able to just run /usr/local/sbin/dhclient and 
watch the console for messages concerning the dhcp protocol

one last thing. the dhclient puts the net interface in promiscuos mode
to get the responses (since it doesn't have an ip address at this stage)
so you have to enable the bpf in the kernel for dhclient to work

regards,

-oscar

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36200184.E84181D3>