Linux如何搭建dhcp

Linux如何搭建dhcp

一、用yum安装dhcp
1)安装yum源
详情请看添加链接描述
2)安装dhcp

yum install dhcp -y

二、修改文件完成dhcp搭建

[root@foundation72 yum.repos.d]# rpm -qc dhcp
/etc/dhcp/dhcpd.conf
/etc/dhcp/dhcpd6.conf
/etc/openldap/schema/dhcp.schema
/etc/sysconfig/dhcpd
/var/lib/dhcpd/dhcpd.leases
/var/lib/dhcpd/dhcpd6.leases
[root@foundation72 yum.repos.d]# vim /etc/dhcp/dhcpd.conf 

复制:/usr/share/doc/dhcp*/dhcpd.conf.example
在这里插入图片描述

[root@foundation72 yum.repos.d]# cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp: overwrite ‘/etc/dhcp/dhcpd.conf’? y
[root@foundation72 yum.repos.d]# vim /etc/dhcp/dhcpd.conf

此时/etc/dhcp/dhcpd.conf文件内容如下图:
在这里插入图片描述
修改为:

  6 # option definitions common to all supported networks...
  7 option domain-name "lee.org";        ##名字可以不改
  8 option domain-name-servers 114.114.114.114;    ##设置dns
  9 
 10 default-lease-time 600;                        ##最少600h
 11 max-lease-time 7200;                           ##最多7200h
31--34行可根据自己具体需求更改
 29 # This is a very basic subnet declaration.
 30 
 31   subnet 172.25.254.0 netmask 255.255.255.0 {    ##其网络区域
 32   range 172.25.254.50 172.25.254.99;           ##给ip范围
 33   option routers 172.25.254.205;               ##给网关
 34 }
 在此之后的信息没啥用,全删了

重启dhcp

systemctl start dhcpd 

-------完成

展开阅读全文

没有更多推荐了,返回首页