在Kali系统配置临时IP和静态IP
虚拟机网卡采用桥接方式桥接网络,即kali系统的网络IP段与物理机的网络IP段相同,网关相同。
1. 查看物理机IP段,打开CMD,输入ipconfig ,得到ip段为 192.168.2.0段,网关为 192.168.2.1
D:\video\tmp>ipconfig Windows IP 配置 无线局域网适配器 WLAN: 连接特定的 DNS 后缀 . . . . . . . : ctc 本地链接 IPv6 地址. . . . . . . . : fe80::a17a:1a55:c628:abbb%5 IPv4 地址 . . . . . . . . . . . . : 192.168.2.9 子网掩码 . . . . . . . . . . . . : 255.255.255.0 默认网关. . . . . . . . . . . . . : 192.168.2.1
2.在kali系统里,设置临时IP,重启后IP会变化
编辑 /etc/network/interfaces 文件,在最末端加上
auto eth0 # 启动生效网卡
iface eth0 inet dhcp #设置网卡获取IP访问为 dhcp
在终端执行
systemctl restart networking # 重启网络服务
reboot # 重启kali
ifconfig eth0 192.168.2.53/24 #设置临时IP为192.168.2.53,重启失效
route add default gw 192.168.2.1 #设置默认网关 192.168.2.1
3.在Kali系统里,设置静态IP,重启后IP不变
编辑 /etc/network/interfaces 文件,在最末端加上
address 192.168.2.53
netmask 255.255.255.0
gateway 192.168.2.1把 iface eth0 inet dhcp 修改为 iface eth0 inet static
最后如下
cat /etc/network/interfaces
root@xg:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.2.53
netmask 255.255.255.0
gateway 192.168.2.1
4. 在Kali系统,设置DNS
配置Kali系统默认的DNS服务器,常用的国内 114.114.114.114,国外谷歌 8.8.8.8
在 /etc/resolv.conf 最末尾添加
nameserver 8.8.8.8
nameserver 114.114.114.114如下 cat /etc/resolv.conf
root@xg:~# cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 114.114.114.114
5. 重启网络服务
systemctl restart networking