Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Port 0 and IPv4 Great... but hey what about IPv6 or inet6?

    Scheduled Pinned Locked Moved Firewalling
    port 0pfctl -srinet6ipv6acl
    15 Posts 2 Posters 235 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JonathanLeeJ
      JonathanLee
      last edited by JonathanLee

      if you noticed you have an auto added pfsense plus auto created rule

      block quick inet proto { tcp, udp } from any port = 0 to any
      

      This is ipv4 only.... if you use a ipv6 tunnel broker you will never see an ipv6 rule and guess what the GUI does not allow you to create a floating rule with port zero.

      Work around create a script so you get the rules like this

      block drop quick inet proto tcp from any port = 0 to any label "Block traffic from port 0" ridentifier 1000000114
      block drop quick inet proto udp from any port = 0 to any label "Block traffic from port 0" ridentifier 1000000114
      block drop quick inet proto tcp from any to any port = 0 label "Block traffic to port 0" ridentifier 1000000115
      block drop quick inet proto udp from any to any port = 0 label "Block traffic to port 0" ridentifier 1000000115
      block drop quick inet6 proto tcp from any port = 0 to any label "Block traffic from port 0" ridentifier 1000000116
      block drop quick inet6 proto udp from any port = 0 to any label "Block traffic from port 0" ridentifier 1000000116
      block drop quick inet6 proto tcp from any to any port = 0 label "Block traffic to port 0" ridentifier 1000000117
      block drop quick inet6 proto udp from any to any port = 0 label "Block traffic to port 0" ridentifier 1000000117
      

      /usr/local/etc/rc.d/block_port0.sh

      #!/bin/sh
      /sbin/pfctl -a "custom/block_port0" -v -f - <<EOF
      block drop quick inet proto { tcp udp } from any port = 0 to any label "Block from port 0 IPv4"
      block drop quick inet proto { tcp udp } from any to any port = 0 label "Block to port 0 IPv4"
      block drop quick inet6 proto { tcp udp } from any port = 0 to any label "Block from port 0 IPv6"
      block drop quick inet6 proto { tcp udp } from any to any port = 0 label "Block to port 0 IPv6"
      EOF
      
      

      make it executable.

      chmod +x /usr/local/etc/rc.d/block_port0.sh
      

      Add a cron job

      Screenshot 2025-07-08 at 11.57.23.png

      Bingo run

      pfctl -sr
      

      and now you have that block rule for ipv6 also it should show inet6.

      or a better script to include bogons

      #!/bin/sh
      /sbin/pfctl -a "custom/block_port0" -v -f - <<EOF
      
      # Block TCP/UDP packets with source or destination port 0 (IPv4)
      block drop quick inet proto { tcp udp } from any port = 0 to any label "Block from port 0 IPv4"
      block drop quick inet proto { tcp udp } from any to any port = 0 label "Block to port 0 IPv4"
      
      # Block TCP/UDP packets with source or destination port 0 (IPv6)
      block drop quick inet6 proto { tcp udp } from any port = 0 to any label "Block from port 0 IPv6"
      block drop quick inet6 proto { tcp udp } from any to any port = 0 label "Block to port 0 IPv6"
      
      # Block some spoofed IPv4 addresses
      block drop quick inet from 127.0.0.0/8 to any label "Block IPv4 loopback source"
      block drop quick inet from 0.0.0.0/8 to any label "Block IPv4 zero network"
      block drop quick inet from 169.254.0.0/16 to any label "Block IPv4 link-local source"
      block drop quick inet from 224.0.0.0/4 to any label "Block IPv4 multicast source"
      block drop quick inet from 240.0.0.0/5 to any label "Block IPv4 reserved source"
      
      # Block some spoofed IPv6 addresses
      block drop quick inet6 from ::1 to any label "Block IPv6 loopback source"
      block drop quick inet6 from ::/128 to any label "Block IPv6 unspecified source"
      block drop quick inet6 from fe80::/10 to any label "Block IPv6 link-local source"
      block drop quick inet6 from ff00::/8 to any label "Block IPv6 multicast source"
      
      EOF
      
      

      Make sure to upvote

      johnpozJ 1 Reply Last reply Reply Quote 0
      • JonathanLeeJ
        JonathanLee
        last edited by JonathanLee

        pfctl -s rules
        

        should show the rules loaded

        Make sure to upvote

        1 Reply Last reply Reply Quote 0
        • JonathanLeeJ
          JonathanLee
          last edited by JonathanLee

          Shell Output - pfctl -vvsr | grep "port = 0"
          
          
          @12 block drop quick inet proto tcp from any port = 0 to any label "Block traffic from port 0" ridentifier 1000000107
          @13 block drop quick inet proto udp from any port = 0 to any label "Block traffic from port 0" ridentifier 1000000107
          @14 block drop quick inet proto tcp from any to any port = 0 label "Block traffic to port 0" ridentifier 1000000108
          @15 block drop quick inet proto udp from any to any port = 0 label "Block traffic to port 0" ridentifier 1000000108
          
          Shell Output - pfctl -vvsr -a custom/block_port0 | grep "port = 0"
          
          @0 block drop quick inet proto tcp from any port = 0 to any label "Block from port 0 IPv4"
          @1 block drop quick inet proto udp from any port = 0 to any label "Block from port 0 IPv4"
          @2 block drop quick inet proto tcp from any to any port = 0 label "Block to port 0 IPv4"
          @3 block drop quick inet proto udp from any to any port = 0 label "Block to port 0 IPv4"
          @4 block drop quick inet6 proto tcp from any port = 0 to any label "Block from port 0 IPv6"
          @5 block drop quick inet6 proto udp from any port = 0 to any label "Block from port 0 IPv6"
          @6 block drop quick inet6 proto tcp from any to any port = 0 label "Block to port 0 IPv6"
          @7 block drop quick inet6 proto udp from any to any port = 0 label "Block to port 0 IPv6"
          

          Make sure to upvote

          1 Reply Last reply Reply Quote 0
          • JonathanLeeJ
            JonathanLee
            last edited by JonathanLee

            @JonathanLee said in Port 0 and IPv4 Great... but hey what about IPv6 or inet6?:

            pfctl -s rules

            something is not right because it should show also with pfctl -sr and it is not

            pfctl -sr -a custom/block_port0 # DOES show them

            Make sure to upvote

            JonathanLeeJ 1 Reply Last reply Reply Quote 0
            • JonathanLeeJ
              JonathanLee @JonathanLee
              last edited by

              @JonathanLee

              pfctl -vvsr -a custom/block_port0
              

              also works

              Make sure to upvote

              JonathanLeeJ 1 Reply Last reply Reply Quote 0
              • JonathanLeeJ
                JonathanLee @JonathanLee
                last edited by

                @JonathanLee

                pfctl -sr -a custom/block_port0
                

                So it works but they are not part of the main ruleset they are loaded and working

                Make sure to upvote

                1 Reply Last reply Reply Quote 0
                • johnpozJ
                  johnpoz LAYER 8 Global Moderator @JonathanLee
                  last edited by johnpoz

                  @JonathanLee said in Port 0 and IPv4 Great... but hey what about IPv6 or inet6?:

                  This is ipv4 only.... if you use a ipv6 tunnel broker you will never see an ipv6 rule and guess what the GUI does not allow you to create a floating rule with port zero.

                  huh.. the rules are there for both IPv4 and v6

                  cat /tmp/rules.debug

                  # We use the mighty pf, we cannot be fooled.
                  block  quick inet proto { tcp, udp } from any port = 0 to any ridentifier 1000000114 label "Block traffic from port 0"
                  block  quick inet proto { tcp, udp } from any to any port = 0 ridentifier 1000000115 label "Block traffic to port 0"
                  block  quick inet6 proto { tcp, udp } from any port = 0 to any ridentifier 1000000116 label "Block traffic from port 0"
                  block  quick inet6 proto { tcp, udp } from any to any port = 0 ridentifier 1000000117 label "Block traffic to port 0"
                  

                  An intelligent man is sometimes forced to be drunk to spend time with his fools
                  If you get confused: Listen to the Music Play
                  Please don't Chat/PM me for help, unless mod related
                  SG-4860 24.11 | Lab VMs 2.8, 24.11

                  JonathanLeeJ 1 Reply Last reply Reply Quote 0
                  • JonathanLeeJ
                    JonathanLee @johnpoz
                    last edited by

                    @johnpoz I noticed that my setup was missing part of the IPv6 rule, even though IPv6 is enabled. I'm not sure if it's due to the older version I'm using. Thanks for taking a look!

                    Make sure to upvote

                    johnpozJ 1 Reply Last reply Reply Quote 0
                    • johnpozJ
                      johnpoz LAYER 8 Global Moderator @JonathanLee
                      last edited by

                      @JonathanLee what version are you running?

                      An intelligent man is sometimes forced to be drunk to spend time with his fools
                      If you get confused: Listen to the Music Play
                      Please don't Chat/PM me for help, unless mod related
                      SG-4860 24.11 | Lab VMs 2.8, 24.11

                      JonathanLeeJ 1 Reply Last reply Reply Quote 0
                      • JonathanLeeJ
                        JonathanLee @johnpoz
                        last edited by

                        @johnpoz 25.03.01

                        Make sure to upvote

                        johnpozJ 1 Reply Last reply Reply Quote 0
                        • johnpozJ
                          johnpoz LAYER 8 Global Moderator @JonathanLee
                          last edited by

                          @JonathanLee so some old beta snapshot? Why?

                          An intelligent man is sometimes forced to be drunk to spend time with his fools
                          If you get confused: Listen to the Music Play
                          Please don't Chat/PM me for help, unless mod related
                          SG-4860 24.11 | Lab VMs 2.8, 24.11

                          JonathanLeeJ 1 Reply Last reply Reply Quote 1
                          • JonathanLeeJ
                            JonathanLee @johnpoz
                            last edited by

                            @johnpoz it is the last one where Squid status page works, I am using it to attempt to figure out why in the new versions the status page does not work correctly. Plus it is my everything works version. Just every thing works how I wanted in this version, I feel very strongly about this version. I would love to update but the Squid status page is not working for me in the new versions.

                            Make sure to upvote

                            johnpozJ 1 Reply Last reply Reply Quote 0
                            • johnpozJ
                              johnpoz LAYER 8 Global Moderator @JonathanLee
                              last edited by

                              @JonathanLee is there a thread where you give details of this status page not working? Is there a current redmine on it?

                              Using some old "beta" version is not proper way to go about getting something not working fixed.

                              An intelligent man is sometimes forced to be drunk to spend time with his fools
                              If you get confused: Listen to the Music Play
                              Please don't Chat/PM me for help, unless mod related
                              SG-4860 24.11 | Lab VMs 2.8, 24.11

                              JonathanLeeJ 2 Replies Last reply Reply Quote 0
                              • JonathanLeeJ
                                JonathanLee @johnpoz
                                last edited by JonathanLee

                                @johnpoz There is a redmine open on it yes.

                                This is it

                                https://redmine.pfsense.org/issues/15410

                                except it is now Squid 7.1 that is stable and has the issue

                                Make sure to upvote

                                1 Reply Last reply Reply Quote 0
                                • JonathanLeeJ
                                  JonathanLee @johnpoz
                                  last edited by

                                  @johnpoz This even does this with the newest CE edition inside of UTM virtualized environment outside of the 2100s

                                  Screenshot 2025-07-17 at 10.15.51.png

                                  It is not just the 2100s this is set up for standard stuff everything else works with it just the status page

                                  Make sure to upvote

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post
                                  Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.