Kali Linux常用服务配置教程获取IP地址
下面以
Kali Linux
为例,演示获取
IP
地址的方法
(
1
)设置网络接口为自动获取
IP
地址。在
Kali Linux
的收藏夹中单击
图标
,将显示所有的程序,如图
1.8
所示。
(
2
)单击“设置”图标,将打开“设置”窗口,如图
1.9
所示。
(
3
)选择“网络”选项,单击有线连接中的
齿轮按钮,将显示“有线”对话框,如图
1.10
所示。
(
4
)勾选“自动连接”复选框。然后,单击
IPv4
标签,将显示
IPv4
选项卡,如图
1.11
所示。
(
5
)在该界面选择“自动
(DHCP)
”选项。然后,单击“应用”按钮。接下来,就可以请求获取
IP
地址了。执行命令如下所示:
root@daxueba:~# dhclient eth0 –d
Internet Systems Consortium DHCP Client 4.3.5
Copyright 2004-2016 Internet Systems Consortium.
All rights reserved.
For info, please visit
Listening on LPF/eth0/00:0c:29:25:89:95
Sending on
LPF/eth0/00:0c:29:25:89:95
Sending on
Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4
DHCPREQUEST of 192.168.0.12 on eth0 to 255.255.255.255 port 67
DHCPOFFER of 192.168.0.12 from 192.168.0.10
DHCPACK of 192.168.0.12 from 192.168.0.100
bound to 192.168.0.12 -- renewal in 277 seconds.
从输出的信息中,可以看到成功获取到
IP
地址
192.168.0.12
。由此可以说明,搭建的
DHCP
服务测试成功。此时,用户查看地址租约文件
dhcpd.leases
,也可以看到分配的
IP
地址。如下所示:
root@daxueba:~# cat /var/lib/dhcp/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.5
# authoring-byte-order entry is generated, DO NOT DELETE
authoring-byte-order little-endian;
lease 192.168.0.10 {
starts 1 2018/07/02 10:15:00;
ends 1 2018/07/02 10:25:00;
cltt 1 2018/07/02 10:15:00;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:0c:29:5c:ae:aa;
client-hostname "daxueba";
}
lease 192.168.0.11 {
starts 1 2018/07/02 10:18:17;
ends 1 2018/07/02 10:28:17;
cltt 1 2018/07/02 10:18:17;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:0c:29:99:92:4f;
uid "\001\000\014)\231\222O";
set vendor-class-identifier = "MSFT 5.0";
client-hostname "Test";
}
lease 192.168.0.12 {
starts 1 2018/07/02 10:34:56;
ends 1 2018/07/02 10:44:56;
cltt 1 2018/07/02 10:34:56;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:0c:29:25:89:95;
client-hostname "daxueba";
}
从输出的信息中,可以看到
DHCP
服务分配出去的
IP
地址及对应租约信息。