11. Configuring a DHCP Server

Installing the DHCP service onto your system

We began supporting DHCP with calculate-server 2.1.4. Dhcpd is used as server.

Before installation

Make sure that the network interface is running and has an IP address belonging to the network, which will be specified for the installing of the DHCP service (the command line option you need will be --net).

Make sure that your system has DNS; if this service is not installed yet, install it by typing:

cl-setup dns

To install the DHCP service, execute:

cl-setup --router <gateway ip> --dnames <domain names> --range <ip range> --net <network ip with mask /24> --dnsip <server dns ip> dhcp

Options:

  • --router - the IP address to be sent to the client computer as the default gateway
  • --dnames - the domain names, comma-separated, to be sent to the client computer as domain names for search. The first name is used for creating a DNS domain on the server, where computers connecting to the network will be added.
  • --range - a range of dynamic IPs: any client computer will have an IP address within it.
  • --net - the network that client computers will be connected to
  • --dnsip - the IP address of the DNS server being sent to client computers

Note: For client computers to be able to find themselves in DNS, the --dnsip option should point at the current server with the installed DHCP service.

Example (the current server with the installed DHCP service has IP address 10.0.0.5):

cl-setup --router 10.0.0.1 --dnames domain.ru,domain.org --range 10.0.0.20,10.0.0.100 --net 10.0.0.0/24 --dnsip 10.0.0.5 dhcp

IMPORTANT: When you install the DHCP service, the domain name of the server is replaced with hostname.first_domain_name_for_search. If the FTP, Samba, Mail, Proxy, and Jabber services are already set up, you will have to specify the current domain as the first domain name; the relevant option is --dnames current_domain (if you do not know it, run hostname -d before you start installing the service). Another method is to specify, in DNS, the previous full server name, pointing to its IP address.

Managing the DHCP service

Manage static hosts in the DHCP service

Creating a static host in the DHCP service

To create a static host, execute:

cl-dhcp-hostadd --host <hostname> --ip <ip address> --mac <mac address>

Options:
  • --host - the hostname of the client computer (no domain)
  • --ip - the IP address being binded to the client computer
  • --mac - the MAC address of the client computer (if do not know it, run ifconfig)

Example:

cl-dhcp-hostadd --host test --ip 10.0.0.20 --mac 00:17:31:c2:88:82

Modifying parameters of a static host

To modify a static host, enter:

cl-dhcp-hostmod [options] <hostname>

Options:
  • --ip - the new IP address for the client computer
  • --mac - the new MAC address of the client computer

Example:

cl-dhcp-hostmod --ip 10.0.0.25 test

Deleting a static host

If you want to delete a static host, execute:

cl-dhcp-hostdel --host <hostname>

Options:
  • --host - the hostname of the client computer (no domain)

Example:

cl-dhcp-hostdel --host test

Manage DHCP networks

Creating a DHCP network

Only one network can be created for each network interface.

To create a network, execute:

cl-dhcp-netadd --router <gateway ip> --dnames <domain names> --range <range of ip for dynamic hosts хостов> --net <ip of network with mask /24> --dnsip <ip of DNS server> dhcp

Options:
  • --router - the IP address that will be sent to the client computer as the default gateway
  • --dnames - the domain names, comma-separated, to be sent to the client computer as domain names for search. The first name is used for creating a DNS domain on the server, where computers connecting to the network will be added.
  • --range - a range of dynamic IPs: any client computer will have an IP address within it.
  • --net - the client network
  • --dnsip - the IP address of the DNS server being sent to client computers

Example:

cl-dhcp-netadd --router 10.0.0.1 --dnames domain.ru,domain.org --range 10.0.0.20,10.0.0.100 --net 10.0.0.0/24 --dnsip 10.0.0.5

Modifying DHCP network options

To modify network options, use the following:

cl-dhcp-netmod  [options] ip_and_network_mask

Options:
  • --router - the new IP address being sent to the client computer as the default gateway
  • --dnames - the new domain names, comma-separated, being sent to the client computer as domain names for search. The first name is used for creating a DNS domain on the server, where computers connecting to the network will be added.
  • --range - the new range of dynamic IPs: any client computer will have an IP address within it.
  • --dnsip - the new IP address of the DNS server, to be sent to client computers.

Example:

cl-dhcp-netmod --range 10.0.0.50,10.0.0.255 10.0.0.0/24
cl-dhcp-netmod --router 10.0.0.1 10.0.0.0/24

Deleting a DHCP network

If only one DHCP network exists, removing it will make it impossible to have the DHCP running. To mend the situation in this latter case, please add a new network.

To delete a network, execute:

cl-dhcp-netdel --net ip_and_network_mask

Options:
  • --net - the network to be removed

Example:

cl-dhcp-netdel --net 10.0.0.0/24

Information about the DHCP service

Use the cl-info command to learn about the records and zones of the DNS service.

Information about all networks

cl-info -n dhcp

Information about the network

cl-info -N <ip_and_network_mask> dhcp

Example:

cl-info -N 10.0.0.0/24 dhcp

Getting information about network 10.0.0.0/24

Information about all static hosts

cl-info --hosts dhcp

Information about a static host

cl-info -H <hostname> dhcp

Example:

cl-info -H computer dhcp

Getting information on a static host, named "computer".

Thank you!