我想在虚拟机上设置一个测试数据库以用于开发目的,但我无法通过网络连接到服务器。
我在 Virtualbox 4.2.4 中的 12.04 主机上安装了 Ubuntu 12.04vm,并将其设置为 - 桥接网络模式 - 混杂允许所有
当我尝试从任何网络客户端 ping 虚拟客户机时,我得到了预期的结果。
PING 192.168.1.209 (192.168.1.209) 56(84) bytes of data.
64 bytes from 192.168.1.209: icmp_req=1 ttl=64 time=0.427 ms
...
虚拟机内部上网正常
但是当我对其进行 nmap 操作时我什么也没得到!
jeremy@bangkok:~$ nmap -sV -p 1-65535 192.168.1.209
Starting Nmap 5.21 ( http://nmap.org ) at 2012-11-15 18:39 CST
Nmap scan report for jeremy (192.168.1.209)
Host is up (0.0032s latency).
All 65535 scanned ports on jeremy (192.168.1.209) are closed
Service detection performed. Please report any incorrect results at http://nmap.org/submit/
Nmap done: 1 IP address (1 host up) scanned in 0.88 seconds
VM 上的 ufw 和 iptables......
jeremy@jeremy:~$ sudo service ufw stop
[sudo] password for jeremy:
ufw stop/waiting
jeremy@jeremy:~$ sudo iptables -L
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
我已经扫描过周围并且没有理由相信我的路由器正在阻塞内部端口。
jeremy@bangkok:~$ nmap -v 192.168.1.2
Starting Nmap 5.21 ( http://nmap.org ) at 2012-11-15 18:44 CST
Initiating Ping Scan at 18:44
Scanning 192.168.1.2 [2 ports]
Completed Ping Scan at 18:44, 0.00s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 18:44
Completed Parallel DNS resolution of 1 host. at 18:44, 0.03s elapsed
Initiating Connect Scan at 18:44
Scanning 192.168.1.2 [1000 ports]
Discovered open port 445/tcp on 192.168.1.2
Discovered open port 139/tcp on 192.168.1.2
Discovered open port 3306/tcp on 192.168.1.2
Discovered open port 80/tcp on 192.168.1.2
Discovered open port 111/tcp on 192.168.1.2
Discovered open port 53/tcp on 192.168.1.2
Discovered open port 5902/tcp on 192.168.1.2
Discovered open port 8090/tcp on 192.168.1.2
Discovered open port 6881/tcp on 192.168.1.2
Completed Connect Scan at 18:44, 0.02s elapsed (1000 total ports)
Nmap scan report for 192.168.1.2
Host is up (0.0017s latency).
Not shown: 991 closed ports
PORT STATE SERVICE
53/tcp open domain
80/tcp open http
111/tcp open rpcbind
139/tcp open netbios-ssn
445/tcp open microsoft-ds
3306/tcp open mysql
5902/tcp open vnc-2
6881/tcp open bittorrent-tracker
8090/tcp open unknown
Read data files from: /usr/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.08 seconds
答案... 事实证明,所有端口都对网络开放。我安装了 open ssh 并确认了这一点。然后我编辑了我的数据库配置以监听外部 IP,一切正常。
答案1
Ping 是 ICMP 回显请求,与端口无关。端口仅与在更高网络层上运行的 TCP 和 UDP 等相关。
答案2
您的机器上是否有打开任何端口,请在 Ubuntu 机器上运行以下命令来查看哪些端口是打开的:
netstat -nap
如果你确实打开了端口,那么尝试使用以下开关运行 nmap:
nmap -sS -p 1-65535 192.168.1.209
答案3
我从下面的链接中得到了提示。结果发现,没有设置任何进程来监听外部 IP。我安装了开放的 ssh 服务器以确保有一个监听器,然后 nmap 显示有 22 个打开。然后我编辑了我的数据库的 conf 文件以监听外部 IP,一切正常。