All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Help] Allow website using iptables
@ 2020-05-04  8:54 Lazuardi Nasution
  2020-05-04 14:00 ` John Haxby
  0 siblings, 1 reply; 9+ messages in thread
From: Lazuardi Nasution @ 2020-05-04  8:54 UTC (permalink / raw)
  To: netfilter; +Cc: Sơn Đỗ

Hi,

YouTube use SSL. So you can't match strings inside the packet, it is
encrypted.

Best regards,

On Mon, May 4, 2020, 15:40 Sơn Đỗ <sondd1096@gmail.com> wrote:

> I have a Linux router and using iptables 1.4 to configure the firewall.
>
> And I want to permit a device to access a certain website with a
> domain name and block other websites. So I have use some cmds in
> iptables below:
>
>
>
> iptables -N allow_chain
> iptables -A FORWARD -j allow_chain
> iptables -A allow_chain -m mac --mac-source 11:22:33:44:55:66 -m
> string --algo bm --string youtube -j ACCEPT
> iptables -A allow_chain -m mac --mac-source 11:22:33:44:55:66 -j DROP
>
>
> In this case, I want computer with MAC address 11:22:33:44:55:66
> connected to my Linux router can only access the youtube . But the
> result was not my expectation, after I apply those rules , my computer
> cannot access to youtube and other web also, it drop all internet
> connection . In my understanding, the rule with ACCEPT target was not
> apply even the package match with the condition, and all packages are
> handled in the rule with DROP target.
>
> So is there any thing wrong with my cmd? What was the problem ?
>
> Please help me, Thanks.
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Help] Allow website using iptables
  2020-05-04  8:54 [Help] Allow website using iptables Lazuardi Nasution
@ 2020-05-04 14:00 ` John Haxby
  2020-05-11 10:20   ` Sơn Đỗ
  0 siblings, 1 reply; 9+ messages in thread
From: John Haxby @ 2020-05-04 14:00 UTC (permalink / raw)
  To: Lazuardi Nasution; +Cc: netfilter, Sơn Đỗ

[-- Attachment #1: Type: text/plain, Size: 296 bytes --]



> On 4 May 2020, at 09:54, Lazuardi Nasution <mrxlazuardin@gmail.com> wrote:
> 
> YouTube use SSL. So you can't match strings inside the packet, it is
> encrypted.

Actually, in most cases you can: the first packet set will usually have the hostname in the SNI extension header.

jch

[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 268 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Help] Allow website using iptables
  2020-05-04 14:00 ` John Haxby
@ 2020-05-11 10:20   ` Sơn Đỗ
  2020-05-11 11:34     ` Reindl Harald
  0 siblings, 1 reply; 9+ messages in thread
From: Sơn Đỗ @ 2020-05-11 10:20 UTC (permalink / raw)
  To: netfilter

hi,
Do you guys have any idea to allow a certain website with a specific
MAC address ?
Thanks.

Vào Th 2, 4 thg 5, 2020 vào lúc 21:00 John Haxby
<john.haxby@oracle.com> đã viết:
>
>
>
> > On 4 May 2020, at 09:54, Lazuardi Nasution <mrxlazuardin@gmail.com> wrote:
> >
> > YouTube use SSL. So you can't match strings inside the packet, it is
> > encrypted.
>
> Actually, in most cases you can: the first packet set will usually have the hostname in the SNI extension header.
>
> jch

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Help] Allow website using iptables
  2020-05-11 10:20   ` Sơn Đỗ
@ 2020-05-11 11:34     ` Reindl Harald
  2020-05-11 11:48       ` Mauricio Tavares
  0 siblings, 1 reply; 9+ messages in thread
From: Reindl Harald @ 2020-05-11 11:34 UTC (permalink / raw)
  To: Sơn Đỗ, netfilter



Am 11.05.20 um 12:20 schrieb Sơn Đỗ:
> Do you guys have any idea to allow a certain website with a specific
> MAC address ?

that's not how the ip layer works
you don't have any MAC adress after a router

don#t get me wrong but you need to learn the absolute basics about
networking: https://en.wikipedia.org/wiki/OSI_model

> Vào Th 2, 4 thg 5, 2020 vào lúc 21:00 John Haxby
> <john.haxby@oracle.com> đã viết:
>>
>>
>>
>>> On 4 May 2020, at 09:54, Lazuardi Nasution <mrxlazuardin@gmail.com> wrote:
>>>
>>> YouTube use SSL. So you can't match strings inside the packet, it is
>>> encrypted.
>>
>> Actually, in most cases you can: the first packet set will usually have the hostname in the SNI extension header

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Help] Allow website using iptables
  2020-05-11 11:34     ` Reindl Harald
