linux5.5配置dhcp,51CTO博客-专业IT技术博客创作平台-技术成就梦想

首先需要安装DHCP服务

[root@localhost Server]# rpm -ivh dhcp-3.0.5-31.el5_8.1.x86_64.rpm

将其设为开机启动

[root@localhost etc]# chkconfig dhcpd on

[root@localhost etc]# chkconfig --list dhcpd

dhcpd           0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭

配置文件

[root@localhost etc]# vim dhcpd.conf

ddns-update-style interim;                            动态更新类型,必须有

subnet 192.168.1.0 netmask 255.255.255.0 {            声明网段

option routers                  192.168.1.254;默认网关

option subnet-mask              255.255.255.0;子网掩码

option domain-name              "tarena.com";

option domain-name-servers      202.106.0.20,192.168.1.254;    DNS服务器

range dynamic-bootp 192.168.1.20 192.168.1.50;         IP分配范围

range dynamic-bootp 192.168.1.80 192.168.1.100;

default-lease-time 21600;                          默认租约期

max-lease-time 43200;                              最大租约期

host win7 {

hardware ethernet 00:0C:29:1D:0B:0C;为主机分配固定IP,只能用在host声明

fixed-address 192.168.1.88;         指定主机物理地址,只能用在host声明

}

host linux {

hardware ethernet 00:0C:29:C7:BB:E6;

fixed-address 192.168.1.66;

}

}

测试dhcp服务器

[root@localhost ~]# service dhcpd configtest

Syntax: OK

重启服务

[root@localhost ~]# service dhcpd restart

将客户端设为自动获取IP地址

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

BOOTPROTO=dhcp

重启客户端network,查看IP

[root@localhost ~]# service network restart

[root@localhost ~]# ifconfig

查看服务器IP分配情况(在服务器)

[root@localhost ~]# less /var/lib/dhcpd/dhcpd.leases

查看客户端已获取的IP租约

[root@localhost ~]# less /var/lib/dhclient/dhclient.leases

[root@localhost ~]# less /var/lib/dhclient/dhclient-eth0.leases

注:服务器本身必须有IP地址,IP分配范围必须在声明网段内

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值