dhcp

Note: Google Drive links may not work or might be expired. You can find the scripts here

Tutorial no 7

                                         Dynamic Host Control Protocol (DHCP)  configuration allows dynamic IP address allocation to hosts in network. Certain IP addresses range is defined called DHCP Pool. When host are connecting to network node they request IP address from DHCP server. And from DHCP Pool IP address is assigned to hosts. So, we don’t have to manually give static IP addresses to hosts.

                                      In the POX we have default script called dhcpd in the folder pox/pox/misc which gives ip to host from the range 192.168.0.0 to 192.168.0.254. This is default range of this script. You can modify according to your need. I have modified to 5.6.0.0 to 5.6.0.254 , which is new DHCP pool.

1) Mininet by default assigns IP address to hosts. So, I have made topology script with two hosts & with no IP assigned to it. Script is available here. Save the topology script in pox/ext location. You can use command line editor nano. Copy the code and save using key ‘CTRL+O’

1

2

2) I have saved script with name mininet-test.py, run script using command

sudo python ./mininet-test.py

3

3) You can check host has no IP by default by command

dump

4

4)Now run script dhcpd.py from pox/pox/misc on controller.

./pox.py –log.level – -DEBUG misc.dhcpd

5

5)Lets check our hosts got IP address from DHCP server or not.

Xterm h1 h2                                                                                                                                                             Ifconfig

6

Unfortunately not. This script is not perfect DHCP.

6) In general hosts request IP from DHCP server automatically. But here we have to request DHCP server from host mannualy. I know its quite disappointing.

sudo dhclient h1-eth0                                                                                                                                              sudo dhclient h2-eth0

Now you can see, our hosts are happy with newly assigned IP addresses. To check IP use command,

ifconfig -a

7

                         You can see hosts  have now IP addresses from the pool 5.6.0.0-5.6.0.254, note that default pool is 192.168.0.0-192.168.0.254 & this script edited with new pool. You can also pass the parameters to define new pool.