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

Support multiple IPs on the server #19

Open
dhpark21 opened this issue Mar 15, 2019 · 3 comments
Open

Support multiple IPs on the server #19

dhpark21 opened this issue Mar 15, 2019 · 3 comments

Comments

@dhpark21
Copy link

dhpark21 commented Mar 15, 2019

Hi
I have many ip of one interface card(Centos 7) as like below
eth0 10.10.10.10
eth0:0 10.10.10.11
eth0:1 10.10.10.12
eth0:2 10.10.10.13

but, if i connect 10.10.10.12 then all packet's are output on 10.10.10.10, not 10.10.10.12
how can i output packet to client request ip (of request port)
ex)
8081 port 10.10.10.11 <-> client A
8082 port 10.10.10.12 <-> client B
8083 port 10.10.10.13 <-> client C

Thanks

@fortuna
Copy link

fortuna commented Aug 2, 2019

Interesting use case!

I think this could be accomplished by getting the local address with Conn.LocalAddr() and setting the laddr on DialTCP() and DialUDP() (Dialer.Dial() doesn't have the laddr option).

@fortuna
Copy link

fortuna commented Oct 27, 2020

The new TCPService code should make that easier. We need to pass clientTCPConn.LocalAddr() to dialTarget here:

tgtConn, dialErr := dialTarget(tgtAddr, &proxyMetrics, s.targetIPValidator)

UDP should be doable too.

@fortuna
Copy link

fortuna commented Nov 10, 2020

There's a difficulty in this situation:

  • Server supports IPv4 and IPv6
  • Client connects to a IPv6 server IP
  • Client requests a connection to an IPv4 target
  • Server can't use the IPv6 address to establish the IPv4 connection.

So we should check if the IP version of the target matches the IP version of the client. If it matches, we can use the IP the client connected to. Otherwise use whatever the system picks for you.

@maddyhof maddyhof changed the title Multi interface ip(alias ip) situation output only eth0 ip.. Support multiple IPs on the server Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants