A small instruction for installing and configuring caching DNS, DHCP and TFTP in the Dnsmasq server.
Dnsmasq It is lightweight and fast-configurable. DNS, DHCP A TFTP server designed to provide domain names and related services to small networks. It can provide names to local machines that do not have global DNS records. The DHCP server is integrated with the DNS server and gives machines with an IP address a domain name configured earlier in the configuration file. Supports IP-address binding to a computer or automatic configuring of IP-addresses from a given range and BOOTP for network loading of diskless machines.
Install dnsmasq in Debian by executing the command:
aptitude install dnsmasq
Install dnsmasq in CentOS by executing the command:
yum install dnsmasq
Install dnsmasq in OpenWRT by executing the command:
opkg install dnsmasq
Below is a configuration file with comments and examples on setting up for 3 LANs, specifying the internal DNS servers and indicating both the individual TFTP server and setting up the built-in TFTP server in DNSMASQ.
This configuration file does not claim to be a complete overview of all server parameters, but claims full performance in the current configuration:
vi /etc/dnsmasq.conf # Перебирать DNS сервера из файла /etc/resolv.conf в том порядке как они указаны strict-order pid-file=/var/run/dnsmasq/dnsmasq.pid # Настройка DNS сервера # Если у Вас уже настроен DNS сервер, нужно отключить DNS сервер в dnsmasq, # необходимо раскоментировать port=0 и закоментировать запросы DNS на server.loc и home.loc #port=0 # Указываем отправлять все запросы DNS на server.loc на внутренний сервер в локальной сети: domain=server.loc server=/server.loc/192.168.1.10 server=/1.168.192.in-addr.arpa/192.168.1.10 # Указываем отправлять все запросы DNS на home.loc на внутренний сервер в локальной сети: domain=home.loc server=/home.loc/192.168.2.10 server=/2.168.192.in-addr.arpa/192.168.2.10 # Настройки DHCP сервера no-dhcp-interface=eth0 # Provider # Работать только на интерфейсах: interface=eth2 # Localnet 192.168.0.0/24 interface=eth3 # Localnet 192.168.1.0/24 interface=eth4 # Localnet 192.168.2.0/24 # Указываем отдельный TFTP сервер в нашей локальной сети dhcp-option=eth2,66,192.168.0.10 dhcp-option=eth3,66,192.168.1.10 dhcp-option=eth4,66,192.168.2.10 # Поднимем TFTP сервер встроенный в dnsmasq сервер, если используется встроенный, # соответственно сменим и адрес в конфиге выше на адрес dnsmasq сервера # cjplfnm папку для файлов tftp сервера: mkdir -p /home/tftp enable-tftp tftp-root=/home/tftp # Динамическая аренда адресов, срок аренды на 7 дней для Localnet 192.168.0.0/24: dhcp-range=eth2,192.168.0.100,192.168.0.229,255.255.255.0,7D # Указываем по умолчанию шлюз dhcp сервера: dhcp-option=eth2,3,192.168.0.1 # Динамическая аренда адресов, срок аренды на 7 дней для Localnet 192.168.1.0/24: dhcp-range=eth3,192.168.1.100,192.168.1.229,255.255.255.0,7D # Указываем по умолчанию шлюз dhcp сервера: dhcp-option=eth3,3,192.168.1.1 # Динамическая аренда адресов, срок аренды на 7 дней для Localnet 192.168.2.0/24: dhcp-range=eth4,192.168.2.100,192.168.2.229,255.255.255.0,7D # Указываем по умолчанию шлюз dhcp сервера: dhcp-option=eth4,3,192.168.2.1 # Указываем нужные DNS серверов для каждой сети: dhcp-option=eth2,6,192.168.0.1,8.8.8.8 # Localnet 192.168.0.0/24 dhcp-option=eth3,6,192.168.1.1,8.8.4.4 # Localnet 192.168.1.0/24 dhcp-option=eth4,6,192.168.2.1,8.8.8.8 # Localnet 192.168.2.0/24 # расположение файла аренды адресов, можно в нем увидеть какой компьютер получил какой IP dhcp-leasefile=/var/lib/misc/dnsmasq.leases # Если нужно записывать отладочную информацию, раскоментировать: #log-dhcp dhcp-authoritative # Привязка компьютера по MAC адресу на определенный IP по примеру: # dhcp-host=11:22:33:44:55:66,foo,192.168.0.10 # где foo - имя компьютера, можно не указывать # Принтера, изменить данные на свои и раскоментировать: #dhcp-host=00:00:47:3c:28:1e,192.168.0.10 # принтер сети Localnet 192.168.0.0/24 #dhcp-host=00:e3:35:09:b1:8e,192.168.1.10 # принтер сети Localnet 192.168.1.0/24
If you configure the built-in TFTP server in dnsmasq, to verify it, we will create a file in the server folder and download it pre-installed tftp client.
Install tftp client by executing the command:
aptitude install -y tftp
Create a test file in text 777 to the tftp folder of the server by executing the command:
echo 777 > /home/tftp/test
Download the created file to check the operability of the tftp server by executing the command by substituting the IP of your dnsmasq server:
echo get test | tftp 192.168.1.1
Check that the file that we previously created is downloaded by executing the command:
cat test 777
Services configured in the dnsmasq server work as expected, the task is completed.
I was with you. Sergey Lazarenko.
Let’s take a short break and watch a useful video with details about DDOSS:



comment