Search code examples
linuxhttp-redirectdnsiptablesnamecheap

Domain redirect to IP with port iptables


I have domain on namecheap and have created subdomain.domain.com and URL redirect to IP:PORT on DNS settings.

But somehow when I make

telnet IP PORT request it works

Ouput:

telnet IP 2002 Trying IP... Connected to ... Escape character is '^]'. ???s?"??+s?"Z?2\?v??????????Connection closed by foreign host.


telnet subdomain.domain.com 2002 doesn't work.

Output:

telnet sub.domain.com 2002` Trying ipofdomain... telnet: connect to address ipofdomain: Connection refused telnet: Unable to connect to remote host


Anyone can shed some light on how to make it work either on namecheap settings or on other server with iptables, perhaps?


Solution

  • As Dusan and Kalyana pointed out, it turns out

    sub.domain.com A record to IP solves the redirection and port resolves itself.

    Thank you guys! Hope it will help some in future.