1. 程式人生 > >Linux下DHCP伺服器配置 (二)

Linux下DHCP伺服器配置 (二)

A、簡介
 
A.1、DHCP
 
DHCP:動態主機設定協議(Dynamic Host Configuration Protocol)是一個區域網的網路協議,使用UDP協議工作,主要有兩個用途:給內部網路或網路服務供應商自動分配IP地址給使用者給內部網路管理員作為對所有計算機作中央管理的手段。
 
A.2、DDNS
 
DDNS(Dynamic Domain Name Server)是動態域名服務的縮寫!DDNS是將使用者的動態IP地址對映到一個固定的域名解析服務上,使用者每次連線網路的時候客戶端程式就會通過資訊傳遞把該主機的動態IP地址傳送給位於服務商主機上的伺服器程式,伺服器程式負責提供DNS服務並實現動態域名解析。就是說DDNS捕獲使用者每次變化的IP 地址,然後將其與域名相對應,這樣其他上網使用者就可以通過域名來進行交流。
 
 
B、安裝和配置
 
B.1、安裝DHCP
 
yum –y install dhcp
 
B.2、配置DHCP
 
DHCP配置檔案為/etc/dhcpd.conf,但該檔案預設是沒有內容的,可以從dhcp安裝目錄複製一個到/etc下。
 
cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
 
vi /etc/dhcpd.conf
 
B.2.1、配置/etc/dhcpd.conf
 
ddns-update-style none;
 
#不要更新DDNS的設定
 
ignore client-updates;
 
 
 
subnet 192.168.0.0 netmask 255.255.255.0 {
 
        option routers                  192.168.0.1;
 
                                                                                              # --- default gateway
 
                                                                                              #閘道器
 
        option subnet-mask              255.255.255.0;
 
                                                                                              #子網掩碼
 
        option nis-domain               "domain.org";
 
        option domain-name              "domain.org";
 
                                                                                              #域名
 
        option domain-name-servers      202.96.209.133,116.228.111.18;
 
                                                                                              #域名伺服器地址
 
        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
 
                                                                                              #選擇點對點節點(預設為混合)。不要改變它,除非你非常瞭解Netbios。
 
                                                                                              # option netbios-node-type 2;
 
 
 
        range dynamic-bootp 192.168.0.128 192.168.0.254;
 
                                                                                              #提供的IP地址端
 
        default-lease-time 21600;
 
                                                                                              #預設租期
 
        max-lease-time 43200;
 
                                                                                              #最大租期
 
 
 
        # we want the nameserver to appear at a fixed address
 
                   #以下內容為特定機器保留IP
 
        host ns {
 
                next-server marvin.RedHat.com;
 
                hardware ethernet 12:34:56:78:AB:CD;
 
                fixed-address 207.175.42.254;
 
        }
 
}
 
B.2.2、配置/etc/sysconfig/dhcpd
 
                                                     # Command line options here
 
DHCPDARGS=eth0
 
B.3、啟動DHCP
 
service dhcpd start
 
                                                     #啟動DHCP服務
 
chkconfig dhcpd on
 
                                                     #讓DHCP服務隨系統而啟動