This Labs show an example of IPv4 DHCP Relay and server with BSDRP
Download a BSDRP serial image (prevent to have to use an X display) on SourceForge.
More information on these BSDRP lab scripts available on How to build a BSDRP router lab.
Start a lab with 3 routers full meshed (no common LAN), example with VirtualBox script:
./BSDRP-lab-vbox.sh -n 3 -i BSDRP_0.36_full_amd64_serial.img
Edit the /etc/rc.conf file:
[root@router]~#vi /etc/rc.conf
And change these parameters:
hostname="R3.bsdrp.net" #Routing not needed gateway_enable="NO" ipv6_gateway_enable="NO" quagga_enable="NO" ifconfig_em1="10.0.23.3/24" defaultrouter="10.0.23.2" dhcpd_enable="YES" dhcpd_flags="-q" dhcpd_conf="/usr/local/etc/dhcpd.conf" dhcpd_ifaces="em1"
Then Edit the DHCP server config file:
[root@router]~#vi /usr/local/etc/dhcpd.conf
And fill this file with theses parameters:
option domain-name "bsdrp.net";
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
subnet 10.0.23.0 netmask 255.255.255.0 {
}
subnet 10.0.12.0 netmask 255.255.255.0 {
range 10.0.12.100 10.0.12.200;
option routers 10.0.12.2;
}
Then Apply the changes:
[root@router]~#hostname R3.bsdrp.net [root@R3]~#/etc/rc.d/netif restart [root@R3]~#/usr/local/etc/rc.d/isc-dhcpd start [root@R3]~#config save
Edit the /etc/rc.conf:
[root@router]~#vi /etc/rc.conf
and set these parameters:
hostname="R2.bsdrp.net" ifconfig_em0="10.0.12.2/24" ifconfig_em1="10.0.23.2/24" dhcrelay_enable="YES" dhcrelay_servers="10.0.23.3" dhcrelay_ifaces="em0 em1"
[root@router]~#hostname R2.bsdrp.net [root@R2]~#/etc/rc.d/netif restart [root@R2]~#/usr/local/etc/rc.d/isc-dhcrelay start Starting dhcrelay. Internet Systems Consortium DHCP Relay Agent 4.2.2 Copyright 2004-2011 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Listening on BPF/em1/aa:aa:00:00:02:23 Sending on BPF/em1/aa:aa:00:00:02:23 Listening on BPF/em0/aa:aa:00:00:02:12 Sending on BPF/em0/aa:aa:00:00:02:12 Sending on Socket/fallback [root@R2]~#config save
Edit the /etc/rc.conf:
[root@router]~#vi /etc/rc.conf
And set theses parmaters:
hostname="R1.bsdrp.net" ifconfig_em0="DHCP" # Disable routing gateway_enable="NO" ipv6_gateway_enable="NO" quagga_enable="NO"
Then save the changes:
[root@router]~#hostname R1.bsdrp.net [root@R1]~#config save
Send a DHCP Discover from R1:
[root@R1]~#dhclient em0 DHCPDISCOVER on em0 to 255.255.255.255 port 67 interval 7 DHCPOFFER from 10.0.12.2 DHCPREQUEST on em0 to 255.255.255.255 port 67 DHCPACK from 10.0.12.2 bound to 10.0.12.100 -- renewal in 300 seconds.
Check that default route was received:
[root@R1]~#show route | grep default default 10.0.12.2 UGS 0 4 em0
And ping the DHCP server:
[root@R1]~#ping 10.0.23.3 PING 10.0.23.3 (10.0.23.3): 56 data bytes 64 bytes from 10.0.23.3: icmp_seq=0 ttl=63 time=2.680 ms 64 bytes from 10.0.23.3: icmp_seq=1 ttl=63 time=1.190 ms 64 bytes from 10.0.23.3: icmp_seq=2 ttl=63 time=1.195 ms ^C --- 10.0.23.3 ping statistics --- 3 packets transmitted, 3 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 1.190/1.688/2.680/0.701 ms