0

I would like to create a TCP proxy that supports multiple hosts. The example I saw was where a DNS server was used to point a specific host to a TCP proxy which had the host hardcoded in it. The TCP proxy can not handle multiple hosts because if all hosts were routed to the TCP proxy, the proxy would not know where to send the data to. Are there any ways to get around this issue?

3
  • How could the proxy possibly know where to proxy to? Jul 26, 2021 at 23:50
  • Yes that is the question. I want to be able to use the TCP proxy like an HTTP proxy supporting all hosts and ports without knowing what they are beforehand. I was thinking of something like creating new servers on the fly on DNS lookup but I don't know if that is feasible.
    – comctimert
    Jul 27, 2021 at 0:06
  • You have to have some way to distinguish them! Jul 27, 2021 at 0:29

1 Answer 1

2

TCP works over IP and IP has no notion of host(names) but only of IP addresses.

As such, TCP knows also only about IP addresses, not hostnames.

If you want to have something handling hostnames you need a protocol on top of TCP (ex: HTTP, SSH, etc.) or translate names to IP addresses before using TCP, as the DNS is typically providing.

Or you need your "TCP" proxy to listen on separate ports and proxy things depending on which port is accessed. However you still have the problem of mapping names to now not only an IP address (of the proxy) but its port too, which is possible but more difficult with DNS (if you control the client, you can do that using SRV records or in the future SVCB ones).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .