Ubuntu DHCP服务器的配置文件通常位于/etc/dhcp/dhcpd.conf。这个文件用于定义DHCP服务器的行为,包括分配IP地址的范围、租期、网关、DNS服务器等信息。下面是对该配置文件的一些基本解析:
default-lease-time 600; # 默认租期为600秒
max-lease-time 7200; # 最大租期为7200秒
option subnet-mask 255.255.255.0; # 子网掩码
option routers 192.168.1.1; # 网关地址
option domain-name-servers 8.8.8.8, 8.8.4.4; # DNS服务器地址
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.100; # 分配IP地址的范围
option broadcast-address 192.168.1.255; # 广播地址
option domain-name "example.com"; # 域名
}
host声明。host specific-host {
hardware ethernet 00:11:22:33:44:55; # MAC地址
fixed-address 192.168.1.20; # 固定IP地址
}
option time-offset(时间偏移量)、option ntp-servers(NTP服务器地址)等。option time-offset -18000; # 时间偏移量(以秒为单位)
option ntp-servers 192.168.1.101; # NTP服务器地址
log-facility local7;
include指令包含其他配置文件。include "/etc/dhcp/dhcpd.conf.example";
请注意,这只是一个简单的示例,实际的配置可能会根据你的网络环境和需求而有所不同。在修改配置文件之前,请确保备份原始文件,以便在出现问题时可以恢复。