IP Address Management using DHCP

Okapi > Miscellaneous

 

Okapi as DHCP Server

This configuration is for a simple set-up of a client and server on the same LAN. Here the client is assigned an IP address from a range of IP-addresses specified at DHCP server.

 

Network Diagram

 

Configuration

 

To configure DHCP server on Okapi router we start with defining a dhcp pool named test1. The network is the LAN in which we have DHCP client and server. Range of IP-addresses that will be used by Okapi DHCP server to assign to the clients can be configured as per own requirement.

Okapi(config)# ip dhcp excluded-address 192.168.1.9

Okapi(config)# ip dhcp pool test1
Okapi(config-dhcp)# network 192.168.1.0 255.255.255.0
Okapi(config-dhcp)# domain-name Test
Okapi(config-dhcp)# range 192.168.1.0 192.168.1.128
Okapi(config-dhcp)# lease days 1

Finally we launch the DHCP Server on router by executing the following command:

Okapi(config)# service dhcp

With this, we have DHCP server functional on Okapi which can listen to queries from the clients and assign them an appropriate address.

This can be verfied by running a request from any client in the network. E.g.

dhcp-client# dhclient eth0

Verify that fhis client has received an IP address.

 

 

Manual Binding

A client with a specific hardware address is assigned a particular ip address configured on the server.

 

Configuration


Setup the server with commands used in the configuration above. Set the harware-address - ip-address mapping for a client using the following commands.
Okapi-RouterA(config-dhcp)# host 192.168.1.250 255.255.255.0
Okapi-RouterA(config-dhcp)# client-identifier
Okapi-RouterA(config-dhcp)# client-name DHCP_Client
Okapi-RouterA(config-dhcp)# hardware-address aabb.ccdd.eeff
The host with the above mentioned mac address is always assigned the ip address 192.168.1.250.

 

 

Okapi as DHCP Client

 

This configuration shows how Okapi router can run as DHCP client and receive an IP address from any DHCP server.

It is very simple to run DHCP client on Okapi. One needs to execute the following command on all the interfaces which are expected to get IP address from DHCP server.

Okapi(config-if-eth)# ip address dhcp

This would result in interface eth0 getting an IP address and other configuration parameters from DHCP server automatically.

 

 

Okapi as DHCP Relay

 

Okapi can work as a DHCP relay agent as well. The DHCP client broadcasts a request for an IP address in a LAN. DHCP relay agent, picks up the broadcast message and inserts the IP address of the interface at which is receives the packet into the gateway IP address (GIADDR) field of the DHCP packet. Finally, the DHCP relay agent, unicasts it to DHCP Server as specified by the ip helper-address interface configuration command.

 

Network Diagram

Configuration

Setup the network as shown in the figure. Configure the dhcp server. Configure the router A to act as a relay agent on eth0.


Okapi(config-if-eth)# ip address helper-address 172.168.1.21

This command is used to specify the ip address of the DNS server.