您的位置:首页 > 其它

UNBUNTU 架设DHCP服务器

2012-11-29 15:53 183 查看
1 到http://www.isc.org/software/dhcp/424-p2/download/dhcp-424-p2targz 下载dhcp-4.2.4-P2.tar.gz

2 解压dhcp-4.2.4-P2.tar.gz到/usr

root@xue-desktop:/home/xue/下载# tar -zxvf dhcp-4.2.4-P2.tar.gz -C /usr

3 配置编译

root@xue-desktop:/home/xue/下载# cd /usr

root@xue-desktop:/usr# ls

adobeflash dhcp-4.2.4-P2 games java local share

bin eclipse include lib sbin src

root@xue-desktop:/usr# cd dhcp-4.2.4-P2/

root@xue-desktop:/usr/dhcp-4.2.4-P2# ./con

configure contrib/

root@xue-desktop:/usr/dhcp-4.2.4-P2# ./configure =====>>配置

root@xue-desktop:/usr/dhcp-4.2.4-P2# make

root@xue-desktop:/usr/dhcp-4.2.4-P2#
make install

root@xue-desktop:/usr/local/sbin#
cd /usr/local/sbin/

root@xue-desktop:/usr/local/sbin# ls

dhclient dhcpd dhcrelay

root@xue-desktop:/usr/local/sbin#

可以看到,程序默认应该是安装到了/usr/local/sbin目录下,里面有三个文件,分别是dhclient,dhcpd,dhcrelay,分别是客户端,服务端和中转器

4 在/etc目录下建一个dhcpd.conf文件,即ipv4配置文件

root@xue-desktop:/usr/local/sbin#
cat -n /etc/dhcpd.conf

1 ddns-update-style none;

2 ignore client-updates;

3 default-lease-time 259200; #默认租借为3天

4 max-lease-time 518400;

5 option routers 192.168.1.128;

6 option domain-name "docotr.mo";

7 option domain-name-servers 202.116.128.1, 202.116.128.2;

8

9 subnet 192.168.1.0 netmask 255.255.255.0

10 {

11 range 192.168.1.200 192.168.1.230;

12

13 host win7

14 {

15 hardware ethernet 00:30:67:3a:ca:32;

16 fixed-address 192.168.1.253;

17 }

18 }

root@xue-desktop:/usr/local/sbin#

启动服务:root@xue-desktop:/usr/local/sbin# cd /usr/local/sbin

root@xue-desktop:/usr/local/sbin# ./dhcpd

Internet Systems Consortium DHCP Server 4.2.4-P2

Copyright 2004-2012 Internet Systems Consortium.

All rights reserved.

For info, please visit https://www.isc.org/software/dhcp/
WARNING: Host declarations are global. They are not limited to the scope you declared them in.

Can't open lease database /var/db/dhcpd.leases: No such file or directory --

check for failed database rewrite attempt!

Please read the dhcpd.leases manual page if you

don't know what to do about this.

If you did not get this software from ftp.isc.org, please

get the latest from ftp.isc.org and install that before

requesting help.

If you did get this software from ftp.isc.org and have not

yet read the README, please read it before requesting help.

If you intend to request help from the dhcp-server@isc.org

mailing list, please read the section on the README about

submitting bug reports and requests for help.

Please do not under any circumstances send requests for

help directly to the authors of this software - please

send them to the appropriate mailing list as described in

the README file.

exiting.

root@xue-desktop:/usr/local/sbin#

这里上面说,找不到/var/db/dhcpd.leases
租约文件, 那就建一个吧

root@xue-desktop:/usr/local/sbin# mkdir /var/db

root@xue-desktop:/usr/local/sbin# touch /var/db/dhcpd.leases

root@xue-desktop:/usr/local/sbin#

再来启动一下:

root@xue-desktop:/usr/local/sbin# ./dhcpd

Internet Systems Consortium DHCP Server 4.2.4-P2

Copyright 2004-2012 Internet Systems Consortium.

All rights reserved.

For info, please visit https://www.isc.org/software/dhcp/
WARNING: Host declarations are global. They are not limited to the scope you declared them in.

Wrote 0 deleted host decls to leases file.

Wrote 0 new dynamic host decls to leases file.

Wrote 0 leases to leases file.

Listening on LPF/eth0/00:e0:4c:20:69:23/192.168.1.0/24

Sending on LPF/eth0/00:e0:4c:20:69:23/192.168.1.0/24

Sending on Socket/fallback/fallback-net

root@xue-desktop:/usr/local/sbin#

看到上面3行红色的就表示没错了。

来看一下服务是否启动了

root@xue-desktop:/usr/local/sbin#
netstat -tulnp | grep dhcp

udp 0 0 0.0.0.0:67 0.0.0.0:* 13904/dhcpd

udp 0 0 0.0.0.0:4079 0.0.0.0:* 13904/dhcpd

udp6 0 0 :::13072 :::* 13904/dhcpd

root@xue-desktop:/usr/local/sbin#

67
端口就是了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: