CentOS建立DHCP服务2——系统自带的dnsmasq
先祭出师父的不老歌:http://debugo.com/dnsmasq/
dnsmasq is a lightweight DNS, TFTP and DHCP server.
这货可以用于dns,tftp,DHCP。
配置文档位置:/etc/dnsmasq.conf
使用文档(巨特么长):See”/usr/sbin/dnsmasq –help” or “man 8 dnsmasq” for details.
Getting start
一、DHCP server的几个小配置:
1.配置监听端口(就是我从哪个网卡或者ip接受DHCP请求):
1 2 3 4 5 6 7 8 9 10 |
# If you want dnsmasq to listen for DHCP and DNS requests only on # specified interfaces (and the loopback) give the name of the # interface (eg eth0) here. # Repeat the line for more than one interface. #interface= # Or you can specify which interface _not_ to listen on #except-interface= # Or which to listen on by address (remember to include 127.0.0.1 if # you use this.) listen-address=192.168.0.101(本机IP),127.0.0.1 |
2.DHCP地址池及有效时间
1 2 3 4 5 6 |
# Uncomment this to enable the integrated DHCP server, you need # to supply the range of addresses available for lease and optionally # a lease time. If you have more than one network, you will need to # repeat this for each network on which you want to supply DHCP # service. dhcp-range=192.168.0.50,192.168.0.150,12h |
3.给MAC地址为的主机分配:IP,主机名,有效时间
1 2 3 |
# Always give the host with ethernet address 11:22:33:44:55:66 # the name fred and IP address 192.168.0.60 and lease time 45 minutes dhcp-host=11:22:33:44:55:66,fred,192.168.0.60,45m |
4.配域
1 2 3 4 5 6 7 8 |
# Set the domain for dnsmasq. this is optional, but if it is set, it # does the following things. # 1) Allows DHCP hosts to have fully qualified domain names, as long # as the domain part matches this setting. # 2) Sets the "domain" DHCP option thereby potentially setting the # domain of all systems configured by DHCP # 3) Provides the domain part for "expand-hosts" domain=thekelleys.org.uk |
二、dns server的配置
犯懒了,直接看师父的吧:
注:如果IP池里的IP被占用,或者没有可用IP,则分配IP的任何操作都不会生效。这时应该先检查IP的使用情况,而不是配置文件表述错误(毕竟有例子,书写错误的概率太低了好嘛!)
没打完,也收工了