LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 06-12-2024, 04:09 PM   #1
icebowl
LQ Newbie
 
Registered: Jun 2024
Posts: 1

Rep: Reputation: 0
nftables {block ip from udp connection}


I am experimenting using nftables on a Raspberry Pi and Deb12. I am able to block tcp ip addresses as follows: ip saddr 192.168.1.98 counter packets 0 bytes 0 drop

The above will drop a tcp connections but not a udp connection.

Please throw me a bone.

Here is my current nttable.conf file (simple)

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

flush ruleset

table inet filter {
    chain input {
        type filter hook input priority 0;
        ip protocol icmp counter accept comment "accept all ICMP types - this is a ping"
        ip saddr 192.168.1.98 counter packets 0 bytes 0 drop
        ip saddr 192.168.1.7 counter packets 0 bytes 0 drop 
        # accept any localhost traffic
        iif lo accept

        # accept traffic originated from us
        ct state established,related accept

        # activate the following line to accept common local services
        tcp dport { 22, 80, 443} ct state new accept
        udp dport {4711,25565,5353 ,59122 ,57324 ,631,19132 ,45091 } ct state new accept

        # ICMPv6 packets which must not be dropped, see https://tools.ietf.org/html/rfc4890#section-4.4.1
        meta nfproto ipv6 icmpv6 type { destination-unreachable, packet-too-big, time-exceeded, parameter-problem, echo-reply, echo-request, nd-router-solicit, nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert, 148, 149 } accept
        ip6 saddr fe80::/10 icmpv6 type { 130, 131, 132, 143, 151, 152, 153 } accept
        

        # count and drop any other traffic
        counter drop
    }
    #from gentoo
    chain forward {
        type filter hook forward priority 0; policy drop;
        counter comment "count dropped packets"
    }

    # If you're not counting packets, this chain can be omitted.
    chain output {
        type filter hook output priority 0; policy accept;
        counter comment "count accepted packets"
    }
}
 
Old 06-18-2024, 10:59 PM   #2
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Devuan
Posts: 3,662
Blog Entries: 33

Rep: Reputation: 284Reputation: 284Reputation: 284
Hi, Welcome to LQ!

I found your question interesting for my vpn setup and...

During my search I found another post with considerable solutions...

pasting link here for others who may search here at LQ.

https://www.linux.org/threads/how-ca...ftables.50419/

Thank you

Last edited by GlennsPref; 06-18-2024 at 10:59 PM. Reason: spelling
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: OpenSnitch Application Firewall 1.4.0 Adds eBPF And nftables Support, Allow/Block Lists LXer Syndicated Linux News 0 09-11-2021 08:30 PM
forward UDP Broadcast from one subnet to another with nftables King Arthur Linux - Networking 0 03-02-2021 04:46 AM
nftables: how to self detect public/private network connection and chose appropriate chains? hanserikbusk Linux - Networking 0 05-12-2020 10:50 PM
nftables, portA tcp and portB udp in one rule bartgrefte Linux - Security 0 04-27-2020 11:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration