Linux-DHCP服务器架设

DHCP服务器:
作用:给局域网中每台主机提供动态ip
通信方式:
Client:利用255.255.255.255广播同个DHCP客户端发送DCHP Discover包。
DHCP:收到包数据之后,回送一个DHCP offer包,包中还有DHCP给客户端的IP,MASK,NETWORK,网关等,还有包含租借日期。
Client:接受到消息后,发送一个DHCP request包,进行确认。
DHCP:接受到消息后,进行再次确认。
安装DHCP:
yum search dhcpd;
yum install dhcpd;
查看到所安装的文件:
rpm -ql dhcpd
编辑/etc/dhcp/dhcpd.conf文件
1 # dhcpd.conf
2 #
3 # Sample configuration file for ISC dhcpd
4 #
5
6 # option definitions common to all supported networks…
7 option domain-name “localhost”; 设置本机的域名
8 option domain-name-servers 192.168.29.0, 192.168.29.100; 设置DNS服务器IP
9
10 default-lease-time 600; 默认租约时间
11 max-lease-time 7200; 最大租约时间,以秒为单位
12
13
14 # Use this to enble / disable dynamic dns updates globally.
15 #ddns-update-style none;
16
17 # If this DHCP server is the official DHCP server for the local
18 # network, the authoritative directive should be uncommented.
19 #authoritative;
20
21 # Use this to send dhcp log messages to a different log file (you also
22 # have to hack syslog.conf to complete the redirection).
23 log-facility local7;
24
25 # No service will be given on this subnet, but declaring it helps the
26 # DHCP server to understand the network topology.
27
28 subnet 192.168.29.0 netmask 255.255.255.0 {
29 }
30
31 # This is a very basic subnet declaration.
32 subnet NETWOEK NETMASK 子网掩码
33 subnet 192.168.29.0 netmask 255.255.255.0 {
34 range 192.168.29.100 192.168.29.150; 分配ip范围
35 option routers 192.168.29.2; 网关
38 }
39
40 # This declaration allows BOOTP clients to get dynamic addresses,
《host为固定主机分配ip》
65 host RedHatserver { host “字符创”
66 hardware ethernet 00:0C:29:4B:1B:6A; “分配主机的MAC”
67 fixed-address 192.168.29.250; ip
68 option routers 192.168.29.3; 网关
69 option domain-name “你才”; 域名
70 option domain-name-servers 114.114.114.114,8.8.8.8; DNS服务器地址
71 }
其中配置文件从局部到全局进行生效。
default-lease-time 600;
max-lease-time 7200; 也可以专为某一主机设置
客户端:
配置/etc/sysconfig/network-script/ifcfg-eth0文件
将其中BOOTPROTO=dhcp
若将虚拟机配置成DHCP服务器,上诉设置同样,但是:这里写图片描述
并且确定,
客户端要进行如上的图的设置。
服务器启动DHCP服务:
service dhcpd start
或 /etc/rc.d/init.d/dhcpd start
客户端正常开机即可获取动态ip

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值