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." -- 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
signature.asc
Description: PGP signature