<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="http://dev1galaxy.org/extern.php?action=feed&amp;tid=2889&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / [Solved] How to load nftables rules at boot?]]></title>
		<link>http://dev1galaxy.org/viewtopic.php?id=2889</link>
		<description><![CDATA[The most recent posts in [Solved] How to load nftables rules at boot?.]]></description>
		<lastBuildDate>Tue, 12 Oct 2021 19:55:39 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=32054#p32054</link>
			<description><![CDATA[<p>For other readers of this thread: Note you may have other packages which install firewall rules (via nft or iptables-legacy or otherwise), which would conflict with the nft tables you want to load.</p><p>Actually, I&#039;d say that it&#039;s kind of a problem that <span class="bbc">nft</span> is highly visible, on the one hand, via <span class="bbc">/etc/nftables.conf</span>; and the <span class="bbc">nftables</span> is installed on account of <span class="bbc">network-manager</span> (assuming you&#039;ve installed that), but on the other hand - there is no associated service you could even query for status. Nor do you get any indication about how things might conflict with its use.</p>]]></description>
			<author><![CDATA[dummy@example.com (einpoklum)]]></author>
			<pubDate>Tue, 12 Oct 2021 19:55:39 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=32054#p32054</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=28575#p28575</link>
			<description><![CDATA[<div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>Yes, that&#039;s right.</p></div></blockquote></div><p>Cool. Thanks for confirming that. Another thing i&#039;m starting to get my head around is&#160; fitting into place <img src="http://dev1galaxy.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (ifdv44)]]></author>
			<pubDate>Sat, 27 Mar 2021 20:09:20 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=28575#p28575</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=28572#p28572</link>
			<description><![CDATA[<p>Yes, that&#039;s right.</p>]]></description>
			<author><![CDATA[dummy@example.com (Head_on_a_Stick)]]></author>
			<pubDate>Sat, 27 Mar 2021 18:00:42 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=28572#p28572</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=28559#p28559</link>
			<description><![CDATA[<div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>There are several kernel modules that provide the firewall functionality but the init script (or systemd unit file) is needed to load the user space process that actually runs the firewall.</p></div></blockquote></div><p>That user space process being the nft &quot;application&quot; that reads in the rules and passes to the kernel part of nf_tables ?</p>]]></description>
			<author><![CDATA[dummy@example.com (ifdv44)]]></author>
			<pubDate>Sat, 27 Mar 2021 11:53:55 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=28559#p28559</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=28557#p28557</link>
			<description><![CDATA[<p>Thank you for the correction...</p><p>As far as I&#039;m aware open-rc run levels are &quot;default, off, recovery and sysinit.&quot;</p><p>I thought the commented lines in the above script were left there from the sys-v script the file was used for.</p><p>I still not completely sure how this works... sorry for butting in.</p><p>I didn&#039;t see those other posts this morning when I added my 2 cents worth. </p><p>But, I&#039;m glad I found out some more about run levels and open-rc.</p>]]></description>
			<author><![CDATA[dummy@example.com (GlennW)]]></author>
			<pubDate>Sat, 27 Mar 2021 11:41:12 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=28557#p28557</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=28548#p28548</link>
			<description><![CDATA[<div class="quotebox"><cite>GlennW wrote:</cite><blockquote><div><p>Hi, my fw script is loaded by open-rc </p><p>It looks like this...</p><p>/home/glenn/build/firewall/fwautorun</p><div class="codebox"><pre><code>#!/bin/bash
### BEGIN INIT INFO
# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO
............</code></pre></div></div></blockquote></div><p>Glenn, If you check earlier in this thread e.g. contribution #7 you&#039;ll see that for Default-Start/stop you would normally (at least in sysvinit) use:</p><div class="codebox"><pre><code># Default-Start:  S
# Default-Stop:   0 6</code></pre></div><p>The reason to use S rather than 2 is that it executes as early as possible, which is a desirable feature of a firewall.</p><p>Is there no S level in open-rc?</p>]]></description>
			<author><![CDATA[dummy@example.com (Marjorie)]]></author>
			<pubDate>Fri, 26 Mar 2021 23:22:32 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=28548#p28548</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=28547#p28547</link>
			<description><![CDATA[<p>Hi, my fw script is loaded by open-rc </p><p>It looks like this...</p><p>/home/glenn/build/firewall/fwautorun</p><div class="codebox"><pre class="vscroll"><code>#!/bin/bash
### BEGIN INIT INFO
# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

case &quot;$1&quot; in
  start)

    sh /home/glenn/bin/nftfw.sh

    echo &quot;Nftables Firewall is now ON&quot;
    ;;
  stop)
    nft flush table filter
    nft flush table ip6 filter
    echo &quot;NFTABLES Firewall is OFF&quot;
    ;;
  *)
        echo &quot;Usage: /etc/init.d/fwautorun {start|stop}&quot;
        exit 1
        ;;
esac

exit 0</code></pre></div><p>I used gentoo, arch and debian guides when I set this up...<br /><a href="https://wiki.gentoo.org/wiki/Nftables/Examples#Typical_workstation_.28separate_IPv4_and_IPv6.29" rel="nofollow">https://wiki.gentoo.org/wiki/Nftables/E … nd_IPv6.29</a><br /><a href="https://wiki.archlinux.org/index.php/Nftables#Simple_stateful_firewall" rel="nofollow">https://wiki.archlinux.org/index.php/Nf … l_firewall</a><br /><a href="https://linux-audit.com/nftables-beginners-guide-to-traffic-filtering/" rel="nofollow">https://linux-audit.com/nftables-beginn … filtering/</a><br /><a href="https://wiki.debian.org/nftables#Should_I_replace_an_iptables_firewall_with_a_nftables_one.3F" rel="nofollow">https://wiki.debian.org/nftables#Should … les_one.3F</a></p><p>I found this somewhere, ... repeat, my init script is called fwautorun.sh, yours may be different.</p><div class="quotebox"><blockquote><div><p>cp&#160; &lt;path to init file&gt;...fwautorun /etc/init.d</p><p># update-rc.d nftables defaults</p><p>rc-update add nftables defaults</p><p>reboot.</p></div></blockquote></div><p>you may have this part sorted, but because it&#039;s mentioned in the start up script, I&#039;ll copy it here...</p><p>/home/glenn/bin/nftfw.sh</p><div class="codebox"><pre class="vscroll"><code>#!/bin/bash

# /home/glenn/build/firewalls/nftfw.sh

# load templates
#nft -f /usr/share/doc/nftables/examples/syntax/ipv4-filter       #loads the ipv4 template table (OS depandant address)
#nft -f /usr/share/doc/nftables/examples/syntax/ipv6-filter       #loads the ipv6 template table (OS depandant address)

# instead of using templates, we create our own.

nft add table filter
nft add table ip6 filter

nft add chain filter input { type filter hook input priority 0 \; }
nft add chain filter forward { type filter hook forward priority 0 \; }
nft add chain filter output { type filter hook output priority 0 \; }

nft add chain ip6 filter input { type filter hook input priority 0 \; }
nft add chain ip6 filter forward { type filter hook forward priority 0 \; }
nft add chain ip6 filter output { type filter hook output priority 0 \; }

# clean out any leftovers...

nft flush table filter
nft flush table ip6 filter

nft add rule filter input ct state established accept
nft add rule filter input ct state related accept
nft add rule filter input iif lo accept
nft add rule filter input tcp dport ssh counter log accept
nft add rule filter input counter log drop

nft add rule filter output ct state established accept
nft add rule filter output ct state related accept
nft add rule filter output oif lo accept
nft add rule filter output ct state new counter accept

nft add rule ip6 filter input ct state established accept
nft add rule ip6 filter input ct state related accept
nft add rule ip6 filter input iif lo accept
nft add rule ip6 filter input tcp dport ssh counter log accept

nft add rule ip6 filter input icmpv6 type nd-neighbor-solicit accept
nft add rule ip6 filter input icmpv6 type echo-request accept
nft add rule ip6 filter input icmpv6 type nd-router-advert accept
nft add rule ip6 filter input icmpv6 type nd-neighbor-advert accept

nft add rule ip6 filter input counter log drop

nft add rule ip6 filter output ct state established accept
nft add rule ip6 filter output ct state related accept
nft add rule ip6 filter output oif lo accept
nft add rule ip6 filter output ct state new counter accept

echo &quot;Nftables Firewall is now ON ... relay&quot;

exit 0</code></pre></div><p># /home/glenn/build/firewalls/nftfw-off.sh</p><div class="codebox"><pre><code>#!/bin/bash

# /home/glenn/build/firewalls/nftfw-off.sh

nft -f /usr/share/doc/nftables/examples/syntax/ipv4-filter             #loads the ipv4 template table
nft -f /usr/share/doc/nftables/examples/syntax/ipv6-filter             #loads the ipv6 template table

nft flush table filter
nft flush table ip6 filter

echo &quot;Nftables Firewall is now OFF&quot;

exit 0</code></pre></div><p>I hope this helps, Glenn</p>]]></description>
			<author><![CDATA[dummy@example.com (GlennW)]]></author>
			<pubDate>Fri, 26 Mar 2021 22:40:56 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=28547#p28547</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=28538#p28538</link>
			<description><![CDATA[<p>There are several kernel modules that provide the firewall functionality but the init script (or systemd unit file) is needed to load the user space process that actually runs the firewall.</p>]]></description>
			<author><![CDATA[dummy@example.com (Head_on_a_Stick)]]></author>
			<pubDate>Fri, 26 Mar 2021 18:15:29 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=28538#p28538</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=28537#p28537</link>
			<description><![CDATA[<p>Can i just check something and im still leanring about nf tables so could be way off. </p><p> If nf_tables is a kernel level module and likely to be loaded at boot time and active(assuming not explicitly deactivated the modules) , then is there any need to have a init.d script to start it ? Wont it start up and load rules then ? What am i missing&#160; ? Or is this just a belt and braces&#160; step to make sure any rules really are included at boot time ?</p>]]></description>
			<author><![CDATA[dummy@example.com (ifdv44)]]></author>
			<pubDate>Fri, 26 Mar 2021 18:02:45 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=28537#p28537</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=25823#p25823</link>
			<description><![CDATA[<div class="quotebox"><cite>Magnus wrote:</cite><blockquote><div><p>Or add a line in /etc/rc.local</p></div></blockquote></div><p>Anything in <span class="bbc">/etc/rc.local</span> is run late in the boot process so that would leave the network exposed, albeit very briefly. A proper init script is the best approach.</p>]]></description>
			<author><![CDATA[dummy@example.com (Head_on_a_Stick)]]></author>
			<pubDate>Thu, 12 Nov 2020 18:03:15 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=25823#p25823</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=25820#p25820</link>
			<description><![CDATA[<p>Or add a line in /etc/rc.local <span class="bbc">/usr/sbin/nft -f /etc/firewall.tables</span></p>]]></description>
			<author><![CDATA[dummy@example.com (Magnus)]]></author>
			<pubDate>Thu, 12 Nov 2020 13:36:50 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=25820#p25820</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=25802#p25802</link>
			<description><![CDATA[<div class="quotebox"><cite>Marjorie wrote:</cite><blockquote><div><p>Also </p><div class="codebox"><pre><code>$ sudo service nftables start
$ sudo service nftables status </code></pre></div><p>don&#039;t provide any output.</p></div></blockquote></div><p>Add <span class="bbc">INIT_VERBOSE=yes</span> to the definitions of environment variables in <span class="bbc">/etc/init.d/nftables</span>.</p>]]></description>
			<author><![CDATA[dummy@example.com (jdev)]]></author>
			<pubDate>Wed, 11 Nov 2020 11:14:45 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=25802#p25802</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=21230#p21230</link>
			<description><![CDATA[<p>Thanks, Head-on-a-stick, that works.</p><p>Note for anyone else searching on this topic, having edited the default run level values in /etc/init.d/nftables you have to remove any existing rc.d symlinks <em>before</em> you reset them, so:</p><div class="codebox"><pre><code>$ sudo update-rc.d nftables remove
$ sudo update-rc.d nftables defaults</code></pre></div><p>If you don&#039;t do that it wont just overwrite the existing symlinks (you do get a warning).</p><p>Also </p><div class="codebox"><pre><code>$ sudo service nftables start
$ sudo service nftables status </code></pre></div><p>don&#039;t provide any output. However I did check that the firewall was working as intended using nmap from a different pc on the network:</p><div class="codebox"><pre><code>$ sudo nmap --top-ports 500 mail
Starting Nmap 7.70 ( https://nmap.org ) at 2020-04-22 15:17 BST
Nmap scan report for mail (192.168.1.xx)
Host is up (0.0054s latency).
Not shown: 493 closed ports
PORT    STATE SERVICE
22/tcp  open  ssh
25/tcp  open  smtp
80/tcp  open  http
143/tcp open  imap
443/tcp open  https
587/tcp open  submission
993/tcp open  imaps
MAC Address: 2D:70:6B:23:64:91</code></pre></div><p>which are just the ports I had configured to be open.</p>]]></description>
			<author><![CDATA[dummy@example.com (Marjorie)]]></author>
			<pubDate>Wed, 22 Apr 2020 14:34:44 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=21230#p21230</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=21224#p21224</link>
			<description><![CDATA[<div class="quotebox"><cite>Marjorie wrote:</cite><blockquote><div><p>no start run levels are defined</p></div></blockquote></div><p>Good spot, I missed that.</p><p>I&#039;ve just run the sysd2v-0.2.sh script on the systemd nftables.service and it says</p><div class="codebox"><pre><code># Default-Start:  S
# Default-Stop:   0 6</code></pre></div><p>So try that.</p><p>EDIT: perhaps open a bug report for this on the Debian package, the maintainer might correct it.</p>]]></description>
			<author><![CDATA[dummy@example.com (Head_on_a_Stick)]]></author>
			<pubDate>Wed, 22 Apr 2020 12:26:30 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=21224#p21224</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Solved] How to load nftables rules at boot?]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=21205#p21205</link>
			<description><![CDATA[<p>I&#039;m setting up a mailserver and I&#039;m trying to use nftables on Beowulf rather than iptables and ufw.as I used to on ASCII.</p><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>Try</p><div class="codebox"><pre><code># cp /usr/share/doc/nftables/examples/sysvinit/nftables.init /etc/init.d
# update-rc.d nftables defaults</code></pre></div><p>Then reboot.</p></div></blockquote></div><p>Assuming I want to start nftables as a service (in the same way that systemd imitates). I would have to change this slightly: </p><div class="codebox"><pre><code>$ sudo cp /usr/share/doc/nftables/examples/sysvinit/nftables.init /etc/init.d/nftables
$ sudo chmod +x  /etc/init.d/nftables
$ sudo update-rc.d nftables defaults</code></pre></div><p>When I run </p><div class="codebox"><pre><code>$ sudo service nftables start</code></pre></div><p>and then </p><div class="codebox"><pre><code>$ sudo service nftables status </code></pre></div><p>there&#039;s no output from either and the process is not running.</p><p>I looks to me that the problem is that nftables, as supplied, isn&#039;t configured to start in any level:</p><p>/etc/init.d/nftables starts:</p><div class="codebox"><pre><code>#!/bin/sh
### BEGIN INIT INFO
# Provides:          nftables
# Required-Start:    $local_fs $network $remote_fs $syslog
# Required-Stop:     $local_fs $remote_fs $syslog
# Default-Start:
# Default-Stop:      0 1 2 3 4 5 6
# Short-Description: nftables firewall service
# Description:       nftables firewall system service
### END INIT INFO

# Author: Arturo Borrero Gonzalez &lt;arturo@debian.org&gt;
....</code></pre></div><p>So no start run levels are defined. Should this be amended before running update-rc.d, and should they be the &#039;standard&#039;?</p><div class="codebox"><pre><code># Default-Start:     2 3 4 5
# Default-Stop:      0 1 6</code></pre></div><p>It would be nice if the package could be devuanated for Beowulf as it&#039;s systemd specific as supplied in Debian.<br />I note there was some discussion about how to enable running on sysvinit back in 2015 when Arturo decided to only supply nftables.init as an example - but then not document what needed to be done to enable it.</p>]]></description>
			<author><![CDATA[dummy@example.com (Marjorie)]]></author>
			<pubDate>Tue, 21 Apr 2020 22:07:05 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=21205#p21205</guid>
		</item>
	</channel>
</rss>
