All of lore.kernel.org
 help / color / mirror / Atom feed
* Filter based on string (or other content)
@ 2020-09-12 13:41 K. de Jong
  2020-09-13  0:45 ` Duncan Roe
       [not found] ` <55b116c5-5b29-f4bc-24ad-6d55a74a71c8@hajes.org>
  0 siblings, 2 replies; 5+ messages in thread
From: K. de Jong @ 2020-09-12 13:41 UTC (permalink / raw)
  To: netfilter

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

I switched to nftables, but I miss one key feature. That is the ability
to filter packets based on a string. The goal is to filter all traffic
going to facebook.com or m.facebook.com for a set of days and time
ranges. The time ranges and days features are present in nftables, I've
spotted them. So I'll not focus on that. nftables-translate gave
errors.


This is what I had in my iptables script:


---

# Some variables, there are used in the rules below
facebook_filters=("www.facebook.com" "fbcdn.net" "m.facebook.com")
week_fb_timestart="03:00:00"
week_fb_timestop="20:00:00"
weekend_fb_timestart="03:00:00"
weekend_fb_timestop="17:00:00"


# Create table called facebook, which includes day and time
specifications
iptables -A facebook -p tcp -m multiport --dports 80,443 -m conntrack
--ctstate NEW,RELATED,ESTABLISHED -m comment --comment "Reject Facebook
during the week" -m time --timestart "$week_fb_timestart" --timestop
"$week_fb_timestop" --weekdays Mon,Tue,Wed,Thu,Fri -j REJECT --reject-
with icmp-port-unreachable


# A rule that applies the string filter, created by a loop through the
facebook_filters array
for filter in "${facebook_filters[@]}"; do
  iptables -A FORWARD -i tun+ -s "$vpn_ipv4_sub" -m string --string
"$filter" --algo bm -j facebook
done


---

I can't seem to find an equal feature in nftables that can perform the
same like I do here in iptables. A filter based on IPs is not reliable,
so adding the IPs of facebook.com might work for a while, until those
IPs change.

Does anyone know a solution to do this with nftables?

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2020-09-14  4:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-12 13:41 Filter based on string (or other content) K. de Jong
2020-09-13  0:45 ` Duncan Roe
2020-09-13  8:49   ` G.W. Haywood
2020-09-14  4:17     ` Duncan Roe
     [not found] ` <55b116c5-5b29-f4bc-24ad-6d55a74a71c8@hajes.org>
2020-09-13 10:59   ` K. de Jong

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.