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 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
Can I write something like
iptables -t nat -A PREROUTING -p tcp -d mycomputername --dport 422 -j DNAT --to mycomputername:22
and the computer name will be resolved in current IP?
Thank you.
No - Attempting this gives a "Bad IP address" (at least in v 1.4.7)
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).
The IPTables manual also recommends against specifying a domain name.