(三)跟我一起玩Linux網絡服務:DHCP服務配置之主服務器配置


我們今天來做DHCP服務器的配置,我們的前提示要實現用一台虛擬機做DHCP服務器

 

1.首先,我們要有DHCP軟件,我們用到下面兩個軟件(可以使用其他方法從網上直接安裝,具體方法網絡搜索)

dhcp-3.0pl1-23.i386.rpm

dhcp-devel-3.0pl1-23.i386.rpm

下載后,安裝

# rpm -ivh /home/yanji/dhcp*.rpm

2.我們更新一下搜索的數據內容,查找我們的主配置文件

# updatedb
# locate dhcpd.conf
/etc/log.d/conf/services/dhcpd.conf
/usr/share/doc/dhcp-3.0pl1/dhcpd.conf.sample
/usr/share/man/man5/dhcpd.conf.5.gz

我們不難發現有一個文件是dhcpd.conf.sample,這個文件是我們最重要的切入點。

接下來使用下面的命令在目的目錄下新建/etc/dhcpd.conf文件,是DHCP的配置文件

# cp /usr/share/doc/dhcp-3.0pl1/dhcpd.conf.sample /etc/dhcpd.conf

3.下面我們就修改這個DHCP配置文件

說明:

名稱 解釋
subnet 指定子網作用域
option routers 網關
option subnet-mask 網關子網掩碼

option domain-name

option domain-name-servers

DNS,設置的域名和域名服務器的IP
option time-offset

時區時間

range dynamic-BOOTP 設置DHCP的地址池
default-lease-time

默認租約時間

max-lease-time 最大租約時間
host 設置保留主機名,即相當於靜態分配一個

 

 

 

 

 

 

 

 

 

 

 

 

 

下面是文字版的配置信息

 1 ddns-update-style interim;  2 ignore client-updates;  3 
 4 subnet 10.10.10.0 netmask 255.255.255.0 {  5 
 6 # --- default gateway  7         option routers                  10.10.10.10;  8         option subnet-mask              255.255.255.0;  9 
10         option domain-name              "ns.gr.org"; 11         option domain-name-servers      10.10.10.10; 12 
13         option time-offset              28800; 14 #       option ntp-servers              192.168.1.1; 15 #       option netbios-name-servers     192.168.1.1; 16 # --- Selects point-to-point node (default is hybrid). Don't change this unless
17 # -- you understand Netbios very well 18 #       option netbios-node-type 2; 19 
20         range dynamic-bootp 10.10.10.100 10.10.10.200; 21         default-lease-time 21600; 22         max-lease-time 43200; 23 
24         # we want the nameserver to appear at a fixed address 25  host boss { 26                 next-server marvin.redhat.com; 27                 hardware ethernet 12:34:56:78:AB:CD; 28                 fixed-address 207.175.42.188; 29  } 30 }

4.配置完上面的內容后,我們重啟一下DHCP服務
# service dhcpd start

查看守護進程(/usr/sbin/dhcpd)
# ps -ax | grep dhcpd
9782 ?        S      0:00 /usr/sbin/dhcpd
9789 pts/0    S      0:00 grep dhcpd
有顯示表示我們已經啟動了DHCP服務,那么激動的時刻來臨了
注:
5.這里我已經做了前面的幾個,所以我的當前虛擬機是使用vmNet 1,ip是10.10.10.10(前面的文章有說明)

 我們把虛擬機的DHCP獲取去掉

 再把Windows下面的網絡適配器的VMNet1設置為自動獲取

設置好之后,我們的最關鍵的都做了,看結果的時候到了,我們運行cmd,輸入 ipconfig,下面顯示的就證明我們配置成功了(我們配置的地址池最后一個是200),可以用我們的虛擬機做DHCP服務器了

 6.查看Linux下的租約文件

# cat  /var/lib/dhcp/dhcpd.leases

 1 # All times in this file are in UTC (GMT), not your local timezone.   This is
 2 # not a bug, so please don't ask about it.   There is no portable way to
 3 # store leases in the local timezone, so please don't request this as a
 4 # feature.   If this is inconvenient or confusing to you, we sincerely
 5 # apologize.   Seriously, though - don't ask.
 6 # The format of this file is documented in the dhcpd.leases(5) manual page.
 7 # This lease file was written by isc-dhcp-V3.0pl1
 8 
 9 lease 10.10.10.200 {
10   starts 1 2015/04/06 18:25:34;
11   ends 2 2015/04/07 00:25:34;
12   binding state active;
13   next binding state free;
14   hardware ethernet 00:50:56:c0:00:01;
15   uid "\001\000PV\300\000\001";
16   client-hostname "PC-20140925ISEN";
17 }

租約文件存在,我們有空的時候可以看看這個租約文件是什么內容。

 

 

 

 

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM