一、安装dnsmasq服务
yum install -y dnsmasq
二、dnsmasq服务主配置文件
[root@localhost]# cp /etc/dnsmasq.conf{,.bak}
[root@localhost]# vim /etc/dnsmasq.conf
#log-dhcp #由于dhcp日志太多请慎重开启
log-queries #开启dns查询日志
log-facility=/var/log/dnsmasq.log #自定义日志文件路径
conf-dir=/etc/dnsmasq.d/,*.conf
三、在dnsmasq服务中配置dhcp
vim /etc/dnsmasq.d/dnsmasq_dhcp.conf
#配置dhcp地址池,地址租期为12小时,为dhcp地址池设置red标记(set:red)
dhcp-range=set:red,192.168.0.50,192.168.0.150,255.255.255.0,12h
#IP地址保留配置
dhcp-host=11:22:33:44:55:66,192.168.0.60
#使用文件的方式配置地址保留获取IP地址会较慢
#dhcp-host.txt文件内容为:dhcp-host=11:22:33:44:55:66,192.168.0.60
#conf-file=/etc/dnsmasq.d/dhcp-host.txt
#本地网卡和无线网卡绑定IP地址为192.168.0.60
#dhcp-host=11:22:33:44:55:66,12:34:56:78:90:12,192.168.0.60
#为打red标记的地址池配置网关
dhcp-option=tag:red,3,192.168.0.254
#为打red标记的地址池配置dns地址
dhcp-option=tag:red,option:dns-server,223.5.5.5,221.12.1.227,221.12.33.227
#为打red标记的地址池配置ntp服务器地址
dhcp-option=tag:red,option:ntp-server,192.168.0.4,10.10.0.5
#dhcp地址分配文件,用来查看IP地址的分配情况,该文件自动生成
dhcp-leasefile=/var/lib/dnsmasq/dnsmasq.leases
四、在dnsmasq服务中配置dns服务
vim /etc/dnsmasq.d/dnsmasq.conf
#指定监听的IP地址
#listen-address=127.0.0.1,10.10.10.1
#强制按照/etc/resolv.conf文件中的DNS服务器顺序进行查询
#strict-order
#不使用默认的/etc/resolv.conf文件
#no-resolv
#自定义resolv.conf文件路径
#resolv-file=
#不允许轮询或更改resolv.conf文件或其它dns服务器文件
#no-poll
#客户端请求163.com域名时使用114.114.114.114服务器响应请求
#server=/163.com/114.114.114.114
#绑定IP和域名,用法同/etc/hosts文件
#address=/double-click.net/127.0.0.1
#不读取默认的/etc/hosts文件
#no-hosts
#自定义hosts文件目录,书写格式同/etc/hosts文件
#addn-hosts=/etc/banner_add_hosts
#在eth0上关闭dhcp和tftp服务
#no-dhcp-interface=eth0
#配置一个test.com域名,客户端请求domain时分配此域名
#domain=test.com
五、tftp-server服务配置
yum install tftp-server -y #安装tftp-server服务
vim /etc/xinetd.d/tftp #开启tftp服务
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot -c
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
chown nobody.root tftpboot #tftp上传文件默认使用nobody
chmod 755 tftpboot
参考链接:
https://blog.51cto.com/longlei/2065967 #tftp-server常见错误
https://cloud.tencent.com/developer/article/1174717