云原生-搭建dhcp服务并测试kickstart脚本

# 安装DHCP服务
【为其他服务器提供分配ip地址的功能,前提是其他服务器网卡必须设置成DHCP获取IP地址模式】
[root@pxe ~]# yum install dhcp.x86_64 -y

[root@pxe ~]# rpm -qc dhcp
/etc/dhcp/dhcpd.conf

[root@pxe -]# cat /etc/dhcp/dhcpd.conf
 #
 # DHCP Server Configuration file.
 # see /usr/share/doc/dhcp*/dhcpd.conf.example
 # see dhcpd.conf(5)man page

# 生成配置文件
[root@pxe ~]# \cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf


[root@pxe ~]# vim /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 "timinhlee.org";     #公司域名
  8 option domain-name-servers 114.114.114.114;    # dhcp工作模式的网络主机获得的DNS的地址,也就是对外分发的dns地址
  9 
 10 default-lease-time 600;    #    默认租约期
 11 max-lease-time 7200;
 12 
 13 # Use this to enble / disable dynamic dns updates globally.
 14 #ddns-update-style none;
 15 
 16 # If this DHCP server is the official DHCP server for the local
 17 # network, the authoritative directive should be uncommented.
 18 #authoritative;
 19 
 20 # Use this to send dhcp log messages to a different log file (you also
 21 # have to hack syslog.conf to complete the redirection).
 22 log-facility local7;    #定义了local的日志格式
 23 
 24 # No service will be given on this subnet, but declaring it helps the 
 25 # DHCP server to understand the network topology.
 26 
 27 # subnet 10.152.187.0 netmask 255.255.255.0 {
 28 # }
 29 
 30 # This is a very basic subnet declaration.
 31 
 32 subnet 网络位 netmask 255.255.255.0 {
 33   range 地址池;
 34   option routers 网关;
 35   }
# 定位35行以后删除不要

[root@pxe ~]# systemctl enable --now dhcpd




### 创建一新台虚拟机,开机测试

 

检测成功!!!

[root@pxe html]# cat /var/lib/dhcpd/dhcpd.leases
# 查看测试主机的ip是否为dhcp分配

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值