歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> Linux資訊 >> 更多Linux

為兩個網段安裝DHCP服務器

我的電腦連接兩個網段(eth0:192.168.123.0/24,eth1:192.168.18.0/24),系統中redhat 9,本文將把本機安裝成兩個網段DHCP服務器,僅作測試用……

1.下載 DHCP 3.0.3  點擊下載

2.解壓:

[root@Crazy bak]# tar zxvf dhcp-3.0.3.tar.gzdhcp-3.0.3dhcp-3.0.3/client......[root@Crazy bak]# cd dhcp-3.0.3[root@Crazy dhcp-3.0.3]# lsclient  configure  dhcpctl  dst       LICENSE   Makefile.conf  minires  README  RELNOTES  site.confcommon  contrib    doc      includes  Makefile  Makefile.dist  omapip   relay   server    tests

3.安裝:

[root@Crazy dhcp-3.0.3]# ./configureSystem Type: Linux-2.2......[root@Crazy dhcp-3.0.3]# make;make install

4.編輯/etc/dhcpd.conf(需手動創建)

root@Crazy etc]# vi dhcpd.conf

#全局設置default-lease-time 259200;max-lease-time     518400;option domain-name-servers 202.96.134.133,202.96.128.68;ddns-update-style ad-hoc;

#192.168.18.0/24網段,分配IP為:192.168.18.200-192.168.18.250subnet 192.168.18.0 netmask 255.255.255.0{range 192.168.18.200 192.168.18.250;option subnet-mask 255.255.255.0;option broadcast-address 192.168.18.255;option routers 192.168.18.1;}

#192.168.123.0/24網段,分配IP為:192.168.123.200-192.168.123.250 subnet 192.168.123.0 netmask 255.255.255.0 {range 192.168.123.200 192.168.123.250;option subnet-mask 255.255.255.0;option broadcast-address 192.168.123.255;option routers 192.168.123.254;}#為網卡MAC為00:11:5B:10:24:9B分配一靜態IP:192.168.18.251,做測試用host crazy{hardware ethernet 00:11:5B:10:24:9B;fixed-address 192.168.18.251;option subnet-mask 255.255.255.0;option broadcast-address 192.168.18.255;option routers 192.168.18.1;}

5.試啟動DHCP(默認啟動程序為/usr/sbin/dhcpd)

[root@Crazy sbin]# dhcpdInternet Systems Consortium DHCP Server V3.0.3Copyright 2004-2005 Internet Systems Consortium.All rights reserved.For info, please visit http://www.isc.org/sw/dhcp/Can't open lease database /var/state/dhcp/dhcpd.leases: No sUCh file or Directory --  check for failed database rewrite attempt!Please read the dhcpd.leases manual page if youdon't know what to do about this. If you did not get this software from FTP.isc.org, pleaseget the latest from ftp.isc.org and install that beforerequesting help. If you did get this software from ftp.isc.org and have notyet read the README, please read it before requesting help.If you intend to request help from the [email protected] list, please read the section on the README aboutsubmitting bug reports and requests for help. Please do not under any circumstances send requests forhelp directly to the authors of this software - pleasesend them to the appropriate mailing list as described inthe README file. exiting.




#啟動出錯,根據出錯信息,Can't open lease database /var/state/dhcp/dhcpd.leases: No such file or directory --#  check for failed database rewrite attempt!,建立/var/state/dhcp/dhcpd.leases

6.調試

[root@Crazy root]# touch /var/state/dhcp/dhcpd.leases

7.再啟動DHCP

[root@Crazy sbin]# dhcpdInternet Systems Consortium DHCP Server V3.0.3Copyright 2004-2005 Internet Systems Consortium.All rights reserved.For info, please visit http://www.isc.org/sw/dhcp/Wrote 0 leases to leases file.Listening on LPF/eth1/00:0f:3d:81:81:23/192.168.18/24Sending on   LPF/eth1/00:0f:3d:81:81:23/192.168.18/24Listening on LPF/eth0/00:11:2f:81:ea:28/192.168.123/24Sending on   LPF/eth0/00:11:2f:81:ea:28/192.168.123/24Sending on   Socket/fallback/fallback-net

#OK,如出現上面的信息,DHCP應該就已經正常啟動了,可以通過以下命令查看是否已啟動DHCP

[root@Crazy sbin]# netstat -utlnActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address           Foreign Address         Statetcp        0      0 0.0.0.0:32768           0.0.0.0:*               LISTENtcp        0      0 127.0.0.1:32769         0.0.0.0:*               LISTENtcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTENtcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTENtcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTENtcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTENtcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTENtcp        0      0 0.0.0.0:23              0.0.0.0:*               LISTENudp        0      0 0.0.0.0:32768           0.0.0.0:*udp        0      0 0.0.0.0:517             0.0.0.0:*udp        0      0 0.0.0.0:825             0.0.0.0:*udp        0      0 0.0.0.0:67              0.0.0.0:*udp        0      0 0.0.0.0:111             0.0.0.0:*udp        0      0 0.0.0.0:631             0.0.0.0:*#上面信息中的67就是DHCP所用端口,一切OK了



8.客戶端進行測試(均為win2k的系統,IP設為自動)

#以下是192.168.18.0/24的測試信息

Ethernet adapter 本地連接:

        Connection-specific DNS Suffix  . :

        Description . . . . . . . . . . . : Realtek RTL8139 Family PCI Fast Ethernet NIC

        Physical Address. . . . . . . . . : 00-11-5B-10-24-9B

        Dhcp Enabled. . . . . . . . . . . : Yes

        Autoconfiguration Enabled . . . . : Yes

        IP Address. . . . . . . . . . . . : 192.168.18.250

#注意,此時IP為192.168.18.250,是因為在/etc/dhcpd.conf中沒還沒加入最後一段

        Subnet Mask . . . . . . . . . . . : 255.255.255.0

        Default Gateway . . . . . . . . . : 192.168.18.1

        DHCP Server . . . . . . . . . . . : 192.168.18.168

        DNS Servers . . . . . . . . . . . : 202.96.134.133

                                            202.96.128.68

        Lease OBTained. . . . . . . . . . : 2005年9月13日 15:42:39

        Lease EXPires . . . . . . . . . . : 2005年9月16日 15:42:39

#以下是192.168.123.0/24的測試信息

Ethernet adapter 本地連接:

  Connection-specific DNS Suffix  . :  Description . . . . . . . . . . . : Realtek RTL8139(A) PCI Fast Ethernet Adapter #2 Physical Address. . . . . . . . . : 00-E0-4C-73-50-1B    DHCP Enabled. . . . . . . . . . . : Yes    Autoconfiguration Enabled . . . . : Yes    IP Address. . . . . . . . . . . . : 192.168.123.249    Subnet Mask . . . . . . . . . . . : 255.255.255.0    Default Gateway . . . . . . . . . : 192.168.123.254    DHCP Server . . . . . . . . . . . : 192.168.123.168    DNS Servers . . . . . . . . . . . : 202.96.134.133                                     202.96.128.68 Lease Obtained. . . . . . . . . . : 2005年9月13日 15:53:28    Lease Expires . . . . . . . . . . : 2005年9月16日 15:53:28



9.完成



9.完成



Copyright © Linux教程網 All Rights Reserved