目录
一、通过DHCP服务器租约文件查看具体租约
从这里可以获取网卡的Mac地址。
[root@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.3.6
# authoring-byte-order entry is generated, DO NOT DELETE
authoring-byte-order little-endian;
server-duid "\000\001\000\001**\343\350\000\014)u\037\310";
lease 192.168.9.145 {
starts 4 2022/06/02 06:11:09; // 租约开始时间
ends 4 2022/06/02 08:11:09; // 租约结束时间
cltt 4 2022/06/02 06:11:09;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:0c:29:8e:d3:14; // Mac地址
client-hostname "Oracle19c"; // 主机名
}
lease 192.168.9.146 {
starts 4 2022/06/02 06:12:28;
ends 4 2022/06/02 08:12:28;
cltt 4 2022/06/02 06:12:28;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:0c:29:8e:d3:1e;
}
注:当你发现这里的时间和你的服务器时间不一致的时候,建议你修改时区解决问题,一般是差8个小时。
二、修改DHCP配置文件
[root@DHCP ~]# vim /etc/dhcp/dhcpd.conf
host fantasia { // 主机名称,可自定义
hardware ethernet 00:0c:29:8e:d3:1e; // 需要分配客户端的Mac地址
fixed-address 192.168.9.150; // 需要分配的固定ip
}
[root@DHCP ~]# systemctl restart dhcpd
三、客户端测试
[root@Oracle19c ~]# dhclient -r ens34
[root@Oracle19c ~]# ifconfig ens34
[root@Oracle19c ~]# dhclient -d ens34
Internet Systems Consortium DHCP Client 4.2.5
Copyright 2004-2013 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/ens34/00:0c:29:8e:d3:1e
Sending on LPF/ens34/00:0c:29:8e:d3:1e
Sending on Socket/fallback
DHCPDISCOVER on ens34 to 255.255.255.255 port 67 interval 6 (xid=0x59f82759)
DHCPREQUEST on ens34 to 255.255.255.255 port 67 (xid=0x59f82759)
DHCPOFFER from 192.168.9.132
DHCPACK from 192.168.9.132 (xid=0x59f82759)
bound to 192.168.9.150 -- renewal in 3323 seconds.
^C
[root@Oracle19c ~]# ifconfig ens34
测试成功,获取ip150:
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/74672.html