Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new property to specify local Socket Address #2081

Closed
jycr opened this issue Mar 2, 2021 · 11 comments
Closed

Add new property to specify local Socket Address #2081

jycr opened this issue Mar 2, 2021 · 11 comments

Comments

@jycr
Copy link
Contributor

jycr commented Mar 2, 2021

I'm submitting a ...

  • feature request

Describe the issue
We use PostgreSQL in hardened security context where remote connection is allowed by source ADDRESS in pg_hba.conf.

On client side VM, we have several network interfaces. When we open JDBC connection toward remote PostgreSQL VM, the source address used by soket connection is always the first network interface. We can not specify another local socket address.
With MySQL, we can use property localSocketAddress, but no equivalent property exists with PostgreSQL.

It would be very useful to add a new property to specify the Hostname or IP address to explicitly configure the interface that the driver will bind the client side of the TCP/IP connection to when connecting.

Driver Version?
42.2.19

Java Version?
11.0.10

OS Version?
Windows 10

PostgreSQL Version?
10

@vlsi
Copy link
Member

vlsi commented Mar 3, 2021

Nice idea.

Do you know if the feature already exists in psql and libpq?
It would be nice to align naming then.

I wonder how that should play with multiple DB hosts.
For instance, what if secondary db is located on a different subnet (from the client perspective).

@davecramer
Copy link
Member

agreed, this sounds like something we could use

@jycr
Copy link
Contributor Author

jycr commented Mar 3, 2021

Do you know if the feature already exists in psql and libpq?
It would be nice to align naming then.

I am not a psql/libpq expert, but I found this comment posted at 2017-10-17:
https://dba.stackexchange.com/questions/188570/bind-psql-client-on-specific-network-interface#comment-365894

Since psql (and in fact libpq) doesn't have an option to bind() a socket to an address before connect(), it's the OS kernel that decides which network interface gets used based on the routing table. Whatever solution there is, it will be at the OS/networking level, not in PostgreSQL. – Daniel Vérité Oct 17 '17 at 12:02

@bokken
Copy link
Member

bokken commented Mar 3, 2021

Leveraging the OS routing tables is going to be a far more robust solution than anything which could be accomplished in the driver itself with connection properties. @vlsi's question on handling multiple db hosts on different subnets is one example of problems with trying to handle this in the driver.

@davecramer
Copy link
Member

I thought this was more for use inside containers. Is it still simple inside containers ?

@bokken
Copy link
Member

bokken commented Mar 3, 2021

My initial reaction is that using OS routing tables is still the better answer in containers, but my use of containers has been pretty limited.

@jycr
Copy link
Contributor Author

jycr commented Mar 8, 2021

Do you need complementary stuff to the PR (#2082 ) before merging it on master for the next release?

@davecramer
Copy link
Member

complementary stuff ?

@jycr
Copy link
Contributor Author

jycr commented Mar 8, 2021

complementary stuff ?

Do you need that I make other changes to the PR #2082 for you to be able to merge it to master and make a release?
We really need this feature for our PRODUCTION environnement.

@davecramer
Copy link
Member

I'll deal with this today. Thanks! No guarantee on when we release tho

@davecramer
Copy link
Member

closed by #2082

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants