![在远程计算机上启动了 netserver,但 netperf 无法建立连接](https://linux22.com/image/943599/%E5%9C%A8%E8%BF%9C%E7%A8%8B%E8%AE%A1%E7%AE%97%E6%9C%BA%E4%B8%8A%E5%90%AF%E5%8A%A8%E4%BA%86%20netserver%EF%BC%8C%E4%BD%86%20netperf%20%E6%97%A0%E6%B3%95%E5%BB%BA%E7%AB%8B%E8%BF%9E%E6%8E%A5.png)
我正在使用两台 Azure 机器在它们之间运行TCP_STREAM
netperf 测试。
远程机器被称为mymachine-Standard-D8as-v4-premium-disk-west
,本地机器被称为mymachine-Standard-D8as-v4-premium-disk
。
我遵循以下步骤:
netserver
在远程服务器的端口启动2333
:
ubuntu@mymachine-Standard-D8as-v4-premium-disk-west-0001:~$ sudo netserver -p 2333
Starting netserver with host 'IN(6)ADDR_ANY' port '2333' and family AF_UNSPEC
确保它已启动:
ubuntu@mymachine-Standard-D8as-v4-premium-disk-west-0001:~$ ps -ef | grep netserver
root 4139 1 0 16:16 ? 00:00:00 /usr/bin/netserver
root 26990 1 0 16:21 ? 00:00:00 netserver -p 2333
ubuntu 27011 1906 0 16:25 pts/0 00:00:00 grep --color=auto netserver
ubuntu@mymachine-Standard-D8as-v4-premium-disk-west-0001:~$sudo lsof -i tcp:2333
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
netserver 26990 root 3u IPv6 66361 0t0 TCP *:2333 (LISTEN)
- 获取远程机器的IP地址:
enP6064s1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500
ether 00:0d:3a:f6:09:99 txqueuelen 1000 (Ethernet)
RX packets 53433 bytes 76754512 (76.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8200 bytes 1287344 (1.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.2.0.27 netmask 255.255.192.0 broadcast 10.2.63.255
inet6 fe80::20d:3aff:fef6:999 prefixlen 64 scopeid 0x20<link>
ether 00:0d:3a:f6:09:99 txqueuelen 1000 (Ethernet)
RX packets 12508 bytes 80101094 (80.1 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8136 bytes 1286894 (1.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 190 bytes 25942 (25.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 190 bytes 25942 (25.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
显示西边机器的 IP 地址是 10.2.0.27!
- 从本地机器运行 netperf
netperf -H 10.2.0.27 -p 2333 -D 0.5 -c -C -l 20 -t TCP_STREAM -P 0 -f g -- -b 2 -D -o throughput,throughput_units
现在它给了我:
establish control: are you sure there is a netserver listening on 10.2.0.27 at port 2333?
establish_control could not establish the control connection from 0.0.0.0 port 0 address family AF_UNSPEC to 10.2.0.27 port 2333 address family AF_INET
这真是令人困惑!因为我已经验证了网络服务器正在监听 10.2.0.27 的 2333 端口。实际上,同样的过程在 GCE 的机器上也可以正常工作。
我想知道这是什么原因造成的以及如何解决它。
根据@waltinator 的评论,我查看了两台机器上的ip route
、、ufw status
。sudo traceroute the-other-system
西机上:
ubuntu@mymachine-Standard-D8as-v4-premium-disk-west-0001:~$ ip route
default via 10.2.0.1 dev eth0 proto dhcp src 10.2.0.27 metric 100
10.2.0.0/18 dev eth0 proto kernel scope link src 10.2.0.27
168.63.129.16 via 10.2.0.1 dev eth0 proto dhcp src 10.2.0.27 metric 100
169.254.169.254 via 10.2.0.1 dev eth0 proto dhcp src 10.2.0.27 metric 100
ubuntu@mymachine-Standard-D8as-v4-premium-disk-west-0001:~$ ufw status
ERROR: You need to be root to run this script
ubuntu@mymachine-Standard-D8as-v4-premium-disk-west-0001:~$ sudo traceroute 10.1.0.62
traceroute to 10.1.0.62 (10.1.0.62), 30 hops max, 60 byte packets
1 * * *
...
30 * * *
在本地机器上:
ubuntu@jane-cr22-Standard-D8as-v4-premium-disk-0001:~$ ip route
default via 10.1.0.1 dev eth0 proto dhcp src 10.1.0.62 metric 100
10.1.0.0/18 dev eth0 proto kernel scope link src 10.1.0.62
168.63.129.16 via 10.1.0.1 dev eth0 proto dhcp src 10.1.0.62 metric 100
169.254.169.254 via 10.1.0.1 dev eth0 proto dhcp src 10.1.0.62 metric 100
ubuntu@mymachine-Standard-D8as-v4-premium-disk-0001:~$ ufw status
ERROR: You need to be root to run this script
ubuntu@mymachine-Standard-D8as-v4-premium-disk-0001:~$ sudo ufw status
Status: inactive
ubuntu@mymachine-Standard-D8as-v4-premium-disk-0001:~$ sudo traceroute 10.2.0.27
traceroute to 10.2.0.27 (10.2.0.27), 30 hops max, 60 byte packets
1 * * *
...
30 * * *
此外,对于西边的机器,我添加了一个优先级为 100 的入站端口规则,允许任何源和目标,端口范围为 2333。但本地机器仍然无法连接远程机器。