I'm developing a product and at a certain point I need to get domain names used to access some service on a specific port. Let's suppose I've a computers network with Internet access through a Linux gateway. I'm interested in port 6208 as an example (it could be any port).
When someone within this network connects to [domain name]:6208 I want an application I'll develop get [domain name] at gateway.
When connect to eg.example.com:6208, application must get eg.example.com.
What can I do at the gateway to get this behavior? Is there some way to do it using existent tools? What I'm asking for isn't how to develop the referred application, but how/where can I get this data (domain name). Given that gateway runs a Linux distribution, it must have someway to do that.
So, have somebody a hint?