1、先查看是否安装了DHCP
#rpm -qa | grep dhcp
2、查询dhcp配置文件模板位置,可使用下面三个命令
#rpm -ql dhcp
#rpm -qld dhcp
#rpm -qlc dhcp
3、复制配置文件模板,创建dhcpd.conf配置文件
#cp /usr/share/doc/dhcp-3.0pl2/dhcpd.conf.sample /etc/dhcpd.conf
4、修改dhcpd.conf配置文件并保存
#vi /etc/dhcpd.conf
具体修改方法,参见
#man dhcpd
5、设置网卡的IP地址为dhcp服务器的IP地址
#setup
或者
#ifconfig eth0 192.168.1.1 netmask 255.255.255.0
6、启动dhcp服务器
#service dhcpd start
或者
#/etc/init.d/dhcpd start
7、若修改了/etc/dhcpd.conf文件,则必须要重启dhcpd服务
#service dhcpd restart
8、查看dhcp是否已启用
#netstat -anu
dhcp服务器端口号是67,dhcp客户机端口号是68
9、查看出错信息
#tail /var/log/messages
#cat /var/log/messages
10、客户端获取dhcp服务器分配的IP地址,使用下面的命令
#dhclient
11、如系统中有两块网卡,可修改下面的配置文件来指定其中的一块网卡启动dhcp服务器
/etc/sysconfig/dhcpd
#e cho "DHCPDARGS=eth0" >> /etc/sysconfig/dhcpd
注:dhcp服务器只能在局域网的那块网卡启用,不能在公网的那块网卡启用dhcp服务器。
12、设置dhcp中继代理(在另外一台机器上)
#vi /etc/sysconfig/dhcrelay
INTERFACES指定接口(eth0或者eth1)
DHCPSERVERS指定dhcp服务器的IP地址
#service dhcrelay start (启动dhcp中继代理)
13、查看dhclp数据库文件
#ls /var/lib/dhcp/
14、查看dhcpd和dhclient的唯一标识号
#cat /var/run/dhcpd.pid
#cat /var/run/dhclient-eth0.pid
附上dhcpd.conf配置文件内容:
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
# --- 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 192.168.0.128 192.168.0.255;
range 192.168.0.10 192.168.0.100;
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;
}
}
--------------------next---------------------
阅读(435) | 评论(0) | 转发(0) |