DHCP server is used to assigning IP to the computer automatically. But as you know that buying a server is costly.To reduce that cost we can configure our router to work as DHCP server. after configuring router as dhcp server we don’t need any dhcp serer to assigning ip to the computer. the router will do that work of assigning ip. But you should not use this method to work in large no. of networks because just in case if the router fails your whole networks will fail to work.so,for a large network you should use a dhcp server. I would prefer to use this method only in small networks.
For practice lets take a sample problem.
Firstly we assign ip to the router ports and give host name to the router.
Continue with configuration dialog? [yes/no]: no
Press RETURN to get started!
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config-if)#ip address 184.108.40.206 255.0.0.0
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router1(config-if)#ip address 220.127.116.11 255.0.0.0
Now create a DHCP pool on router by following commands.
Router1(config)#ip dhcp pool pool1
Router1(dhcp-config)#network 18.104.22.168 255.0.0.0
Router1(config)#ip dhcp pool pool2
Router1(dhcp-config)#network 22.214.171.124 255.0.0.0
*here pool1/pool2 is the name of that pool to identify the network, and default-router is the ip of the port which is connected to that network.
Now you can assign ip to the computer b DHCP setting and it will take the ip automatically.