Kali linux虚拟机ping不通主机?联不上网?应该如何解决host unreachable

作者:FancyPig | 发布时间: | 更新时间:

相关阅读

data-postsbox="{"id":24381,"title":"如何给Kali linux虚拟机扩容","author":"FancyPig","author_id":1,"cover_image":"","cover_video":"","views":1687,"comment_count":2,"category":"knowledge","is_forum_post":false}">{"id":24381,"title":"如何给Kali linux虚拟机扩容","author":"FancyPig","author_id":1,"cover_image":"","cover_video":"","views":1687,"comment_count":2,"category":"knowledge","is_forum_post":false}
data-postsbox="{"id":2210,"title":"Kali linux最新版 安装方法以及常见问题解答","author":"FancyPig","author_id":1,"cover_image":"","cover_video":"","views":6747,"comment_count":28,"category":"cybersecurity","is_forum_post":false}">{"id":2210,"title":"Kali linux最新版 安装方法以及常见问题解答","author":"FancyPig","author_id":1,"cover_image":"","cover_video":"","views":6747,"comment_count":28,"category":"cybersecurity","is_forum_post":false}
data-postsbox="{"id":9415,"title":"Kali linux最新版镜像如何下载","author":"FancyPig","author_id":1,"cover_image":"","cover_video":"","views":5354,"comment_count":4,"category":"cybersecurity","is_forum_post":false}">{"id":9415,"title":"Kali linux最新版镜像如何下载","author":"FancyPig","author_id":1,"cover_image":"","cover_video":"","views":5354,"comment_count":4,"category":"cybersecurity","is_forum_post":false}

问题场景

之前有热心网友提问,自己的kali为什么连不上网?ping自己的主机也ping不通?

方案一

联网使用的是NAT模式

我们可以通过下面方式进行修改

网卡配置

修改/etc/network/interfaces

mousepad /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

DNS配置

修改/etc/resolv.conf

mousepad /etc/resolv.conf

配置文件如下

# Generated by NetworkManager
search localdomain
nameserver 114.114.114.114
nameserver 8.8.8.8

部分热心网友看了网上的一些教程,就无脑的去设置了静态地址,从而导致无法联网、也无法ping通主机……

方案二

部分网友发现可以联的上网,但是ping不通内网的机器,这时,你可能需要使用下面的命令

route -n

找到错误的链路,然后把它删掉

route delete -net X.X.X.X netmask X.X.X.X

举个例子

[root@kali ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 eth0
10.0.2.0        0.0.0.0         255.255.255.0   U     100    0        0 eth0
10.244.0.0      0.0.0.0         255.255.255.0   U     0      0        0 cni0
10.244.1.0      10.244.1.0      255.255.255.0   UG    0      0        0 flannel.1
10.244.2.0      10.244.2.0      255.255.255.0   UG    0      0        0 flannel.1
link-local      0.0.0.0         255.255.0.0     U     1003   0        0 eth1
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.18.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-fc0843e5ca0a
192.168.8.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1

需要删除这里的docker0链路

[root@kali ~]# route del -net 172.17.0.0 netmask 255.255.0.0 

方案三

很多学生配置实验需要在IP中携带自己的学号,导致kali被整的很乱,这时,你可以找到一种暴力的手段

那就是虚拟网络编辑器一键还原,这样就没有烦恼了

标签:kali, ping, linux系统, host, etc