连接到未知 IP 地址的 Azure 服务总线中继:40.112.124.x:9352
Azure service bus relay connecting to unknown ip address: 40.112.124.x:9352
我们交付使用 Azure 服务总线中继暴露给云的本地软件,我们用来暴露的基本代码如下(我已经删除了所有可识别的内容):
ServiceHost sh = new ServiceHost(typeof(BasicHttpEntityService));
BasicHttpRelayBinding basicHttpRelayBinding = new BasicHttpRelayBinding();
Uri uriEndPointAddress = ServiceBusEnvironment.CreateServiceUri("https", "ourdomain", "test-url-appendage");
m_shRelayServiceHost.AddServiceEndpoint(
typeof(IMyService),
basicHttpRelayBinding,
uriEndPointAddress
).Behaviors.Add(
new TransportClientEndpointBehavior
{
TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(
"MyUser",
"MyPassword")
});
sh.Open();
这对我们的大多数客户都适用,但是,我们的一个客户有严格的防火墙策略。
According to the SB guidelines we have found,我们要求他们将端口 9351-9354 开放给 ourdomain.servicebus.windows.net。现在我们发现,当有传入请求时,该服务连接到 'ourdomain'(我们在 Wireshark 和 WCF 日志中看到这成功)和 40.112 上的未知(对我们来说)服务。124.x:9352(最后一个八位字节随每个请求而变化)。
通过禁止连接到任何端口上的任何 40.x.x.x 地址,我已经能够在我的开发环境中重现该问题。这是 WCF 日志中发生的情况:
System.Net.Sockets.SocketException (0x80004005): An attempt was made to access a socket in a way forbidden by its access permissions 40.112.124.25:9352
Server stack trace:
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at Microsoft.ServiceBus.RelayedConnectionSession.ConnectAsyncResult.<GetAsyncSteps>b__4(ConnectAsyncResult thisRef, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Exception rethrown at [0]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.RelayedConnectionSession.EndConnect(IAsyncResult result)
这段时间没有发出 DNS 请求,因此没有主机名可以提供任何有关此传出连接功能的线索。
根据我的调查,this appears to be a Microsoft controlled subnet,所以我可以接受连接到它的中继服务,但我想知道:
- 这个额外的连接是可选的吗?
- 如果不允许,我们应该允许整个子网吗?
- 这个 IP 范围将来会改变吗?它是否在某处进行了硬编码?
最后,我们请求微软的支持。
简而言之,他们的回答如下:
这个附加连接是可选的吗?
No it is not optional. For the relay listener, there is a control channel on port 5671, this connection is always there. Then there is a data channel on portal 9352, this connection established when there is a relay client tries to communicate with the listener.
这个 IP 范围将来会改变吗?
Currently, for relay this IP can change, so you need to allow the IP range for the entire datacenter in your region (https://www.microsoft.com/en-us/download/confirmation.aspx?id=41653). The SB product team will be working on to significantly reduce this IP range in the future, to make it much more predictable. There is no exact ETA on this future.
所以好消息是他们正在努力。坏消息是,现在我们需要将大量 IP 地址添加到白名单中以确保顺利运行。
我们交付使用 Azure 服务总线中继暴露给云的本地软件,我们用来暴露的基本代码如下(我已经删除了所有可识别的内容):
ServiceHost sh = new ServiceHost(typeof(BasicHttpEntityService));
BasicHttpRelayBinding basicHttpRelayBinding = new BasicHttpRelayBinding();
Uri uriEndPointAddress = ServiceBusEnvironment.CreateServiceUri("https", "ourdomain", "test-url-appendage");
m_shRelayServiceHost.AddServiceEndpoint(
typeof(IMyService),
basicHttpRelayBinding,
uriEndPointAddress
).Behaviors.Add(
new TransportClientEndpointBehavior
{
TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(
"MyUser",
"MyPassword")
});
sh.Open();
这对我们的大多数客户都适用,但是,我们的一个客户有严格的防火墙策略。
According to the SB guidelines we have found,我们要求他们将端口 9351-9354 开放给 ourdomain.servicebus.windows.net。现在我们发现,当有传入请求时,该服务连接到 'ourdomain'(我们在 Wireshark 和 WCF 日志中看到这成功)和 40.112 上的未知(对我们来说)服务。124.x:9352(最后一个八位字节随每个请求而变化)。
通过禁止连接到任何端口上的任何 40.x.x.x 地址,我已经能够在我的开发环境中重现该问题。这是 WCF 日志中发生的情况:
System.Net.Sockets.SocketException (0x80004005): An attempt was made to access a socket in a way forbidden by its access permissions 40.112.124.25:9352
Server stack trace:
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at Microsoft.ServiceBus.RelayedConnectionSession.ConnectAsyncResult.<GetAsyncSteps>b__4(ConnectAsyncResult thisRef, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Exception rethrown at [0]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.RelayedConnectionSession.EndConnect(IAsyncResult result)
这段时间没有发出 DNS 请求,因此没有主机名可以提供任何有关此传出连接功能的线索。
根据我的调查,this appears to be a Microsoft controlled subnet,所以我可以接受连接到它的中继服务,但我想知道:
- 这个额外的连接是可选的吗?
- 如果不允许,我们应该允许整个子网吗?
- 这个 IP 范围将来会改变吗?它是否在某处进行了硬编码?
最后,我们请求微软的支持。 简而言之,他们的回答如下:
这个附加连接是可选的吗?
No it is not optional. For the relay listener, there is a control channel on port 5671, this connection is always there. Then there is a data channel on portal 9352, this connection established when there is a relay client tries to communicate with the listener.
这个 IP 范围将来会改变吗?
Currently, for relay this IP can change, so you need to allow the IP range for the entire datacenter in your region (https://www.microsoft.com/en-us/download/confirmation.aspx?id=41653). The SB product team will be working on to significantly reduce this IP range in the future, to make it much more predictable. There is no exact ETA on this future.
所以好消息是他们正在努力。坏消息是,现在我们需要将大量 IP 地址添加到白名单中以确保顺利运行。