LINUX DHCP學習

LINUX DHCP輕巧,也比較簡單

1.安裝:

[root@localhost dhcp]# rpm -q dhcp  //查詢是否安裝
dhcp-3.0.5-21.el5
[root@localhost dhcp]# rpm -ivh dhcp-3.0.5-21.el5.x86_64.rpm //安裝DHCP


2.dhcp配置文件

默認爲/etc/dhcpd.conf

例子文件爲:/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample:

[root@localhost dhcp-3.0.5]# more dhcpd.conf.sample 
ddns-update-style interim;
ignore client-updates;


subnet 192.168.0.0 netmask 255.255.255.0 {  //如果非relay方式,這個subnet一定要包括server的本地IP的在內.否則服務啓動不了.


# --- default gateway
        option routers                  192.168.0.1;                     
        option subnet-mask              255.255.255.0;


        option nis-domain               "domain.org";
        option domain-name              "domain.org";
        option domain-name-servers      192.168.1.1;  


        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 marvin.redhat.com;
                hardware ethernet 12:34:56:78:AB:CD;
                fixed-address 207.175.42.254;
        }
}

可將該文件複製到/etc/dhcpd.conf,然後進行修改

3.中繼

dhcrelay *.*.*.*

或者編輯/etc/sysconfig/dhcrelay配置文件

4.服務啓停

/etc/init.d/dhcpd start

/etc/init.d/dhcpd stop

/etc/init.d/dhcpd restart

/etc/init.d/dhcpd status //查看服務狀態


或者 services dhcpd restart

5.ntsysv將DHCP設置爲開機啓動

6.服務器日誌從/var/log/messages中查到,租賃信息也可從這裏查到

7.租約信息從/var/lib/dhcp/dhcpd.leases看到

8.如果測試Linux客戶端是否可以獲取地址,則編輯/etc/sysconfig/network-scripts/ifcfg-eth0 

BTTOPROTO=dhcp



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章