1

Topic: How to install and configure nftables (firewall) in Hyperbola.

Hi all . Please tell me how to configure nftables (firewall) correctly.
I couldn’t find any information on the forum or wiki, in my opinion this is the first thing you need to do after installing the distro.

The syntax of this firewall is much longer than that of ufw

I would like to configure the rules after enabling the firewall.

1. Deny all incoming and outgoing connections.

2. Allow outgoing connections on a specific interface (eth0,wlan0)

3. Allow outgoing connection for a specific port (80,443,22)

2

Re: How to install and configure nftables (firewall) in Hyperbola.

I'm myself not that deep into this, but I can provide an example from Emulatorman as he is working with.

#!/sbin/nft -f
# vim:set ts=4:

# Clear all prior state
flush ruleset

# ----- IPv4/IPv6 -----
table inet filter {
    chain input {
        type filter hook input priority 0; policy drop;
        ct state invalid counter drop \
        comment "early drop of invalid packets"
        ct state {established, related} counter accept \
        comment "accept all connections related to connections made by us"
        iif lo accept \
        comment "accept loopback"
        iif != lo ip daddr 127.0.0.1/8 counter drop \
        comment "drop connections to loopback not coming from loopback"
        iif != lo ip6 daddr ::1/128 counter drop \
        comment "drop connections to loopback not coming from loopback"

        ip saddr 10.1.1.2 accept \
        comment "accept connection from foo's vpn address (sample1)"
        ip saddr 10.2.1.2 accept \
        comment "accept connection from bar's vpn address (sample2)"

        ip protocol icmp icmp type {
            echo-reply,  # type 0
            destination-unreachable,  # type 3
            echo-request,  # type 8
            time-exceeded,  # type 11
            parameter-problem,  # type 12
        } accept \
        comment "Accept ICMP"
        counter comment "count dropped packets"

        ip6 nexthdr icmpv6 icmpv6 type {
            destination-unreachable,  # type 1
            packet-too-big,  # type 2
            time-exceeded,  # type 3
            parameter-problem,  # type 4
            echo-request,  # type 128
            echo-reply,  # type 129
        } accept \
        comment "Accept basic IPv6 functionality"

        ip6 nexthdr icmpv6 icmpv6 type {
            nd-router-solicit,  # type 133
            nd-router-advert,  # type 134
            nd-neighbor-solicit,  # type 135
            nd-neighbor-advert,  # type 136
        } ip6 hoplimit 255 accept \
        comment "Allow IPv6 SLAAC"

        ip6 nexthdr icmpv6 icmpv6 type {
            mld-listener-query,  # type 130
            mld-listener-report,  # type 131
            mld-listener-reduction,  # type 132
            mld2-listener-report,  # type 143
        } ip6 saddr fe80::/10 accept \
        comment "Allow IPv6 multicast listener discovery on link-local"

        ip6 saddr fe80::/10 udp sport 547 udp dport 546 accept \
        comment "Accept DHCPv6 replies from IPv6 link-local addresses"
        counter comment "count dropped packets"
    }

    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;
    }
}
Human being in favor with clear principles and so also for freedom in soft- and hardware!

Certainly anyone who has the power to make you believe absurdities has the power to make you commit injustices: For a life of every being full with peace and kindness, including diversity and freedom. Capitalism is destroying our minds, the planet itself and the universe in the end!

3

Re: How to install and configure nftables (firewall) in Hyperbola.

Thank you for your answer . What command did you use to get this output?

$ doas nft list ruleset 

Why was UFW removed? For the user there is a simpler and more understandable syntax, I looked at the UFW dependencies https://git.alpinelinux.org/aports/tree … /APKBUILD, this is iptables and python3, there is nothing wrong..

It seems to me that the wiki should indicate the basic firewall settings or an explanation of how to set up the firewall from the very beginning, I don’t think that an ordinary user would write parvils like this))