@ 2020-05-11 11:48       ` Mauricio Tavares
  2020-05-11 12:24         ` Marc SCHAEFER
  0 siblings, 1 reply; 9+ messages in thread
From: Mauricio Tavares @ 2020-05-11 11:48 UTC (permalink / raw)
  To: Reindl Harald; +Cc: Sơn Đỗ, Netfilter

On Mon, May 11, 2020 at 7:36 AM Reindl Harald <h.reindl@thelounge.net> wrote:
>
>
>
> Am 11.05.20 um 12:20 schrieb Sơn Đỗ:
> > Do you guys have any idea to allow a certain website with a specific
> > MAC address ?
>
> that's not how the ip layer works
> you don't have any MAC adress after a router
>
      What I read is that he wants to have an egress rule to block a
computer behind his router (private network) to reach youtube. If the
computer is in the same broadcast domain as the router, his request is
valid. I guess offending computer uses DHCP and he is looking for a
solution that accounts for that and expects user knows nothing about
MAC spoofing.

> don#t get me wrong but you need to learn the absolute basics about
> networking: https://en.wikipedia.org/wiki/OSI_model
>
> > Vào Th 2, 4 thg 5, 2020 vào lúc 21:00 John Haxby
> > <john.haxby@oracle.com> đã viết:
> >>
> >>
> >>
> >>> On 4 May 2020, at 09:54, Lazuardi Nasution <mrxlazuardin@gmail.com> wrote:
> >>>
> >>> YouTube use SSL. So you can't match strings inside the packet, it is
> >>> encrypted.
> >>
> >> Actually, in most cases you can: the first packet set will usually have the hostname in the SNI extension header

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Help] Allow website using iptables
  2020-05-11 11:48       ` Mauricio Tavares
@ 2020-05-11 12:24         ` Marc SCHAEFER
  0 siblings, 0 replies; 9+ messages in thread
From: Marc SCHAEFER @ 2020-05-11 12:24 UTC (permalink / raw)
  To: Mauricio Tavares; +Cc: Reindl Harald, S??n ?????, Netfilter

On Mon, May 11, 2020 at 07:48:13AM -0400, Mauricio Tavares wrote:
> valid. I guess offending computer uses DHCP and he is looking for a
> solution that accounts for that and expects user knows nothing about
> MAC spoofing.

I have done things like this but more with ebtables than iptables.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Help] Allow website using iptables
  2020-05-04  8:43 ` Alessandro Vesely
@ 2020-05-07  1:40   ` Trent W. Buck
  0 siblings, 0 replies; 9+ messages in thread
From: Trent W. Buck @ 2020-05-07  1:40 UTC (permalink / raw)
  To: netfilter

Sơn Đỗ, I agree with Alessandro.  Here are some additional comments.

Alessandro Vesely <vesely@tana.it> writes:
> On 04/05/2020 08:53, Sơn Đỗ wrote:
>> I have a Linux router and using iptables 1.4 to configure the firewall.

Note that iptables 1.4 is *really* old - about 2015 I think.
Consider upgrading if possible.

>> And I want to permit a device to access a certain website with a
>> domain name and block other websites. So I have use some cmds in
>> iptables below:
>> 
>> iptables -N allow_chain
>> iptables -A FORWARD -j allow_chain
>> iptables -A allow_chain -m mac --mac-source 11:22:33:44:55:66 -m string --algo bm --string youtube -j ACCEPT
>> iptables -A allow_chain -m mac --mac-source 11:22:33:44:55:66 -j DROP
>> 
>> In this case, I want computer with MAC address 11:22:33:44:55:66
>> connected to my Linux router can only access the youtube.
>
> Quite problematic, as it has to be able to access a name server to get the
> target IP, at least.  If you mean youtube.com, access to a number of ancillary
> Javascript providers (google.com, gstatic.com, and the like) may also have to
> be granted.

See also https://en.wikipedia.org/wiki/Deep_packet_inspection

> For a different approach, censorship is often applied by controlling the DNS resolver.  See:
> https://en.wikipedia.org/wiki/Internet_censorship#Content_suppression_methods

Another approach is to disable routing (ip_forward) altogether, and
instead require clients to use a forward proxy (e.g. squid).

