lig*_*ght 1 iptables port-forwarding
如何将端口转发到主机名和端口。我正在看这篇文章:Iptables forward all traffic to a specified port, to another device and see how to do it port to ip 但如果我需要做 port to hostname 怎么办?尝试将主机作为目的地,但它在 iptables 中引发错误
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination ehb-us-redis-001.ehb-usredis.u1.cache.com:6379
iptables v1.4.21: Bad IP address "ehb"
Try `iptables -h' or 'iptables --help' for more information.
Run Code Online (Sandbox Code Playgroud)
你不能。语法在iptables-extensions手册页中指定为
--to-destination [ipaddr[-ipaddr]][:port[-port]]
Run Code Online (Sandbox Code Playgroud)
虽然and语法允许使用主机名,但不鼓励这样做,因为它可能会导致安全问题。由于采用 IP 地址范围(对于简单的循环负载平衡),地址语法将无关紧要。iptables
-s
-d
address[/mask]
--to-destination
在将规则提交给内核之前,主机名将只解析一次。请注意,指定要使用远程查询(例如 DNS)解析的任何名称是一个非常糟糕的主意。
此外,Netfilter 内核模块不处理主机名;如果您认为这可以解决更改 IP 地址的一些问题,那么它不会。
如果您确实需要使用主机名,反向代理会更适用。
归档时间: |
|
查看次数: |
2712 次 |
最近记录: |