# nft flush ruleset
# nft add table ip FIREWALLIPv4
# nft add chain ip FIREWALLIPv4 INCOMING { type filter hook input priority 0 \; policy drop \; }
# nft add chain ip FIREWALLIPv4 FORWARDING { type filter hook forward priority 0 \; policy drop \; }
# nft add chain ip FIREWALLIPv4 OUTGOING { type filter hook output priority 0 \; policy accept \; }
# nft add rule ip FIREWALLIPv4 INCOMING iifname "lo" counter accept
# nft add rule ip FIREWALLIPv4 INCOMING ct state related,established counter accept
# nft add rule ip FIREWALLIPv4 INCOMING iifname "eth0" ip saddr 10.1.5.0/24 ct state new tcp dport 22 counter accept comment \"Allow access to SSH-server\"
# nft add rule ip FIREWALLIPv4 INCOMING iifname "eth0" ip saddr 10.1.0.0/13 ct state new icmp type echo-request counter accept comment \"Allow ping\"
# nft add rule ip FIREWALLIPv4 INCOMING iifname "eth0" ip saddr 10.1.0.0/13 ct state new tcp dport {80, 443} counter accept comment \"Allow access to Web-server\"
# nft add table ip6 FIREWALLIPv6
# nft add chain ip6 FIREWALLIPv6 INCOMING { type filter hook input priority 0 \; policy drop \; }
# nft add chain ip6 FIREWALLIPv6 FORWARDING { type filter hook forward priority 0 \; policy drop \; }
# nft add chain ip6 FIREWALLIPv6 OUTGOING { type filter hook output priority 0 \; policy accept \; }

4

Re: How to install and configure nftables (firewall) in Hyperbola.

You know, I find it a bit funny because we two indirect go through most packages as you have questions why some are not there and in fact we go through most of them with explanations. smile No, this is NOT criticism. Not even sarcasm. But I find it nevertheless important to not underestimate the reasonings given. So I'm happy to explain here: The problem is iptables as Hyperbola did the decision to ditch it complete and only orient on nftables.

I did try to evaluate a possible integration, but we ended again only to add another layer on top of nftables (here). See the effort doing this was and is too high with less outcome for Hyperbola as future BSD-system.

Next to look into the packaging-script from Alpine as ufw is ONLY GNU/Linux: https://pkgs.org/download/ufw

So it brings us nothing for HyperbolaBSD. I hope I was able to explain a bit more the reasoning behind. Please also remember our GNU/Linux-libre system is exactly going in the direction build up the base for HyperbolaBSD. So we have it easier with porting. smile It is not meant to be developed parallell.

Human being in favor with clear principles and so also for freedom in soft- and hardware!

Certainly anyone who has the power to make you believe absurdities has the power to make you commit injustices: For a life of every being full with peace and kindness, including diversity and freedom. Capitalism is destroying our minds, the planet itself and the universe in the end!

5

Re: How to install and configure nftables (firewall) in Hyperbola.

If you don't mind: Please stop comparisons with other system-distributions, jim. Those comparisons do not help foremost. They are only telling more about those system-distributions, not about Hyperbola. Since version 0.4 there was no ufw and per definition it was never removed. The version 0.4 was rebuild from scratch: All the PKGBUILDs are ours now. In versions before this was done with a snapshot and only partwise rebuilding and replacing.

Human being in favor with clear principles and so also for freedom in soft- and hardware!

Certainly anyone who has the power to make you believe absurdities has the power to make you commit injustices: For a life of every being full with peace and kindness, including diversity and freedom. Capitalism is destroying our minds, the planet itself and the universe in the end!

6

Re: How to install and configure nftables (firewall) in Hyperbola.

Thank you for your answer .
I would like to answer you about the comparison. To give me an example, I need to take it from somewhere, I take the example of Arch-like systems, if it’s convenient for you, I can take an example from git Arch.

I think users who read us understand perfectly well that this is just an example and not a comparison, there is no point in digital jealousy)) (my expression)


I think that they will never compare what is made from scratch. And if they took some distro as a base for their system from one place and then added (changed) something else and called it something else, then users understand this, so they will always compare since this is not a product made from scratch (from the very beginning)
If you paint a potato red, it will not become a tomato)) It will be a red potato!

As for iptables and nftables, do you know that these are the same developers?)) They simply remade iptables from a syntax point of view, nothing special.

I looked at iptables, the dependencies https://gitlab.archlinux.org/archlinux/ … 1eec9bbbd0 are all there in Hyperbola, can I build it? Personally, I find the UFW syntax more convenient and clearer.

If we are talking about HyperbolaBSD, then the pf firewall is not as complex as ufw in terms of syntax, but at the moment I would use ufw.

7

Re: How to install and configure nftables (firewall) in Hyperbola.

Sure thing, comparisons are also a point to support and help. From our both perspectives this is a conclusion and logic. I only can reflect and give you the feedback we have received over the years. Hyperbola has many packages and scripts build direct from scratch and no other system has those. The issue is from my point also given where some people root Hyperbola: As long-term Arch-comparable system. Sure thing we have the same package-management and also very clear basics but also very different goals. So I think we need to change Hyperbolas description at the FSF next for 0.4.5 to come. Perhaps as a proposal: What do you think about a community-question as thread? Collecting proposals and create together a newer, better description for Hyperbola. smile

