LINUX DHCP轻巧,也比较简单
1.安装:
[root@localhost dhcp]# rpm -q dhcp //查询是否安装
dhcp-3.0.5-21.el5
[root@localhost dhcp]# rpm -ivh dhcp-3.0.5-21.el5.x86_64.rpm //安装DHCP
2.dhcp配置文件
默认为/etc/dhcpd.conf
例子文件为:/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample:
[root@localhost dhcp-3.0.5]# more dhcpd.conf.sample
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 { //如果非relay方式,这个subnet一定要包括server的本地IP的在内.否则服务启动不了.
# --- default gateway
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.1.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.0.128 192.168.0.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;
}
}
可将该文件复制到/etc/dhcpd.conf,然后进行修改
3.中继
dhcrelay *.*.*.*
或者编辑/etc/sysconfig/dhcrelay配置文件
4.服务启停
/etc/init.d/dhcpd start
/etc/init.d/dhcpd stop
/etc/init.d/dhcpd restart
/etc/init.d/dhcpd status //查看服务状态
或者 services dhcpd restart
5.ntsysv将DHCP设置为开机启动
6.服务器日志从/var/log/messages中查到,租赁信息也可从这里查到
7.租约信息从/var/lib/dhcp/dhcpd.leases看到
8.如果测试Linux客户端是否可以获取地址,则编辑/etc/sysconfig/network-scripts/ifcfg-eth0
BTTOPROTO=dhcp