Конфигурация сервера dhcp линукс

About Dynamic Host Configuration Protocol (DHCP)

The Dynamic Host Configuration Protocol (DHCP) is a network service that enables host computers to be automatically assigned settings from a server as opposed to manually configuring each network host. Computers configured to be DHCP clients have no control over the settings they receive from the DHCP server, and the configuration is transparent to the computer’s user.

The most common settings provided by a DHCP server to DHCP clients include:

  • IP address and netmask
  • IP address of the default-gateway to use
  • IP addresses of the DNS servers to use

However, a DHCP server can also supply configuration properties such as:

The advantage of using DHCP is that any changes to the network, such as a change in the DNS server address, only need to be changed at the DHCP server, and all network hosts will be reconfigured the next time their DHCP clients poll the DHCP server. As an added advantage, it is also easier to integrate new computers into the network, as there is no need to check for the availability of an IP address. Conflicts in IP address allocation are also reduced.

DHCP configuration

A DHCP server can provide configuration settings using the following methods:

Manual allocation (MAC address)

This method uses DHCP to identify the unique hardware address of each network card connected to the network, and then supplies a static configuration each time the DHCP client makes a request to the DHCP server using that network device. This ensures that a particular address is assigned automatically to that network card, based on its MAC address.

Dynamic allocation (address pool)

In this method, the DHCP server assigns an IP address from a pool of addresses (sometimes also called a range or scope) for a period of time (known as a lease) configured on the server, or until the client informs the server that it doesn’t need the address anymore. This way, the clients receive their configuration properties dynamically and on a “first come, first served” basis. When a DHCP client is no longer on the network for a specified period, the configuration is expired and released back to the address pool for use by other DHCP clients. After the lease period expires, the client must renegotiate the lease with the server to maintain use of the same address.

Читайте также:  Увеличить системный диск linux

Automatic allocation

Using this method, the DHCP automatically assigns an IP address permanently to a device, selecting it from a pool of available addresses. Usually, DHCP is used to assign a temporary address to a client, but a DHCP server can allow an infinite lease time.

The last two methods can be considered “automatic” because in each case the DHCP server assigns an address with no extra intervention needed. The only difference between them is in how long the IP address is leased; in other words, whether a client’s address varies over time.

Available servers

Ubuntu makes two DHCP servers available:

  • isc-dhcp-server :
    This server installs dhcpd , the dynamic host configuration protocol daemon. Although Ubuntu still supports isc-dhcp-server , this software is no longer supported by its vendor. Find out how to install and configure isc-dhcp-server .
  • isc-kea :
    Kea was created by ISC to replace isc-dhcp-server – It is supported in Ubuntu releases from 23.04 onwards. Find out how to install and configure isc-kea .

References

  • The isc-dhcp-server Ubuntu Wiki page has more information.
  • For more /etc/dhcp/dhcpd.conf options see the dhcpd.conf man page.
  • ISC dhcp-server
  • ISC Kea Documentation

Источник

Dynamic Host Configuration Protocol (DHCP)

The Dynamic Host Configuration Protocol (DHCP) is a network service that enables host computers to be automatically assigned settings from a server as opposed to manually configuring each network host. Computers configured to be DHCP clients have no control over the settings they receive from the DHCP server, and the configuration is transparent to the computer’s user.

note: this package was called dhcp3-server in versions prior to precise 12.04 LTS.

Читайте также:  Воспроизведение h 264 linux

Installation

At a terminal prompt, enter the following command to install dhcpd:

sudo apt-get install isc-dhcp-server

You will probably need to change the default configuration by editing /etc/dhcp3/dhcpd.conf to suit your needs and particular configuration.

You also need to edit /etc/default/isc-dhcp-server to specify the interfaces dhcpd should listen to. By default it listens to eth0.

Also, you have to assign a static ip to the interface that you will use for dhcp. If you will use eth0 for providing addresses in the 192.168.1.x subnet then you should assign for instance ip 192.168.1.1 to the eth0 interface using NetworkManager. Without this step you will get an error from dhcpd when starting the service.