About iptables: If you can build it? Sure thing. Only be careful about your system: I would give you the recommendation first to try it with qemu and qtemu (for managing). Just to make sure for yourself.

Human being in favor with clear principles and so also for freedom in soft- and hardware!

Certainly anyone who has the power to make you believe absurdities has the power to make you commit injustices: For a life of every being full with peace and kindness, including diversity and freedom. Capitalism is destroying our minds, the planet itself and the universe in the end!

8

Re: How to install and configure nftables (firewall) in Hyperbola.

Hello . Thanks for your answer and clarification.

I am sure that when the Hyperbola project has a larger financial budget, you will be able to create your own system from scratch. You need a good large team of professionals to do this, this is obviously like 2x2)) It is impossible to create complex projects when you have a team of 3 people. If you analyze donations over recent years, you will see that this is very little and the trend is not improving.

Perhaps when you create HyperbolaBSD the situation will improve, the professional community knows that some of the most secure server solutions are OpenBSD systems, if not the most secure in the world.
A certain number of users will switch to you, which will give you opportunities for development (my opinion)

As for assembling iptables, I tried it yesterday but got an error, I wanted to ask you for help with the assembly since you are the best))

So, my steps:

Clone

$ git clone  https://gitlab.archlinux.org/archlinux/packaging/packages/iptables.git
$ cd iptables 
$ makepkg -si 

There was an error with the gpg key, ok

$ gpg --keyserver hkps://keyserver.ubuntu.com  --recv-keys D55D978A8A1420E4

check

$ gpg -k 


Next I needed to download several packages, and then I encountered errors that drove me in circles))


mkdir: cannot create directory 'build' : File exists
==> ERROR: A failure occurred in prapare().
    Aborting

ok

$ rm -rf src/
$ makepkg -si 
***Error: no suitable 'libnftnl' found 
   Please install the 'libnftnl' package
   Or consider  --disable-nftables to skip
   iptables-compat over nftables support.
==> ERROR: A failure occurred in prapare().
    Aborting

libnftnl was installed, I reinstalled it and then everything went in circles again


Maybe I need to install an older version?

9 (edited by jim 2024-01-11 14:08:52)

Re: How to install and configure nftables (firewall) in Hyperbola.

I understood what needed to be done, I downloaded and compiled a new library https://gitlab.archlinux.org/archlinux/ … s/libnftnl and everything worked

To install iptables, you need to remove nftables (if installed) and disable all services

10

Re: How to install and configure nftables (firewall) in Hyperbola.

Please understand: Complexity <> minimalism. We have no interest in more complexity as we want to reduce that. The financials are common point every project has, which sound a bit more uncommon. So people are either not interested or reject it from the very beginning. So we are "okay" with having a niche for really interested people. The point here is another: People being interested is one thing, another one people understanding also that free, libre software is living from getting hands on and support. Getting a team together builds also upon getting people to get in touch, communicate, test out, document (and stay on documentation) and make feedback.

We had therefore different not so positive experiences in the past as some people promised very much, but later did not hold on for their promises given. May it be:

- Giving a helping hand, perhaps with creating handbooks or whatever else in the project around
- Just testing a bit more
- Support with development (while pretending to have experiences)
- Donate surely money when they said months ago (never reporting back afterwards)
- Ask around who is willing to support further in different fields
- Document in the wiki and stay onwards with the corresponding article (including testing)

.. or even just this: Pretend to work with and for Hyperbola, when they have not even Hyperbola installed or want not to bother with doing so. Yes, all of this was and is experience. And exactly therefore we are a bit tired in those directions. Sure, everyone has a different perspective and may take it more easy or not. In the end: When you give much time, personal engagement and called "heart bleed" into such a project, you have therefore a very strong perspective on having it safe. And the bigger any community, the lesser safe a project gets from experience spoken: There are more people wanting feature X and addition Y, which consults into more problems possible. And we had also people thinking to get into Hyperbola and make it their own playfield and toy, just for their current fun - with really not friendly discussions followed after. So we tried best to keep Hyperbola as project safe, working and going on. But it is also an illusion to compare Hyperbola with other projects with just a complete different goal: Hyperbola is and will be a little but stable and long-term meant operating-system as BSD-descendant, most near to UNIX as possible. It gets towards clients and servers, giving users technical emancipation and freedom for their data with demanding surely their own learning. What Hyperbola is NOT: A BSD-base with more and more packages added, a resulting more complex system with another empty promise of being "self-aware". Nope, that's not the point! smile

