使用端口 iptables 将域重定向到 IP

Domain redirect to IP with port iptables

我在 namecheap 上有域名,并在 DNS 设置上创建了 subdomain.domain.com 和 URL 重定向到 IP:PORT。

但不知何故当我

telnet IP PORT 请求有效

输出:

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 无效。

输出:

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


任何人都可以阐明如何使其在 namecheap 设置或其他带有 iptables 的服务器上工作,也许?

URL 重定向在 HTTP 层工作。 Telnet 工作在TCP 层。当您通过浏览器或 curl 向 subdomain.domain.com 发出请求时,您将看到一个 302 到 IP:port.

正如 Dusan 和 Kalyana 所指出的,事实证明

sub.domain.com A record to IP 解决重定向,端口自行解析。

谢谢大家!希望以后对大家有所帮助。