RedHat6.2简单配置dhcp

我的环境:

两台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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29320885/viewspace-1062880/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值