And we had many talks with people stating that Hyperbola "needs to be more bigger", "needs to be all around", "needs to support all common architectures for CPUs" and so much more. All of this is only one thing: A dreamcastle-building as in the end Hyperbola won't be different to any other system out there and forgetting about its roots and ideas. So yes: A niche, but with the issue that people need to understand that phrases like "sharing is caring" are more than phrases and a helping hand for building is also valuable, same as giving some money every month, not the big amount just to support. The other way is to be seen elsewhere: Projects giving big news like yearly congress and more, while looking close enough those "events" are just more sponsored and the projects are driven into full dependency of other groups (nothing in special, can be a wide variety). And some point? Those projects get the call to "implement" something or the donation and sponsorship is gone, while the community thinks nevertheless all is "independent done". That's the dreamcastle, that's the illusion. And "getting bigger" is not the answer for this.

Human being in favor with clear principles and so also for freedom in soft- and hardware!

Certainly anyone who has the power to make you believe absurdities has the power to make you commit injustices: For a life of every being full with peace and kindness, including diversity and freedom. Capitalism is destroying our minds, the planet itself and the universe in the end!

11

Re: How to install and configure nftables (firewall) in Hyperbola.

jim wrote:

I understood what needed to be done, I downloaded and compiled a new library https://gitlab.archlinux.org/archlinux/ … s/libnftnl and everything worked

To install iptables, you need to remove nftables (if installed) and disable all services

As said: That's the complete wrong way in our perspective, the point to exclude iptables and therefore depending packages like ufw.

Human being in favor with clear principles and so also for freedom in soft- and hardware!

Certainly anyone who has the power to make you believe absurdities has the power to make you commit injustices: For a life of every being full with peace and kindness, including diversity and freedom. Capitalism is destroying our minds, the planet itself and the universe in the end!

12

Re: How to install and configure nftables (firewall) in Hyperbola.

I compiled iptables and tried to launch ufw, but I got this error that I need to fix

$ doas ufw enable 

ERROR: problem running ufw-init
modprobe: FATAL: Module ip_tables not found in directory /lib/modules/5.10.127-gnu1-1-lts
iptables v1.8.10 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
modprobe: FATAL: Module ip_tables not found in directory /lib/modules/5.10.127-gnu1-1-lts
iptables v1.8.10 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
modprobe: FATAL: Module ip_tables not found in directory /lib/modules/5.10.127-gnu1-1-lts
iptables v1.8.10 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

I also can't use the ip command

13 (edited by jim 2024-01-11 17:07:31)

Re: How to install and configure nftables (firewall) in Hyperbola.

Why can't I install iproute2 (ip) separately?

When I try to install this program, is the nftables firewall installed along with it?

14

Re: How to install and configure nftables (firewall) in Hyperbola.

You need to analyze the differences of Hyperbola as system, jim. Here is the dependency-tree for our iproute2:

    libelf
    nftables
    linux-atm (optional) - ATM support
    linux-atm (make)
    quilt (make)

And as you have noted to have taken the source-data from Arch GNU/Linux, here is the iproute2 from Arch GNU/Linux:

    glibc
    iptables
    libbpf
    libcap
    libelf
    db5.3 (optional) - userspace arp daemon
    linux-atm (optional) - ATM support
    python (optional) - for routel
    linux-atm (make)

So you see that it is not enough to remove nftables. You need to modify several more packages and rebuild them on your purpose. You can do that, if you like. But please: Do not await any further support in this, only notes like I do now. Again to underline as in the long post above: Yes, you are able to do and modify. But no, we are not supporting every single modification here. If we are doing that: Sure, then we need a team bigger than everything other. You need to analyze the dependencies and conclude what you need. If you modify your system that way and readd packages being excluded out of reasoning before when the system was rebuild from scratch, you will encounter issues and problems on that way.

Human being in favor with clear principles and so also for freedom in soft- and hardware!

Certainly anyone who has the power to make you believe absurdities has the power to make you commit injustices: For a life of every being full with peace and kindness, including diversity and freedom. Capitalism is destroying our minds, the planet itself and the universe in the end!

15

Re: How to install and configure nftables (firewall) in Hyperbola.

Okay, you'll have to spend time on nftable, it's a pity that you can't collect ufw

I understand .
This is an example not a comparison

https://archlinux.org/packages/core/x86_64/iproute2/ 
Dependencies (6)

    glibc
    iptables
    libbpf
    libcap
    libelf
    db5.3 (optional) - userspace arp daemon
    linux-atm (optional) - ATM support
    python (optional) - for routel
    linux-atm (make)

16

Re: How to install and configure nftables (firewall) in Hyperbola.

