Skip to contentSkip to conversation

iptables does not handle hostname with DNAT

DISCUSSION Thomas Woerner 2 participants 2 messages May 21, 2004 netfilter

lore
Share & tools
lore
#0 lore raw

Hello,

is there a reason why DNAT can only be used with ip adresses and not with hostnames?

Thanks in advance,
Thomas

Signature · 4 lines
Thomas Woerner, Software Developer     Phone: +49-711-96437-0
Red Hat GmbH                           Fax  : +49-711-96437-111
Hauptstaetterstr. 58                   Email: [email protected]
D-70178 Stuttgart                      Web  : http://www.redhat.de/
#1 lore raw
Quoted 2 lines · Thomas Woerner

is there a reason why DNAT can only be used with ip adresses and not with hostnames?

None other than the small fact that iptables can only operate on IP addresses.. but I don't really see any reason why DNAT --to should not accept host names much like any of the other IP address specifications in iptables. Well, there is one.. DNAT can only accept a single IP address but a host name may return multiple IP addresses but it is pretty trivial to deal with so..

What is needed is to rewrite libipt_DNAT.c to use parse_hostnetworkmask rater than dotted_to_addr. See libipt_conntrack.c for an example on how it can be done.

Regards
Henrik