My Java application is running on a linux machine with 2 IP’s, One internal IP and one External IP. All the third party applications connects to my application using the external IP. When my application is establishing a connection with the database(db in the same machine where my app is running), whether my java app uses which NIC card IP, internal ip or external IP? how to find this?
Share
It is your OS that decides this based on the routing tables. if both IPs are in different subnets then adding a route like
ip route add 192.168.1.0/24 dev eth0will force all connections to any 192.168.0/24 network to use eth0If they are on the same machine like in your case the OS should use the
lo 127.0.0.1interface.