Configuration

The error message the installation ends with might be a little confusing, but the following steps will help you configure the service:

Most commonly, what you want to do is assign an IP address randomly. This can be done with settings as follows:

# Sample /etc/dhcpd.conf # (add your comments here) default-lease-time 600; max-lease-time 7200; option subnet-mask 255.255.255.0; option broadcast-address 192.168.1.255; option routers 192.168.1.254; option domain-name-servers 192.168.1.1, 192.168.1.2; option domain-name "mydomain.example"; subnet 192.168.1.0 netmask 255.255.255.0 range 192.168.1.10 192.168.1.100; range 192.168.1.150 192.168.1.200; >

This will result in the DHCP server giving a client an IP address from the range 192.168.1.10-192.168.1.100 or 192.168.1.150-192.168.1.200. It will lease an IP address for 600 seconds if the client doesn’t ask for a specific time frame. Otherwise the maximum (allowed) lease will be 7200 seconds. The server will also «advise» the client that it should use 255.255.255.0 as its subnet mask, 192.168.1.255 as its broadcast address, 192.168.1.254 as the router/gateway and 192.168.1.1 and 192.168.1.2 as its DNS servers.

If you need to specify a WINS server for your Windows clients, you will need to include the netbios-name-servers option, e.g.

option netbios-name-servers 192.168.1.1;

Start and stop service

sudo service isc-dhcp-server restart sudo service isc-dhcp-server start sudo service isc-dhcp-server stop

dhcp3-server and multiple interfaces

Источник

Читайте также:  Kyocera драйвер для linux

Установка и базовая настройка DHCP сервера на Ubuntu

Обновлено и опубликовано

Опубликовано: 12.03.2023

Установка и настройка

Сервер DHCP в Ubuntu может быть реализован с помощью пакета isc-dhcp-server. Его можно установить из стандартных репозиториев системы. Выполняем обновления кэша пакетов и установку:

subnet 192.168.0.0 netmask 255.255.255.0 <
range 192.168.0.100 192.168.0.200;
option domain-name-servers 192.168.0.10, 192.168.0.11;
option domain-name «dmosk.local»;
option routers 192.168.0.1;
option broadcast-address 192.168.0.255;
default-lease-time 600;
max-lease-time 7200;
>

  • subnet — сеть, для которой будет работать данная группа настроек.
  • range — диапазон, из которого будут браться IP-адреса.
  • option domain-name-servers — через запятую перечисленные DNS-сервера.
  • option domain-name — суффикс доменного имени.
  • option routers — шлюз по умолчанию.
  • option broadcast-address — адрес сети для широковещательных запросов.
  • default-lease-time и max-lease-time — время и максимальное время в секундах, на которое клиент получит адрес, по его истечению будет выполнено продление срока.

Проверить корректность конфигурационного файла можно командой:

dhcpd -t -cf /etc/dhcp/dhcpd.conf

Разрешаем автозапуск сервиса:

systemctl enable isc-dhcp-server

systemctl restart isc-dhcp-server

Добавляем правило в firewall:

iptables -I INPUT -p udp —dport 67 -j ACCEPT

Возможные проблемы

Not configured to listen on any interfaces!

Сервис dhcp не запускается, а в логе можно увидеть ошибки, на подобие:

No subnet declaration for ens18 (192.168.1.10).
.
** Ignoring requests on ens18. If this is not what
you want, please write a subnet declaration
in your dhcpd.conf file for the network segment
to which interface ens18 is attached. **
.
Not configured to listen on any interfaces

Причина: в конфигурационном файле описана подсеть, которая не настроена ни на одном из сетевых интерфейсов сервера.

Решение: конфигурация subnet должна включать только те подсети, в которых настроен сам сервер DHCP. Посмотреть сетевые настройки можно командой:

После чего необходимо проверить настройки в конфигурационном файле сервера dhcp.

Читайте также

Другие инструкции, связанные с DHCP:

Источник

Оцените статью
Adblock
detector