* How can I get rules with all resolved IPs for FQDN?
@ 2011-04-21 9:04 Brian Lu
2011-04-21 10:40 ` Jan Engelhardt
2011-04-22 11:00 ` /dev/rob0
0 siblings, 2 replies; 12+ messages in thread
From: Brian Lu @ 2011-04-21 9:04 UTC (permalink / raw)
To: netfilter
Hi All
I am having a problem about not all FQDN can work for iptables commands .
If I run an iptable command for www.google.com , it can work fine.
I can find 6 rules from the rules table.
[root@localhost iptables-1.3.5]# nslookup www.google.com
Server: 168.95.1.1
Address: 168.95.1.1#53
Non-authoritative answer:
www.google.com canonical name = www.l.google.com.
Name: www.l.google.com
Address: 64.233.183.104
Name: www.l.google.com
Address: 64.233.183.105
Name: www.l.google.com
Address: 64.233.183.106
Name: www.l.google.com
Address: 64.233.183.147
Name: www.l.google.com
Address: 64.233.183.99
Name: www.l.google.com
Address: 64.233.183.103
If I run an iptable command for www.facebook.com , it can't work fine.
I can only find a rule from the rules table.
[root@localhost iptables-1.3.5]# nslookup www.facebook.com
Server: 168.95.1.1
Address: 168.95.1.1#53
Non-authoritative answer:
Name: www.facebook.com
Address: 69.171.224.12
[root@localhost iptables-1.3.5]# nslookup www.facebook.com
Server: 168.95.1.1
Address: 168.95.1.1#53
Non-authoritative answer:
Name: www.facebook.com
Address: 69.171.224.11
[root@localhost iptables-1.3.5]# nslookup www.facebook.com
Server: 168.95.1.1
Address: 168.95.1.1#53
Non-authoritative answer:
Name: www.facebook.com
Address: 66.220.149.11
[root@localhost iptables-1.3.5]# nslookup www.facebook.com
Server: 168.95.1.1
Address: 168.95.1.1#53
Non-authoritative answer:
Name: www.facebook.com
Address: 66.220.158.25
[root@localhost iptables-1.3.5]# nslookup www.facebook.com
Server: 168.95.1.1
Address: 168.95.1.1#53
Non-authoritative answer:
Name: www.facebook.com
Address: 66.220.146.25
How can I get rules with all resolved IPs for this kind of FQDN?
Any suggestions will be appreciated!!!
Best regards,
Brian Lu
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How can I get rules with all resolved IPs for FQDN?
2011-04-21 9:04 How can I get rules with all resolved IPs for FQDN? Brian Lu
@ 2011-04-21 10:40 ` Jan Engelhardt
2011-04-22 7:19 ` Lu Brian
2011-04-22 11:00 ` /dev/rob0
1 sibling, 1 reply; 12+ messages in thread
From: Jan Engelhardt @ 2011-04-21 10:40 UTC (permalink / raw)
To: Brian Lu; +Cc: netfilter
On Thursday 2011-04-21 11:04, Brian Lu wrote:
> [root@localhost iptables-1.3.5]# nslookup www.facebook.com
> Server: 168.95.1.1
> Address: 168.95.1.1#53
>
> Non-authoritative answer:
> Name: www.facebook.com
> Address: 66.220.146.25
>
> How can I get rules with all resolved IPs for this kind of FQDN?
Using modern tools like iptables 1.4.10 - and host(8) FWIW.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How can I get rules with all resolved IPs for FQDN?
2011-04-21 10:40 ` Jan Engelhardt
@ 2011-04-22 7:19 ` Lu Brian
2011-04-22 9:22 ` Jan Engelhardt
0 siblings, 1 reply; 12+ messages in thread
From: Lu Brian @ 2011-04-22 7:19 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: netfilter@vger.kernel.org
Hi Jan
My prolem is when I type the command :
[root@localhost ~]# iptables -t nat -A POSTROUTING -s 192.168.3.0/24
-d www.google.com -j SNAT --to-source 192.168.3.254
I can get all resolved ips for the domain name :
[root@localhost ~]# iptables -t nat -L -vn
Chain PREROUTING (policy ACCEPT 2 packets, 104 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
3855 213K SNAT all -- * * 192.168.2.0/24
0.0.0.0/0 to:192.168.1.20
0 0 SNAT all -- * * 192.168.3.0/24
72.14.203.147 to:192.168.3.254
0 0 SNAT all -- * * 192.168.3.0/24
72.14.203.99 to:192.168.3.254
0 0 SNAT all -- * * 192.168.3.0/24
72.14.203.103 to:192.168.3.254
0 0 SNAT all -- * * 192.168.3.0/24
72.14.203.104 to:192.168.3.254
0 0 SNAT all -- * * 192.168.3.0/24
72.14.203.105 to:192.168.3.254
0 0 SNAT all -- * * 192.168.3.0/24
72.14.203.106 to:192.168.3.254
when i type the command :
[root@localhost ~]# iptables -t nat -A POSTROUTING -s 192.168.3.0/24
-d www.facebook.com -j SNAT --to-source 192.168.3.254
I can only get 1 new rule for the domain www.facebook.com
[root@localhost ~]# iptables -t nat -L -vn
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
3855 213K SNAT all -- * * 192.168.2.0/24
0.0.0.0/0 to:192.168.1.20
0 0 SNAT all -- * * 192.168.3.0/24
69.171.224.42 to:192.168.3.254
iptables command can resolve the domain name..www.google.com and
www.facebook.com can be resolved to many ips,but I can only get 1 rule
for www.facebook.com when i type an iptable command ....
2011/4/21 Jan Engelhardt <jengelh@medozas.de>:
>
> On Thursday 2011-04-21 11:04, Brian Lu wrote:
>
>> [root@localhost iptables-1.3.5]# nslookup www.facebook.com
>> Server: 168.95.1.1
>> Address: 168.95.1.1#53
>>
>> Non-authoritative answer:
>> Name: www.facebook.com
>> Address: 66.220.146.25
>>
>> How can I get rules with all resolved IPs for this kind of FQDN?
>
> Using modern tools like iptables 1.4.10 - and host(8) FWIW.
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How can I get rules with all resolved IPs for FQDN?
2011-04-22 7:19 ` Lu Brian
@ 2011-04-22 9:22 ` Jan Engelhardt
2011-04-22 10:05 ` Lu Brian
0 siblings, 1 reply; 12+ messages in thread
From: Jan Engelhardt @ 2011-04-22 9:22 UTC (permalink / raw)
To: Lu Brian; +Cc: netfilter@vger.kernel.org
On Friday 2011-04-22 09:19, Lu Brian wrote:
>
>when i type the command :
>[root@localhost ~]# iptables -t nat -A POSTROUTING -s 192.168.3.0/24
>-d www.facebook.com -j SNAT --to-source 192.168.3.254
>
>I can only get 1 new rule for the domain www.facebook.com
And why is that a problem? facebook.com resolves to only one address.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How can I get rules with all resolved IPs for FQDN?
2011-04-22 9:22 ` Jan Engelhardt
@ 2011-04-22 10:05 ` Lu Brian
2011-04-22 10:08 ` Jan Engelhardt
0 siblings, 1 reply; 12+ messages in thread
From: Lu Brian @ 2011-04-22 10:05 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: netfilter@vger.kernel.org
if u nslookup www.facebook.com,you can get different resolved ip
almost every time.
Many webs use this kind of wrr dns reply method. It means I need to
find out all of the resolved ip manually and then add rules for all of
the resolved ips...
2011/4/22 Jan Engelhardt <jengelh@medozas.de>:
>
> On Friday 2011-04-22 09:19, Lu Brian wrote:
>>
>>when i type the command :
>>[root@localhost ~]# iptables -t nat -A POSTROUTING -s 192.168.3.0/24
>>-d www.facebook.com -j SNAT --to-source 192.168.3.254
>>
>>I can only get 1 new rule for the domain www.facebook.com
>
> And why is that a problem? facebook.com resolves to only one address.
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How can I get rules with all resolved IPs for FQDN?
2011-04-22 10:05 ` Lu Brian
@ 2011-04-22 10:08 ` Jan Engelhardt
2011-04-22 10:35 ` Lu Brian
0 siblings, 1 reply; 12+ messages in thread
From: Jan Engelhardt @ 2011-04-22 10:08 UTC (permalink / raw)
To: Lu Brian; +Cc: netfilter@vger.kernel.org
On Friday 2011-04-22 12:05, Lu Brian wrote:
>if u nslookup www.facebook.com,you can get different resolved ip
>almost every time.
But you get only one, and that is what counts. And from that you cannot
make an assessment how many more addresses they potentially have.
>Many webs use this kind of wrr dns reply method. It means I need to
>find out all of the resolved ip manually and then add rules for all of
>the resolved ips...
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How can I get rules with all resolved IPs for FQDN?
2011-04-22 10:08 ` Jan Engelhardt
@ 2011-04-22 10:35 ` Lu Brian
2011-04-22 10:52 ` Jan Engelhardt
0 siblings, 1 reply; 12+ messages in thread
From: Lu Brian @ 2011-04-22 10:35 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: netfilter@vger.kernel.org
yes,..this is the problem ...
2011/4/22 Jan Engelhardt <jengelh@medozas.de>:
> On Friday 2011-04-22 12:05, Lu Brian wrote:
>
>>if u nslookup www.facebook.com,you can get different resolved ip
>>almost every time.
>
> But you get only one, and that is what counts. And from that you cannot
> make an assessment how many more addresses they potentially have.
>
>>Many webs use this kind of wrr dns reply method. It means I need to
>>find out all of the resolved ip manually and then add rules for all of
>>the resolved ips...
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How can I get rules with all resolved IPs for FQDN?
2011-04-22 10:35 ` Lu Brian
@ 2011-04-22 10:52 ` Jan Engelhardt
0 siblings, 0 replies; 12+ messages in thread
From: Jan Engelhardt @ 2011-04-22 10:52 UTC (permalink / raw)
To: Lu Brian; +Cc: netfilter@vger.kernel.org
On Friday 2011-04-22 12:35, Lu Brian wrote:
>>>if u nslookup www.facebook.com,you can get different resolved ip
>>>almost every time.
>>
>> But you get only one, and that is what counts. And from that you cannot
>> make an assessment how many more addresses they potentially have.
>
>yes,..this is the problem ...
So talk to facebook. It is not an iptables issue.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How can I get rules with all resolved IPs for FQDN?
2011-04-21 9:04 How can I get rules with all resolved IPs for FQDN? Brian Lu
2011-04-21 10:40 ` Jan Engelhardt
@ 2011-04-22 11:00 ` /dev/rob0
2011-04-22 12:31 ` Pandu Poluan
2011-04-25 2:04 ` Lu Brian
1 sibling, 2 replies; 12+ messages in thread
From: /dev/rob0 @ 2011-04-22 11:00 UTC (permalink / raw)
To: netfilter
On Thu, Apr 21, 2011 at 05:04:01PM +0800, Brian Lu wrote:
> Subject: How can I get rules with all resolved IPs for FQDN?
Having read the thread with Jan (pssst, Jan, host(1) is section 1,
not section 8 :) ) this looks a lot like an "XY problem". You want to
do X, but you are asking how to do Y.
"X" here appears to be to block or control access to Facebook Web
servers. To accomplish X, you chose iptables, which is the wrong
tool. So you ran into problems because you chose the wrong tool, and
now you're asking "Y".
The answer to Y ($SUBJECT) is that you can't. Your iptables(8)
command resolves the name exactly one time. Rules are entered into
the kernel based on the number of IP addresses returned.
Lookups for www.facebook.com return exactly one IP address, with a
two-minute TTL, every time you query Facebook's authoritative NS
servers.
for X in {1..10} ; do \
dig +short www.facebook.com. @glb1.facebook.com. ; \
done
I ran that and got 9 unique answers for 10 queries. Substituting
@glb2 for @glb1, again I got 9 unique answers, with some (but not
all) having been found in the first set.
The fact is: outside of Facebook itself, no one has any way to know
how many IP addresses they have set up to answer HTTP connections as
www.facebook.com. They use a very short TTL, which implies that they
might dynamically change the list of IP addresses as needed.
> I am having a problem about not all FQDN can work for iptables
> commands . If I run an iptable command for www.google.com , it can
> work fine. I can find 6 rules from the rules table.
BTW, Google and just about every other large site does variations of
the same thing. You're wrong if you think that your 6 IP addresses
found for www.google.com. are the ONLY 6 they use. They are the 6
presented to you as a choice at that particular moment.
As Jan tried to explain to you, this is how iptables works. Names
given are resolved only once. Bottom line: you can't rely on using
DNS names which you don't control.
The answer to your real question, "X", might be to hijack the DNS for
facebook.com. and other Internet domains as desired. Or perhaps more
likely, to force use of an HTTP proxy like Squid to control access.
I suspect that this all boils down to a clueless and ineffective
manager's desire to solve a social problem using technical means. :)
--
Offlist mail to this address is discarded unless
"/dev/rob0" or "not-spam" is in Subject: header
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How can I get rules with all resolved IPs for FQDN?
2011-04-22 11:00 ` /dev/rob0
@ 2011-04-22 12:31 ` Pandu Poluan
2011-04-25 1:56 ` Lu Brian
2011-04-25 2:04 ` Lu Brian
1 sibling, 1 reply; 12+ messages in thread
From: Pandu Poluan @ 2011-04-22 12:31 UTC (permalink / raw)
To: netfilter
On 2011-04-22, /dev/rob0 <rob0@gmx.co.uk>
> The fact is: outside of Facebook itself, no one has any way to know
> how many IP addresses they have set up to answer HTTP connections as
> www.facebook.com. They use a very short TTL, which implies that they
> might dynamically change the list of IP addresses as needed.
>
>> I am having a problem about not all FQDN can work for iptables
>> commands . If I run an iptable command for www.google.com , it can
>> work fine. I can find 6 rules from the rules table.
>
> BTW, Google and just about every other large site does variations of
> the same thing. You're wrong if you think that your 6 IP addresses
> found for www.google.com. are the ONLY 6 they use. They are the 6
> presented to you as a choice at that particular moment.
>
> As Jan tried to explain to you, this is how iptables works. Names
> given are resolved only once. Bottom line: you can't rely on using
> DNS names which you don't control.
>
> The answer to your real question, "X", might be to hijack the DNS for
> facebook.com. and other Internet domains as desired. Or perhaps more
> likely, to force use of an HTTP proxy like Squid to control access.
>
Another option would be to use ipset. Do a dig against
www.facebook.com every minute and feed any new address found into the
ipset.
But, then again, this is the *wrong* way to clamp down on facebook access :)
> I suspect that this all boils down to a clueless and ineffective
> manager's desire to solve a social problem using technical means. :)
*Wrong* technical means, you mean :)
Rgds,
--
Pandu E Poluan - IT Optimizer
My website: http://pandu.poluan.info/
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How can I get rules with all resolved IPs for FQDN?
2011-04-22 12:31 ` Pandu Poluan
@ 2011-04-25 1:56 ` Lu Brian
0 siblings, 0 replies; 12+ messages in thread
From: Lu Brian @ 2011-04-25 1:56 UTC (permalink / raw)
To: Pandu Poluan; +Cc: netfilter, Jan Engelhardt
I see...Thanks for everyone...
2011/4/22 Pandu Poluan <pandu@poluan.info>:
> On 2011-04-22, /dev/rob0 <rob0@gmx.co.uk>
>> The fact is: outside of Facebook itself, no one has any way to know
>> how many IP addresses they have set up to answer HTTP connections as
>> www.facebook.com. They use a very short TTL, which implies that they
>> might dynamically change the list of IP addresses as needed.
>>
>>> I am having a problem about not all FQDN can work for iptables
>>> commands . If I run an iptable command for www.google.com , it can
>>> work fine. I can find 6 rules from the rules table.
>>
>> BTW, Google and just about every other large site does variations of
>> the same thing. You're wrong if you think that your 6 IP addresses
>> found for www.google.com. are the ONLY 6 they use. They are the 6
>> presented to you as a choice at that particular moment.
>>
>> As Jan tried to explain to you, this is how iptables works. Names
>> given are resolved only once. Bottom line: you can't rely on using
>> DNS names which you don't control.
>>
>> The answer to your real question, "X", might be to hijack the DNS for
>> facebook.com. and other Internet domains as desired. Or perhaps more
>> likely, to force use of an HTTP proxy like Squid to control access.
>>
>
> Another option would be to use ipset. Do a dig against
> www.facebook.com every minute and feed any new address found into the
> ipset.
>
> But, then again, this is the *wrong* way to clamp down on facebook access :)
>
>> I suspect that this all boils down to a clueless and ineffective
>> manager's desire to solve a social problem using technical means. :)
>
> *Wrong* technical means, you mean :)
>
> Rgds,
> --
> Pandu E Poluan - IT Optimizer
> My website: http://pandu.poluan.info/
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How can I get rules with all resolved IPs for FQDN?
2011-04-22 11:00 ` /dev/rob0
2011-04-22 12:31 ` Pandu Poluan
@ 2011-04-25 2:04 ` Lu Brian
1 sibling, 0 replies; 12+ messages in thread
From: Lu Brian @ 2011-04-25 2:04 UTC (permalink / raw)
To: netfilter; +Cc: rob0
i see...thank you~
2011/4/22 /dev/rob0 <rob0@gmx.co.uk>:
> On Thu, Apr 21, 2011 at 05:04:01PM +0800, Brian Lu wrote:
>> Subject: How can I get rules with all resolved IPs for FQDN?
>
> Having read the thread with Jan (pssst, Jan, host(1) is section 1,
> not section 8 :) ) this looks a lot like an "XY problem". You want to
> do X, but you are asking how to do Y.
>
> "X" here appears to be to block or control access to Facebook Web
> servers. To accomplish X, you chose iptables, which is the wrong
> tool. So you ran into problems because you chose the wrong tool, and
> now you're asking "Y".
>
> The answer to Y ($SUBJECT) is that you can't. Your iptables(8)
> command resolves the name exactly one time. Rules are entered into
> the kernel based on the number of IP addresses returned.
>
> Lookups for www.facebook.com return exactly one IP address, with a
> two-minute TTL, every time you query Facebook's authoritative NS
> servers.
>
> for X in {1..10} ; do \
> dig +short www.facebook.com. @glb1.facebook.com. ; \
> done
>
> I ran that and got 9 unique answers for 10 queries. Substituting
> @glb2 for @glb1, again I got 9 unique answers, with some (but not
> all) having been found in the first set.
>
> The fact is: outside of Facebook itself, no one has any way to know
> how many IP addresses they have set up to answer HTTP connections as
> www.facebook.com. They use a very short TTL, which implies that they
> might dynamically change the list of IP addresses as needed.
>
>> I am having a problem about not all FQDN can work for iptables
>> commands . If I run an iptable command for www.google.com , it can
>> work fine. I can find 6 rules from the rules table.
>
> BTW, Google and just about every other large site does variations of
> the same thing. You're wrong if you think that your 6 IP addresses
> found for www.google.com. are the ONLY 6 they use. They are the 6
> presented to you as a choice at that particular moment.
>
> As Jan tried to explain to you, this is how iptables works. Names
> given are resolved only once. Bottom line: you can't rely on using
> DNS names which you don't control.
>
> The answer to your real question, "X", might be to hijack the DNS for
> facebook.com. and other Internet domains as desired. Or perhaps more
> likely, to force use of an HTTP proxy like Squid to control access.
>
> I suspect that this all boils down to a clueless and ineffective
> manager's desire to solve a social problem using technical means. :)
> --
> Offlist mail to this address is discarded unless
> "/dev/rob0" or "not-spam" is in Subject: header
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2011-04-25 2:04 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-21 9:04 How can I get rules with all resolved IPs for FQDN? Brian Lu
2011-04-21 10:40 ` Jan Engelhardt
2011-04-22 7:19 ` Lu Brian
2011-04-22 9:22 ` Jan Engelhardt
2011-04-22 10:05 ` Lu Brian
2011-04-22 10:08 ` Jan Engelhardt
2011-04-22 10:35 ` Lu Brian
2011-04-22 10:52 ` Jan Engelhardt
2011-04-22 11:00 ` /dev/rob0
2011-04-22 12:31 ` Pandu Poluan
2011-04-25 1:56 ` Lu Brian
2011-04-25 2:04 ` Lu Brian
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox