我们有一个Azure VM,我们需要从本机的特定端口发送UDP消息。我们使用.NET Class UdpClient进行通信。当在Azure虚拟机上穿过公共VIP时,出站UDP指定的源端口发生更改
如果我们尝试在同一虚拟网络中的机器之间发送消息,接收方机器会显示正确的源主机和端口。
如果我们跨越公共VIP(在不同虚拟网络中的虚拟机或onPremises侦听器之间),源端口将显示1024或更高的端口,而不是选定的源端口。
发信人:1.2.3.4:5000
接收机:5.6.7.8:5001 - >说,来自1.2.3.4:1025接收到的数据 - > 1025源端口应5000
VB.NET样品:
'Sending
Private Sub Send()
Dim data() As Byte = System.Text.Encoding.Unicode.GetBytes("Data")
Dim client As UdpClient = New UdpClient(5000)
client.Send(data, data.Length, "5.6.7.8", "5001")
client.Close()
End Sub
'Recieving
Private Sub Recieve()
While True
Dim remoteIPEndPoint As IPEndPoint = New IPEndPoint(IPAddress.Any, 5001)
Dim content() As Byte = udpClient.Receive(remoteIPEndPoint)
If content.Length > 0 Then
Dim message As String = Encoding.ASCII.GetString(content)
message &= remoteIPEndPoint.Address.ToString & " " & remoteIPEndPoint.Port & " " & message & vbCrLf
End If
End While
End Sub
我读过一些关于NAT(源NAT),我想知道如果Azure的网络总是能转化上超越公共网关出站通信源UDP端口。
我们确实需要在我们的平台上保留目的地的源端口信息,因为我们有数以千计的设备在Internet上只侦听指定的IP:UDPPort组合。
由于提前,
安东尼奥·桑切斯
亚特兰蒂斯全球系统