Here are the build-sources for iproute2: https://git.hyperbola.info:50100/packag … e/iproute2
You can modify that package also and add iptables if you want to do that. It is than surely your own iproute2, jim.

Human being in favor with clear principles and so also for freedom in soft- and hardware!

Certainly anyone who has the power to make you believe absurdities has the power to make you commit injustices: For a life of every being full with peace and kindness, including diversity and freedom. Capitalism is destroying our minds, the planet itself and the universe in the end!

17

Re: How to install and configure nftables (firewall) in Hyperbola.

Thank you very much for the information. I wanted to clarify with you, maybe I made a mistake when I downloaded iptables instead of iptables-openrc and ufw instead of ufw-openrc, can you confirm this? I saw that there are other options.

https://gitea.artixlinux.org/packages?s … q=iptables   (this is an example not a comparison)

18

Re: How to install and configure nftables (firewall) in Hyperbola.

No problem in those cases for sure. big_smile

The openrc, dinit and so on packages are having the corresponding service-declarations. You need nevertheless the original package. If you want I explain what those declarations are.

Human being in favor with clear principles and so also for freedom in soft- and hardware!

Certainly anyone who has the power to make you believe absurdities has the power to make you commit injustices: For a life of every being full with peace and kindness, including diversity and freedom. Capitalism is destroying our minds, the planet itself and the universe in the end!

19 (edited by jim 2024-01-11 19:56:37)

Re: How to install and configure nftables (firewall) in Hyperbola.

I tried to build iproute2  https://git.hyperbola.info:50100/packag … e/iproute2  and got an error

==> Retrieving sources...
  -> Downloading iproute2-5.9.0.tar.xz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   162  100   162    0     0    527      0 --:--:-- --:--:-- --:--:--   527
100  768k  100  768k    0     0   157k      0  0:00:04  0:00:04 --:--:--  179k
  -> Downloading iproute2-5.9.0.tar.sign...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   162  100   162    0     0    775      0 --:--:-- --:--:-- --:--:--   775
100   566  100   566    0     0   1196      0 --:--:-- --:--:-- --:--:--  1196
  -> Downloading iproute2_5.9.0-1.debian.tar.xz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
==> ERROR: Failure while downloading https://deb.debian.org/debian/pool/main/i/iproute2/iproute2_5.9.0-1.debian.tar.xz
    Aborting...

20

Re: How to install and configure nftables (firewall) in Hyperbola.

Tell me if you succeed in making ufw work without iptables and/or other bloated crap.

That would interest me indeed.

HyperbolaBSD: The Future of Secure Libre Lightweight Operating Systems!

21

Re: How to install and configure nftables (firewall) in Hyperbola.

Reworking package, but take this first: https://repo.hyperbola.info:50011/gnu-p … src.tar.lz

Human being in favor with clear principles and so also for freedom in soft- and hardware!

Certainly anyone who has the power to make you believe absurdities has the power to make you commit injustices: For a life of every being full with peace and kindness, including diversity and freedom. Capitalism is destroying our minds, the planet itself and the universe in the end!

22

Re: How to install and configure nftables (firewall) in Hyperbola.

Hello zapper . I'm trying, thanks for helping me Throgh.

Throgh thanks, I'll try it now

23

Re: How to install and configure nftables (firewall) in Hyperbola.

I tried to install and got an error  https://repo.hyperbola.info:50011/gnu-p … src.tar.lz

$ doas pacman -U iproute2-5.9.0-2.src.tar.lz
loading packages...
error: missing package metadata in iproute2-5.9.0-2.src.tar.lz
error: 'iproute2-5.9.0-2.src.tar.lz': invalid or corrupted package

24

Re: How to install and configure nftables (firewall) in Hyperbola.

Sorry if I was not clear: You should unpack that and find all needed sources within.
All packages here have their sources rooted in that folder. So you can access them any time.

But to make the difference:

pkg -> package (binary)
src -> sources (build-files, tarballs and so on)

Human being in favor with clear principles and so also for freedom in soft- and hardware!

Certainly anyone who has the power to make you believe absurdities has the power to make you commit injustices: For a life of every being full with peace and kindness, including diversity and freedom. Capitalism is destroying our minds, the planet itself and the universe in the end!

25

Re: How to install and configure nftables (firewall) in Hyperbola.

I built iproute2, also iptables and ufw, but when I try to run ufw I get an error with kernel modules.

ERROR: problem running ufw-init
modprobe: FATAL: Module ip_tables not found in directory /lib/modules/5.10.127-gnu1-1-lts
iptables v1.8.10 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)