问题描述
我想将某些端口从WAN重定向到我的笔记本电脑.问题在于,笔记本电脑的无线IP和电缆LAN都有不同的IP.有没有办法在iptables中使用计算机名称?
I want to redirect some port from WAN to my laptop. The problem is, that the laptop has different IP on wireless as on cable LAN. Is there a way to use the computer name in iptables?
iptables端口转发规则(使用IP)应为:
Iptables port forwarding rule (using IPs) should be:
iptables -t nat -A PREROUTING -p tcp -d 192.168.102.37 --dport 422 -j DNAT --to 192.168.102.37:22
我可以写类似的东西吗
iptables -t nat -A PREROUTING -p tcp -d mycomputername --dport 422 -j DNAT --to mycomputername:22
计算机名称将在当前IP中解析吗?
and the computer name will be resolved in current IP?
谢谢.
推荐答案
否-尝试给出错误的IP地址"(至少在1.4.7版中)
No - Attempting this gives a "Bad IP address" (at least in v 1.4.7)
看来iptables不喜欢目标地址和端口组合. (您可以为简单的IP指定主机名,但是在添加端口时似乎没有.)
It appears that iptables does not like the destination address and port combination. (You can get away with specifying a host name for a simple IP, but not, it seems, when you append a port).
IPTables手册也建议不要指定域名.
The IPTables manual also recommends against specifying a domain name.
这篇关于是否可以在iptables中使用计算机名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!