> -----Original Message----- > From: Mark H. Wood <mw...@iupui.edu> > Sent: Friday, June 25, 2021 12:30 PM > To: users@tomcat.apache.org > Subject: Re: Re-Use TCP Source Ports if the Socket is Unique? > > On Fri, Jun 25, 2021 at 12:46:03PM +0000, Eric Robinson wrote: > > Olaf and Scott -- > > > > Thanks to both of you for your comments. I may have asked my question > poorly, since what you both described is the way I understand TCP to work. > There is no correlation between an incoming connection to tomcat and its > outgoing connection to a database backend, nor would I expect there to be. > > > > Perhaps a simpler way to ask my question is: when a server has multiple > IPs, which one does tomcat use as its source IP when it initiates a three-way > handshake with a remote machine? > > > > For example, suppose my server has IP addresses 10.0.0.1 and 10.0.0.2, and > my tomcat connector looks like this... > > > > <Connector > > port="8080" > > protocol="HTTP/1.1" > > address="10.0.0.2" > > connectionTimeout="20000" > > redirectPort="8443" > > /> > > > > Tomcat is now listening on IP 10.0.0.2. > > > > But here's the question. If tomcat needs to initiate a TCP session to a > remote machine (acting as a TCP client), will it use 10.0.0.1 or 10.0.0.2 as > the > source IP of the outbound connection? I'm assuming it will use the same IP > that the connector is configured to listen on. > > man 7 tcp > > A client uses 'connect' and doesn't need to set a local address. Only a > service > needs to declare its own address and port. > > The kernel routing database knows which distant hosts should be reachable > via each local address. 'connect' should use this to pick an address that can > reach the distant host, assign an unallocated port, and send SYN to request a > connection. > > So the answer to your question is "it depends on the service host's address > and what networks the interfaces for 10.0.0.1 and 10.0.0.2 can see." >
Gotcha, that is clearer to me now. Fortunately, Christopher Schultz turned me on to the Connector/J localSocketAddress property, and now I can control which source IP my tomcat instances use when connecting to remote database servers. > -- > Mark H. Wood > Lead Technology Analyst > > University Library > Indiana University - Purdue University Indianapolis > 755 W. Michigan Street > Indianapolis, IN 46202 > 317-274-0749 > www.ulib.iupui.edu Disclaimer : This email and any files transmitted with it are confidential and intended solely for intended recipients. If you are not the named addressee you should not disseminate, distribute, copy or alter this email. Any views or opinions presented in this email are solely those of the author and might not represent those of Physician Select Management. Warning: Although Physician Select Management has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org