From: Joel Newkirk <netfilter@newkirk.us>
To: Florian Effenberger <floeff@arcor.de>
Cc: netfilter@lists.netfilter.org
Subject: Re: host names and IPs
Date: 18 Apr 2003 11:41:49 -0400 [thread overview]
Message-ID: <1050680509.6664.27.camel@alpha.newkirk.us> (raw)
In-Reply-To: <003301c305a1$c04ab1a0$0500a8c0@effenberger>
On Fri, 2003-04-18 at 07:57, Florian Effenberger wrote:
> Hi,
>
> I have a question to the gurus on this list ;-)
>
> I'm on Linux 2.4.20 with iptables 1.2.7a. I have a syntax as follows:
>
> ===
> iptables -A INPUT -p tcp -s www.myhostname.com --dport 53 -j ACCEPT
> ===
>
> Now it seems that www.myhostname.com is resolved only the first time the
> rule is set and that a fixed IP address is stored.
Correct.
> However, www.myhostname.com has a dynamically assigned address and I would
> like to have iptables resolve the IP address everytime.
Same here... :^(
> Is that possible? If yes, how? Or will it produce too much load?
Iptables/netfilter does not, AFAIK, support this at all. I have a
similar situation, and found two solutions.
The one I implemented was to map out the range of dynamic IPs assigned
(ISP refused to disclose!) and ended up using a /22 netmask. Not as
tight, but simpler and less overhead than:
The other approach was to write a script (cron scheduled) that would
extract the IP from 'dig' output and compare it against a stored value
from the last change (/tmp/myhostname.com.ip perhaps). If the same do
nothing. If different, delete the original rule, insert a
newly-constructed one, and echo the new IP to the tmp file. Depending
on the lease-length (or whatever other factor may determine lifespan of
a given IP for www.myhostname.com...) and frequency of expected
connections, you'd set the frequency of the job accordingly.
Depending on what services are being made available to
www.myhostname.com, the first solution is probably your best bet so long
as it doesn't open up anything critical. For my case, the rule only
opens SSH, and only a single non-root user can login with SSH on that
box. (and all SSH access is logged)
The third solution, of course, would be to dig into the source and write
a new match, or patch the "-s" match with a new flag like "--dynip" and
the obvious support to enable that... ;^) Checking the current IP of a
named host for every packet would be impossible. The only feasible
solution here would be to integrate the effect of the cron job approach
into the netfilter code, periodically confirming the IP and updating if
needed.
> Thanks
> Florian
j
next prev parent reply other threads:[~2003-04-18 15:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-18 11:57 host names and IPs Florian Effenberger
2003-04-18 15:41 ` Joel Newkirk [this message]
2003-04-22 16:05 ` bill davidsen
2003-04-22 20:11 ` Michael K
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1050680509.6664.27.camel@alpha.newkirk.us \
--to=netfilter@newkirk.us \
--cc=floeff@arcor.de \
--cc=netfilter@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox