We have a load balanced (NLB) ASP.NET web app which sends email.
The servers are dual homed with an external facing and internal (behind firewall) facing IP. The Mail server is behind the firewall.
We have been seing a problem where the SMTPClient class throws an exception stating it is unable to connect to the SMTP server.
The networking guys are telling us they are seeing attempts to connect to the SMTP server from the external facing IP address (which the firewall is blocking)
From my (admittedly patchy) knowledge of network enabled applications I thought that the local IP binding would be decided based on the destination, i.e. if the routing tables say the IP address can be accessed through a particular NIC than that is the IP the outbound request is generated from. Am I wrong?
looking at SmtpClient.ServicePoint I’m beginning to think that we might be and that we can (should) force an explicit binding to a particular IP?
specifically I’ve been looking at
ServicePoint.BindIPEndPointDelegate Property
from that page…
Remarks :Some load balancing techniques
require a client to use a specific
local IP address and port number,
rather than IPAddress.Any (or
IPAddress.IPv6Any for Internet
Protocol Version 6) and an ephemeral
port. Your BindIPEndPointDelegate can
satisfy this requirement.
it just seems a little odd to me that I’d need to do that but perhaps thats common in this type of environment?
You need to do something like this…