第一步: cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
第二步: 改成自己网卡所在的网段.
第三步: service dhcpd start
成功! 验证也成功
原理:linux的DHCP服务是一个修改配置文件的服务,此配置文件的范本在/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample
只要拷贝一下到/etc配置目录下就可启动.由于DHCP 能识别自己网段(也就是要跨网段的 话要用到DHCP中继)
查看租约:cat /var/lib/dhcpd/dhcpd.leases
复制配置文件
cp /usr/share/doc/dhcp-3.05/dhcpd.conf.sample /etc/dhcpd.conf
vi /etc/dhcpd.conf
①修改子网subnet、子网掩码netmask、路由routers、dns服务器
②可分配地址段
③租约
④为指定的计算机保留IP
[root@localhost ~]# cat /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.99.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.99.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.99.1;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 192.168.99.128 192.168.99.254;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
}
[root@localhost ~]#
来源:https://www.cnblogs.com/cyj123/archive/2013/06/06/3121095.html