RedHat6.2簡單配置dhcp

靜以致遠√團團發表於2013-12-10

我的環境:

兩臺RedHat6.2,其中192.168.16.11作測試,192.168.16.12dhcp伺服器

dhcp版本:dhcp-4.1.1-25.P1.el6.i686

 

實驗步驟:

1、由於映象已複製到伺服器端,直接在伺服器端搭建本地yum源:

[root@redhat6-2 dhcp]# vi /etc/yum.repos.d/rhel-source.repo 

[my-yum]

name=Red Hat Enterprise 6.2

baseurl=file:///var/ftp/pub/Server

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

2、使用yum update更新yum源:

3、使用yum install dhcp-* 安裝dhcp

Running Transaction

  Installing : 12:dhcp-4.1.1-25.P1.el6.i686               1/1 

Installed products updated.

Installed:

  dhcp.i686 12:4.1.1-25.P1.el6                                

Complete!

4、手動寫dhcp的配置檔案:

[root@redhat6-1 ~]# vi /etc/dhcp/dhcpd.conf 

也可直接copy模板,修改一下即可:

[root@redhat6-1 ~]# cp -rf  /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample  /etc/dhcp/dhcpd.conf

 

配置檔案內容如下:關鍵內容已標出

ddns-update-style interim;       支援DDNS

ignore client-updates;           忽略DDNS更新

subnet 192.168.16.0 netmask 255.255.255.0 {                    宣告作用域

# --- default gateway

        option routers                  192.168.16.1;            閘道器

        option subnet-mask              255.255.255.0;          掩碼

 

        option nis-domain               "domain.org";           NIS

        option domain-name              "domain.org";          DHCP名字

        option domain-name-servers      10.37.16.1;            給客戶機分配的DNS

 

        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 fantasia.fugue.com;

        }

}

5、儲存退出,重啟一下dhcp服務:service dhcpd restart

 

6、修改測試端的IP設定為dhcp獲取

[root@redhat6-1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1

加入BOOTPROTO=dhcp即可

DEVICE="eth1"

HWADDR="00:0C:29:19:FB:ED"

NM_CONTROLLEiD="no"

ONBOOT="yes"

BOOTPROTO=dhcp

IPADDR=192.168.16.11

NETMASK=255.255.255.0

7、測試端(原本IP192.168.16.11)輸入dhclient

 

由於dhcp重新獲取ipip地址已改變

8、進入虛擬機器檢視IP是否發生了變化,IP是否是從dhcp伺服器端獲得

 

ip地址果然發生變化,服務端檢視ip資源分配情況

[root@redhat6-2 dhcp]# cat /var/lib/dhcpd/dhcpd.leases

# The format of this file is documented in the dhcpd.leases(5) manual page.

# This lease file was written by isc-dhcp-4.1.1-P1

 

lease 192.168.16.128 {

  starts 2 2013/12/10 10:50:51;

  ends 2 2013/12/10 16:50:51;

  tstp 2 2013/12/10 16:50:51;

  cltt 2 2013/12/10 10:50:51;

  binding state active;

  next binding state free;

  hardware ethernet 00:0c:29:19:fb:ed;

}

 

192.168.16.128分配給了00:0c:29:19:fb:ed,完全一致,dhcp配置成功!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29320885/viewspace-1062880/,如需轉載,請註明出處,否則將追究法律責任。

相關文章