对于某些 IP 上的某些端口,“没有到主机的路由”

对于某些 IP 上的某些端口,“没有到主机的路由”

我遇到了一种奇怪的情况,我的笔记本电脑上运行着一个 MySQL 服务器,同时我的 VM 也运行在这台笔记本电脑上。

我注意到,我可以通过虚拟机ssh通过仅主机 IP ( ) 连接到主机192.168.56.1,但无法连接到端口3306。但是,如果我使用主机的 LAN IP 地址,它就可以工作!

我使用了该 nc -vz命令并从虚拟机获得以下输出:

[root@portal42 portal]# nc -vz 192.168.56.1 3306
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: No route to host.
[root@portal42 portal]# nc -vz 192.168.178.241 3306
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.178.241:3306.
Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.
[root@portal42 portal]# nc -vz 192.168.178.66 3306
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.178.66:3306.
Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.
[root@portal42 portal]# nc -vz 192.168.178.66 24800
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connection refused.
[root@portal42 portal]# nc -vz 192.168.178.66 24801
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connection refused.
[root@portal42 portal]# nc -vz 192.168.178.66 3307
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connection refused.
[root@portal42 portal]# nc -vz 192.168.56.1 3307
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: No route to host.

正如您所看到的,如果我没有运行任何服务,它只会Connection refused从我通常可以访问的 IP 进行显示,这是正常的。

我在 LAN 上还有一台机器,我尝试了同样的方法,在这种情况下,nz使用笔记本电脑的 LAN IP 的命令会给我No Route to host,但仅限于某些端口:端口8025可以22工作,但248003306不工作,尽管我确实有服务在这些端口上运行。下面...66是 Wi-Fi,...241是有线(我已连接两者)。

$ nc -vz 192.168.178.66 61616
nc: connect to 192.168.178.66 port 61616 (tcp) failed: No route to host
$ nc -vz 192.168.178.66 3306
nc: connect to 192.168.178.66 port 3306 (tcp) failed: No route to host
$ nc -vz 192.168.178.66 24800
nc: connect to 192.168.178.66 port 24800 (tcp) failed: No route to host
$ nc -vz 192.168.178.66 80
Connection to 192.168.178.66 80 port [tcp/http] succeeded!
$ nc -vz 192.168.178.66 22
Connection to 192.168.178.66 22 port [tcp/ssh] succeeded!
$ nc -vz 192.168.178.66 25
Connection to 192.168.178.66 25 port [tcp/smtp] succeeded!
$ nc -vz 192.168.178.241 3306
nc: connect to 192.168.178.241 port 3306 (tcp) failed: No route to host

我已禁用ufw,并已iptables在笔记本电脑上刷新:

$ sudo iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

另外,我的 MySQL 已bind_address=0.0.0.0禁用ufw

$ sudo service ufw status
● ufw.service - Uncomplicated firewall
   Loaded: loaded (/lib/systemd/system/ufw.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Tue 2019-06-25 21:30:35 CEST; 17h ago
     Docs: man:ufw(8)
  Process: 339 ExecStart=/lib/ufw/ufw-init start quiet (code=exited, status=0/SUCCESS)
  Process: 20404 ExecStop=/lib/ufw/ufw-init stop (code=exited, status=0/SUCCESS)
 Main PID: 339 (code=exited, status=0/SUCCESS)

Jun 24 22:40:18 mau-Precision-7520 systemd[1]: Started Uncomplicated firewall.
Jun 25 21:30:35 mau-Precision-7520 systemd[1]: Stopping Uncomplicated firewall...
Jun 25 21:30:35 mau-Precision-7520 systemd[1]: ufw.service: Succeeded.
Jun 25 21:30:35 mau-Precision-7520 systemd[1]: Stopped Uncomplicated firewall.
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

日志中没有任何迹象表明并且apparmor也被删除了。

这个问题是在 Ubuntu 升级后出现的,但我不知道问题是什么!

有什么帮助吗?我已经注意到这个问题 5 天了,但我不知道问题出在哪里!

谢谢

相关内容