User Tools

Site Tools


documentation:examples:dhcp_relay_and_server_lab

DHCP Relay and Server lab

This Labs show an example of IPv4 DHCP Relay and server with BSDRP (v1.51)

Presentation

Network diagram

Here is the logical and physical view:

Setting-up the lab

Downloading BSD Router Project images

Download a BSDRP serial image (prevent to have to use an X display) on SourceForge.

Downloading BSDRP lab scripts and starting the lab

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

Routers configuration

Router 3 (DHCP server)

Set the basic parameters:

sysrc hostname=R3
sysrc gateway_enable=NO
sysrc ipv6_gateway_enable=NO
sysrc quagga_enable=NO
sysrc ifconfig_em1="10.0.23.3/24"
sysrc defaultrouter="10.0.23.2" 
sysrc dhcpd_enable=YES
sysrc dhcpd_flags="-q"
sysrc dhcpd_conf="/usr/local/etc/dhcpd.conf"
sysrc dhcpd_ifaces="em1"

Then Create the DHCP server config file:

cat > /usr/local/etc/dhcpd.conf <<'EOF'
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;
}
'EOF'

Then Apply the changes:

hostname R3
service quagga stop
service netif restart
service routing restart
service isc-dhcpd start
config save

Router 2 (Router and DHCP Relay)

Set the basic parameters:

sysrc hostname=R2
sysrc ifconfig_em0="10.0.12.2/24"
sysrc ifconfig_em1="10.0.23.2/24"
sysrc dhcprelya_enable=YES
sysrc dhcprelya_servers="10.0.23.3"
sysrc dhcprelya_ifaces="em0"
sysrc quagga_enable=NO

Then apply the changes:

hostname R2
service netif restart
service routing restart
service quagga stop
service dhcprelya start
config save

Router 1 (DHCP client)

Set the basic parameters:

sysrc hostname=R1
sysrc ifconfig_em0="DHCP"
sysrc gateway_enable=NO
sysrc ipv6_gateway_enable=NO
sysrc quagga_enable="NO"

Then save the changes:

hostname R1
service netif restart
service routing restart
service quagga stop
config save

Final testing

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
documentation/examples/dhcp_relay_and_server_lab.txt · Last modified: 2014/06/11 19:27 by olivier