All of lore.kernel.org
 help / color / mirror / Atom feed
* How can I block all traffic from an IP range, irrespective of origin, going to, or coming from, using nftables in Debian 10
@ 2019-10-01 23:22 Jags
  2019-10-03 19:00 ` zrm
  0 siblings, 1 reply; 16+ messages in thread
From: Jags @ 2019-10-01 23:22 UTC (permalink / raw)
  To: netfilter

hello everyone,

I would like to block all traffic from an IP range (e.g.: 123.0.0.0/8), irrespective of its origin, going to, or coming from, using nftables firewall in Debian 10.

If I understand correctly, the following will block traffic originating from that IP range.

nft insert rule ip filter INPUT ip saddr 123.0.0.0/8 counter drop


But it will still allow traffic if it's in response to (or associated with) an application on my Debian machine.

The problem: When I run a torrent client and add any torrent, be it Debian/Ubuntu ISO or any other torrent, I can see a bunch of IPs from my ISP connects to the torrent.

Even if I add a torrent that have only 1 seed and no peer at all, I can see a lot of IPs from my ISP (with zero percent of torrent availability) in qBittorrent client. In fact, I have blocked like 100+ in qBittorrent but the new IPs still keep popping up under "peers".

So I'd like to block an IP range, irrespective of traffic origin, going to, or coming from, using nftables.


Thanks a lot in advance.



Here's my nftables.conf file:

:::::
#!/usr/sbin/nft -f

flush ruleset

table inet filter {

    chain input {
        type filter hook input priority 0; policy drop;

        iifname lo accept

        # ssh for internal network
        ip saddr 192.168.0.0/16 tcp dport 22 counter accept
        ct state established,related accept

        # Avoid brute force on ssh
        tcp dport 22 ct state new limit rate 10/minute accept

        # Early drop of invalid connections
        ct state invalid drop

        # VsFTPD
        ip saddr 192.168.0.0/16 tcp dport 20 counter accept
        ip saddr 192.168.0.0/16 tcp dport 21 counter accept
        ip saddr 192.168.0.0/16 tcp dport 990 counter accept
        ip saddr 192.168.0.0/16 tcp dport 40000-50000 counter accept


        # ICMP & IGMP
        ip saddr 192.168.0.0/16 icmp type echo-request counter accept
        icmp type echo-request counter drop
        ip protocol igmp drop

        # Everything else
        reject with icmpx type port-unreachable

        log flags all counter drop
        log prefix "[nftables] Input Denied: " flags all counter drop
    }
}
:::::

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

end of thread, other threads:[~2019-10-06 23:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-01 23:22 How can I block all traffic from an IP range, irrespective of origin, going to, or coming from, using nftables in Debian 10 Jags
2019-10-03 19:00 ` zrm
2019-10-04  9:45   ` Jags
2019-10-04 10:18     ` Reindl Harald
2019-10-04 10:44       ` Jags
2019-10-04 11:05         ` Reindl Harald
2019-10-04 12:21           ` Jags
2019-10-04 13:06             ` Reindl Harald
2019-10-04 14:28               ` Jags
2019-10-04 15:10                 ` Reindl Harald
2019-10-04 15:47                   ` Neal P. Murphy
2019-10-04 16:25                   ` Jags
2019-10-04 20:30                     ` Anton Rieger
2019-10-04 21:27                       ` Jags
2019-10-06 17:26                         ` sean darcy
2019-10-06 23:00                           ` Jags

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.