File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_set_up_a_dhcp_server.mdwn
Revision 1.1: download - view: text, annotated - select for diffs
Sun Nov 20 21:35:54 2011 UTC (2 years, 5 months ago) by mspo
Branches: MAIN
CVS tags: HEAD
even more pkgsrc.se imports

Setting up a DHCP Server for your home or company network is pretty simple with NetBSD. You don't need to install any software, because everything you need, is part of the base system. Just create the file /etc/dhcpd.conf like this: 
    
    
    deny unknown-clients;       
    ddns-update-style none;      
    subnet 192.168.0.0 netmask 255.255.255.0 {
            range 192.168.0.200 192.168.0.254; 
            default-lease-time 28800;
            max-lease-time 86400;
            option broadcast-address 192.168.0.255;
            option domain-name "mycompanydomainname.com";
            option domain-name-servers 194.152.64.35, 194.25.2.132;
            option routers 192.168.0.1;
     
            host ftp-server {
                    hardware ethernet 00:00:0a:d8:39:ee;
                    fixed-address 192.168.0.199;
                    }
            host sparc {
                    hardware ethernet 00:50:04:01:ee:20;
                    fixed-address 192.168.0.198;
                    }
    }
    

Now add the service to your /etc/rc.conf. This way the DHCP will be started on every reboot. 
    
    dhcpd=yes
    dhcpd_flags="-q ex0"
    

ex0 is the Network Interface to listen on for dhcp requests. This is important if you have more than one Network Interface. If you don't, you can omit the second line. 

Before starting the service, you have to create a lease file, that the dhcp server needs. 
    
    # touch /var/db/dhcpd.leases
    

Now start the service: 
    
    # /etc/rc.d/dhcpd start
    

To test if your dhcp server is running, run _dhclient_ on another host on the same network. 
    
    # dhclient
    

Also check your /var/db/dhcpd.leases file. That's it. Have fun. 

##  Additional Information 

  * [dhcpd(8)](http://netbsd.gw.com/cgi-bin/man-cgi?dhcpd+8+NetBSD-current)


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb