【发布时间】:2014-04-05 15:21:44
【问题描述】:
我在 debian linux 系统中运行 mysql,该系统在 Windows 7 上的 vm 上运行。我已修改 iptables 以接受来自任何地方通过端口 3306 的连接 - 但我无法从 Windows 对它进行 telnet。虽然我可以 ping 虚拟机并确保它可以访问。
这是 iptables 的详细信息:
# sudo iptables -L
CHAIN INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:mysql
CHAIN FORWARD (policy ACCEPT)
target prot opt source destination
CHAIN OUTPUT (policy ACCEPT)
target prot opt source destination
#
这是我添加规则的内容:
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
我可以成功 ping 到 debian vm,但是当我尝试从 windows 主机进行 telnet 时,我得到:
Could not open connection to the host, on port 3306: Connect failed
我还尝试在 debian 中进行远程登录。这是我得到的:
$ telnet localhost 3306
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
6
5.1.73-1*?MH]~"* wG;2(oz9JJrConnection closed by foreign host.
$
debian 系统会等待一段时间,然后自行关闭连接。或者我可以做一个 ^] 并关闭它。
【问题讨论】:
-
您的虚拟机是否使用主机网络?如果没有桥接,它可能会给您带来问题?您的 Windows 防火墙是如何配置的?
-
对不起,只是重新阅读,您可以 ping...
-
你能从 Debian 内部 telnet 到它吗?
-
@AndrewMcDonnell 谢谢。我已经用结果更新了问题。
-
@AndrewMcDonnell 正如我上面提到的,telnet 连接会自动关闭。