Kali 配置静态ip
环境
**虚拟化平台:**VMware workstation pro 17.5
**镜像版本:**kali-2023.4
kali 安装自行安装,默认大家都是安装完成
配置步骤
步骤一:配置VMware 网络
- 进入VMware,在选项栏选择【编辑】-【虚拟网络编辑器】
- 使用管理员权限进行编辑,点击【更改设置】
- 安装如下顺序进行操作
- 双击【VMnet8】
- 填写子网ip及子网掩码,即确认内网网段,本文网段
192.168.10.0/24
- 点击【NAT设置】,对NAT进行配置
- 填写网关IP,本文使用
192.168.10.2
步骤二:配置宿主机VMnet8网络适配器
- 进入windows 设置页面,点击【网络和internet】
- 点击【高级网络配置】下的【更改适配器选项】
- 双击 VMnet8适配器
- 点击【属性】
- 双击【ipv4】
- 配置对应的IP
步骤三:编辑kali网络配置文件
# 编辑网络接口文件
┌──(root㉿kali)-[/home/kali]
└─# vim /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.10.101 # ip地址
netmask 255.255.255.0 # 子网掩码
getway 192.168.10.2 # 网关
network 192.168.10.0 # 子网ip
# 编辑dns文件
┌──(root㉿kali)-[/home/kali]
└─# vim /etc/resolv.conf
search localdomain
nameserver 192.168.10.2 # 网关
nameserver 8.8.8.8 # 公共dns
nameserver 114.114.114.114 # 公共dns
# 重启网络服务
┌──(root㉿kali)-[/home/kali]
└─# service networking restart
# 查看ip地址
┌──(root㉿kali)-[/home/kali]
└─# ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:1c:8c:00 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.101/24 brd 192.168.10.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe1c:8c00/64 scope link proto kernel_ll
valid_lft forever preferred_lft foreve
截至到现在就静态ip配置完成
遇到的异常
- 配完IP之后,发现无法访问公网,提示Network is unreachable
┌──(root㉿kali)-[/home/kali]
└─# ping baidu.com
ping: connect: Network is unreachable
# 修改 NetworkManager.conf 配置文件(网络服务图形管理工具)或者停止NetworkManager服务
# 1.修改配置文件
┌──(root㉿kali)-[/home/kali]
└─# vim /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile
[ifupdown]
managed=true # 将该选项改成true,默认false
# 停止服务并重启网络
┌──(root㉿kali)-[/home/kali]
└─# service NetworkManager stop
└─# service disable NetworkManager
└─# service networking restart
# 此时再进行ping 测试
┌──(root㉿kali)-[/home/kali]
└─# ping baidu.com
ping: connect: Network is unreachable
# 还是不行,怀疑是路由问题,查看路由
┌──(root㉿kali)-[/home/kali]
└─# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
# 果然路由存在异常,添加上网关(上文配置的网关)
┌──(root㉿kali)-[/home/kali]
└─# route add default gw 192.168.10.2
┌──(root㉿kali)-[/home/kali]
└─# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.10.2 0.0.0.0 UG 0 0 0 eth0
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
# 再次ping测试,发现网络正常
┌──(root㉿kali)-[/home/kali]
└─# ping baidu.com
PING baidu.com (110.242.68.66) 56(84) bytes of data.
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=1 ttl=128 time=20.3 ms
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=2 ttl=128 time=20.3 ms
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=3 ttl=128 time=18.8 ms
^C
--- baidu.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2005ms
rtt min/avg/max/mdev = 18.768/19.781/20.327/0.717 ms
问题反馈
若对文中有任何的疑问,或者需要帮助可以通过以下方式进行反馈
-
直接进行评论或者单独私聊
-
发送邮件到:mr_xuansu@163.com
更多内容请关注微信公众号:萱蘇的运维日常