The proxy can then choose what sites to allow.
HTTPS proxies using CONNECT, so per-domain ACLs are easy.
To e.g. allow https://example.com/index.html but block https://example.com/email.php,
you need the proxy to do a MITM attack on your users, see

    http://www.squid-cache.org/Doc/config/ssl_bump/

Note that your jurisdiction's privacy laws may forbid such techniques.

Both DNS and HTTP proxy methods are increasingly difficult to implement
as GUI web browsers get smarter about e.g. cert pinning and DNSSEC/DANE.
See e.g.

    https://en.wikipedia.org/wiki/Certificate_Transparency


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Help] Allow website using iptables
  2020-05-04  6:53 Sơn Đỗ
@ 2020-05-04  8:43 ` Alessandro Vesely
  2020-05-07  1:40   ` Trent W. Buck
  0 siblings, 1 reply; 9+ messages in thread
From: Alessandro Vesely @ 2020-05-04  8:43 UTC (permalink / raw)
  To: Sơn Đỗ, netfilter

Hi,

On 04/05/2020 08:53, Sơn Đỗ wrote:
> I have a Linux router and using iptables 1.4 to configure the firewall.
> 
> And I want to permit a device to access a certain website with a
> domain name and block other websites. So I have use some cmds in
> iptables below:
> 
> 
> 
> iptables -N allow_chain
> iptables -A FORWARD -j allow_chain
> iptables -A allow_chain -m mac --mac-source 11:22:33:44:55:66 -m string --algo bm --string youtube -j ACCEPT
> iptables -A allow_chain -m mac --mac-source 11:22:33:44:55:66 -j DROP
> 
> 
> In this case, I want computer with MAC address 11:22:33:44:55:66
> connected to my Linux router can only access the youtube.


Quite problematic, as it has to be able to access a name server to get the
target IP, at least.  If you mean youtube.com, access to a number of ancillary
Javascript providers (google.com, gstatic.com, and the like) may also have to
be granted.

For a different approach, censorship is often applied by controlling the DNS
resolver.  See:
https://en.wikipedia.org/wiki/Internet_censorship#Content_suppression_methods


> But the result was not my expectation, after I apply those rules , my
> computer cannot access to youtube and other web also, it drop all internet 
> connection.

I guess that depends on the default policy (iptables -P) you set.  The rules
quoted above only affect packets matching the given mac-source.


> In my understanding, the rule with ACCEPT target was not apply even the
> package match with the condition, and all packages are handled in the rule
> with DROP target.

I don't think that /every/ packet will contain that string.  Typically, a
"Host: youtube.com", header field will only appear in one of the first packets
after the TCP handshake.


HTH

Ale
-- 


























^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Help] Allow website using iptables
@ 2020-05-04  6:53 Sơn Đỗ
  2020-05-04  8:43 ` Alessandro Vesely
  0 siblings, 1 reply; 9+ messages in thread
From: Sơn Đỗ @ 2020-05-04  6:53 UTC (permalink / raw)
  To: netfilter

I have a Linux router and using iptables 1.4 to configure the firewall.

And I want to permit a device to access a certain website with a
domain name and block other websites. So I have use some cmds in
iptables below:



iptables -N allow_chain
iptables -A FORWARD -j allow_chain
iptables -A allow_chain -m mac --mac-source 11:22:33:44:55:66 -m
string --algo bm --string youtube -j ACCEPT
iptables -A allow_chain -m mac --mac-source 11:22:33:44:55:66 -j DROP


In this case, I want computer with MAC address 11:22:33:44:55:66
connected to my Linux router can only access the youtube . But the
result was not my expectation, after I apply those rules , my computer
cannot access to youtube and other web also, it drop all internet
connection . In my understanding, the rule with ACCEPT target was not
apply even the package match with the condition, and all packages are
handled in the rule with DROP target.

So is there any thing wrong with my cmd? What was the problem ?

Please help me, Thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-05-11 12:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-04  8:54 [Help] Allow website using iptables Lazuardi Nasution
2020-05-04 14:00 ` John Haxby
2020-05-11 10:20   ` Sơn Đỗ
2020-05-11 11:34     ` Reindl Harald
2020-05-11 11:48       ` Mauricio Tavares
2020-05-11 12:24         ` Marc SCHAEFER
  -- strict thread matches above, loose matches on Subject: below --
2020-05-04  6:53 Sơn Đỗ
2020-05-04  8:43 ` Alessandro Vesely
2020-05-07  1:40   ` Trent W. Buck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.