网站首页 > 服务器教程 > linux服务器 > Linux架设DHCP服务器的方法

Linux架设DHCP服务器的方法

  • 作者:互联网
  • 时间:2009-06-04 17:57:20

1、OS系统版本

[root@server ~]# more /etc/redhat-release

Red Hat Enterprise Linux AS release 4 (Nahant Update 4)


2、查看系统是否已经安装DHCP服务端软件

[root@server ~]# rpm -qa | grep dhcp

dh***6_client-0.10-14_EL4


3、将光盘mount上去,然后安装DHCP服务端软件

[root@server ~]# mount /media/cdrom

mount: block device /dev/hdc is write-protected, mounting read-only

[root@server RPMS]# find /media/cdrom -name "dhcp*"

/m***a/cdrom/RedHat/RPMS/dhcpv6-0.10-14_EL4.i386.rpm

/media/cdrom/RedHat/RPMS/dh***6_client-0.10-14_EL4.i386.rpm

/m***a/cdrom/RedHat/RPMS/dh***3.0.1-58.EL4.i386.rpm

/m***a/cdrom/RedHat/RPMS/dhcp-devel-3.0.1-58.EL4.i386.rpm

[root@server RPMS]# rpm -ivh /m***a/cdrom/RedHat/RPMS/dh***3.0.1-58.EL4.i386.rpm

[root@server RPMS]# rpm -qa | grep dhcp

dh***3.0.1-58.EL4

dh***6_client-0.10-14_EL4


到这儿已经安装成功了,哈哈


4、查看一下,都有那些文件

[root@server RPMS]# rpm -ql grep dhcp

...

/e***dhcpd.conf ----------------------------dhcp配置文件

/e***rc.d/init.d/dhcpd

/e***rc.d/init.d/dhcrelay

/etc/sysconfig/dhcpd

/etc/sysconfig/dhcrelay

/usr/bin/omshell

/usr/sbin/dhcpd

/usr/sbin/dhcrelay

/u***share/doc/dhcp-3.0.1

/u***share/doc/dhcp-3.0.1/README

/u***share/doc/dhcp-3.0.1/RELNOTES

/u***share/doc/dhcp-3.0.1/dhcpd.conf.sample-----dhcp配置文件的模板

/u***share/man/man1/omshell.1.gz

/u***share/man/man5/dhcp-eval.5.gz

/u***share/man/man5/dhcpd.conf.5.gz

/u***share/man/man5/dhcpd.leases.5.gz

/u***share/man/man8/dhcpd.8.gz

/u***share/man/man8/dhcrelay.8.gz

/var/lib/dhcp

/v***lib/dhcp/dhcpd.leases -----------------分配IP的那个日志文件


5、[root@server RPMS]# more /e***dhcpd.conf

这儿有没有什么东东的,还是把模板文件COPY过来吧

[root@server RPMS]# cp /u***share/doc/dhcp-3.0.1/dhcpd.conf.sample /e***dhcpd.conf


6、查看配置文件,并根据自己的要求更改

[root@server RPMS]# more /e***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 "do***n.org";

option domain-name "wi***m.com.cn";

option domain-name-servers 219.141.136.10,211.147.6.3;

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 ma***n.redhat.com;

hardware ethernet 12:34:56:78:AB:CD;

fixed-address 207.175.42.254;

}

}


上面都已经很明了,该配置的都配置了


7、启动DHCP服务器啦

[root@server RPMS]# service dhcpd start

Starting dhcpd: [ OK ]


8、查看日志,看看是否有错

[root@server RPMS]# tail -20 /var/log/messages

Dec 9 18:05:19 server dhcpd: Wrote 0 deleted host decls to leases file.

Dec 9 18:05:19 server dhcpd: Wrote 0 new dynamic host decls to leases file.

Dec 9 18:05:19 server dhcpd: Wrote 0 leases to leases file.

Dec 9 18:05:19 server dhcpd: Internet Systems Consortium DHCP Server V3.0.1

Dec 9 18:05:19 server dhcpd:

Dec 9 18:05:19 server dhcpd: Copyright 2004 Internet Systems Consortium.

Dec 9 18:05:19 server dhcpd: All rights reserved.

Dec 9 18:05:19 server dhcpd: For info, please visit http://www.isc.org/sw/dhcp/

Dec 9 18:05:19 server dhcpd: Wrote 0 deleted host decls to leases file.

Dec 9 18:05:19 server dhcpd: Wrote 0 new dynamic host decls to leases file.

Dec 9 18:05:19 server dhcpd: Listening on LP***th0/00:0c:29:c5:06:fc/192.168.0/24

Dec 9 18:05:19 server dhcpd: Wrote 0 leases to leases file.

Dec 9 18:05:19 server dhcpd: Listening on LP***th0/00:0c:29:c5:06:fc/192.168.0/24

Dec 9 18:05:19 server dhcpd: Sending on LP***th0/00:0c:29:c5:06:fc/192.168.0/24

Dec 9 18:05:19 server dhcpd: Sending on LP***th0/00:0c:29:c5:06:fc/192.168.0/24

Dec 9 18:05:19 server dhcpd:

Dec 9 18:05:19 server dhcpd: Sending on Socket/fallback/fallback-net

Dec 9 18:05:19 server dhcpd: Sending on Socket/fallback/fallback-net

Dec 9 18:05:19 server dhcpd:

Dec 9 18:05:20 server dhcpd: dhcpd startup succeeded