DHCP

From RFC 2131:

The DHCP provides a framework for passing configuration information to hosts on a TCP/IP network.

DHCP utilizes a server/client model to deliver the protocol. DHCP servers allocate network addresses to clients and provide them with network configurations.

DHCP Client

SoodarOS uses DHCPCD as a DHCP client to automatically assign IP address to interfaces.

DHCP Client Configuration

ip dhcp client hostname HOSTNAME

Send provided hostname as client’s hostname to server. The default value is the system’s hostname.

ip dhcp client request router

Request( deny in case of negating) router option from server.

ip dhcp client request dns-nameserver

Request( deny in case of negating) DNS option from server.

DHCP Server

SoodarOS uses Kea DHCP as a backend to provide DHCP server functionalities. These functionalities include:

  • Add IP pools and define subnet and IP ranges to allocate to hosts

  • Provide clients DNS server addresses

  • Provide clients gateway address

  • Provide clients NTP server addresses

  • Set leasing time for each pool

  • Show/Clear bindings

Configuring Pool

ip dhcp pool DHCP4POOL

Create a new DHCP4 pool. Each pool has a subnet. This subnet determines which pool should be used for incoming requests by matching the pool’s subnet with the ingress interface subnet. The negated form removes a pool from pools.

soodar(config)# ip dhcp pool p1
soodar(dhcp-config)#
network A.B.C.D/M

Set pool’s subnet address.

soodar(config)# ip dhcp pool p1
soodar(dhcp-config)# network 192.168.1.0/24
included-address A.B.C.D A.B.C.D

Define a range of addresses that could be used for allocating to clients from the subnet. Each pool can have multiple ``included-address``commands.

soodar(config)# ip dhcp pool p1
soodar(dhcp-config)# included-address 192.168.1.100 192.168.1.120
soodar(dhcp-config)# included-address 192.168.1.140 192.168.1.165
dns-server A.B.C.D ...

Configure DNS server address(es) that is fed to clients. Users can provide all addresses in one command or issue multiple commands.

Note

Up to 8 DNS servers can be set. It is not allowed to set more than 8 servers.

Example:

Following lines set 1.1.1.1, 4.2.2.4 and 8.8.8.8 as DNS servers:

soodar(config)# ip dhcp pool p1
soodar(dhcp-config)# dns-server 4.2.2.4 1.1.1.1
soodar(dhcp-config)# dns-server 8.8.8.8
default-router A.B.C.D ...

Set gateway address(es) for presenting to clients. Users can provide all addresses in one command or issue multiple commands.

Note

Up to 8 gateway can be set. It is not allowed to set more than 8 addresses.

soodar(config)# ip dhcp pool p1
soodar(dhcp-config)# default-router 192.168.1.1
ntp-server NTP ...

Configure NTP server address(es) that is fed to clients. Users can provide all addresses in one command or issue multiple commands.

Note

Up to 8 NTP servers can be set. It is not allowed to set more than 8 servers.

soodar(config)# ip dhcp pool p1
soodar(dhcp-config)# ntp-server ir.pool.ntp.org
domain-name NAME

Specifies the domain name for clients

soodar(config)# ip dhcp pool p1
soodar(dhcp-config)# domain-name example.org
lease <(0-365) (0-23) (0-59)|infinite>

Set DHCP lease time in days, hours, and minutes or infinite to disable lease time. The default lease time is 24 hours( 1 day). Negating resets lease time to the default value.

soodar(config)# ip dhcp pool p1
soodar(dhcp-config)# ! set lease time to 30 days
soodar(dhcp-config)# lease 30 0 0

Configure interfaces

ip dhcp server

Enable DHCP serving on the interface. Negation disables DHCP serving.

soodar(config-if)# ip dhcp server
ip address dhcp

Enable DHCP client on the interface. Negation disables DHCP client.

Pool status and management

show ip dhcp pool

Show general information about a pool(s)

soodar# show ip dhcp pool p1

Pool p1 :
 Total addresses: 47
 Leased addresses:        1
 Declined addresses:      0
 2 ranges are currently in the pool :
 Range's low       Range's high
 192.168.1.100     192.168.1.120
 192.168.1.140     192.168.1.165
show ip dhcp binding [<DHCP4POOL|A.B.C.D>]

Show information about current bindings.

soodar# show ip dhcp binding
  IP Address   Client hostname   Client HW address   Lease expiration           Pool   Type        State
  1.1.1.100    n4                00:00:00:aa:00:01   Wed Nov  3 11:20:06 2021   p2     Automatic   Leased
clear ip dhcp binding <*|A.B.C.D>

Removes a binding from the lease database. If * is the input argument, clears all bindings