<?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=6337&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / nftables init script]]></title>
		<link>http://dev1galaxy.org/viewtopic.php?id=6337</link>
		<description><![CDATA[The most recent posts in nftables init script.]]></description>
		<lastBuildDate>Tue, 09 Apr 2024 13:47:43 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=49458#p49458</link>
			<description><![CDATA[<p>Possibly because it depends on <span class="bbc">$syslog</span> which isn&#039;t started in the <span class="bbc">rcS</span> collection.</p>]]></description>
			<author><![CDATA[dummy@example.com (ralph.ronnquist)]]></author>
			<pubDate>Tue, 09 Apr 2024 13:47:43 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=49458#p49458</guid>
		</item>
		<item>
			<title><![CDATA[Re: nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=49457#p49457</link>
			<description><![CDATA[<p>Adding</p><div class="quotebox"><blockquote><div><p># Required-Start: $local_fs</p></div></blockquote></div><p>to the test script makes it work as intended, my bad:</p><div class="codebox"><pre><code># cat /root/test.txt
Tue Apr 9 15:34:39 CEST 2024 stop
Tue Apr 9 15:34:56 CEST 2024 start</code></pre></div><p>But still I don&#039;t understand why nftables does not load the ruleset on boot with:</p><div class="quotebox"><blockquote><div><p># Default-Start: S</p></div></blockquote></div><p>but it does with:</p><div class="quotebox"><blockquote><div><p># Default-Start: 2 3 4 5</p></div></blockquote></div>]]></description>
			<author><![CDATA[dummy@example.com (davide)]]></author>
			<pubDate>Tue, 09 Apr 2024 13:43:07 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=49457#p49457</guid>
		</item>
		<item>
			<title><![CDATA[Re: nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=49456#p49456</link>
			<description><![CDATA[<p>Maybe try also with </p><div class="codebox"><pre><code># Required-Start: $local_fs</code></pre></div><p>as otherwise the root filesystem might still be mounted read-only when the output is attempted.</p>]]></description>
			<author><![CDATA[dummy@example.com (ralph.ronnquist)]]></author>
			<pubDate>Tue, 09 Apr 2024 11:39:20 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=49456#p49456</guid>
		</item>
		<item>
			<title><![CDATA[Re: nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=49455#p49455</link>
			<description><![CDATA[<p>Are you sure the init script with this LSB header causes the script to run at boot, rather than merely giving the impression that it does?</p><div class="codebox"><pre><code>### BEGIN INIT INFO
# Provides:          nftables
# Required-Start:    $local_fs $network $remote_fs $syslog
# Required-Stop:     $local_fs $remote_fs $syslog
# Default-Start:     S	
# Default-Stop:      0 6
# Short-Description: nftables firewall service
# Description:       nftables firewall system service
### END INIT INFO</code></pre></div><p>For reasons unknown, none of my Debians run the script at boot with</p><div class="codebox"><pre><code># Default-Start: S</code></pre></div><p>I assume the issue may also exist on Devuan. This seems to be a general problem with all init scripts under Debian whose &quot;Default-Start&quot; tag is set to &quot;S&quot;. For example, I created the test file</p><div class="codebox"><pre><code>  /etc/init.d/test.sh</code></pre></div><p>with the following content:</p><div class="codebox"><pre><code>  #!/bin/bash

  ### BEGIN INIT INFO
  # Provides:          test
  # Required-Start:
  # Required-Stop:
  # Should-Start:
  # Default-Start:     S
  # Default-Stop:      0 1 6
  # Short-Description: Test
  # Description: Test
  ### END INIT INFO

  echo $(date) &quot;$@&quot; &gt;&gt;/root/test.txt</code></pre></div><p>and I enabled it with:</p><div class="codebox"><pre><code>  update-rc.d test.sh defaults</code></pre></div><p>which results in these, and only these, rc symlinks being created:</p><div class="codebox"><pre><code>  rc0.d/K01test.sh
  rc1.d/K01test.sh
  rc6.d/K01test.sh
  rcS.d/S01test.sh</code></pre></div><p>After rebooting the system from an empty &#039;/root/test.txt&#039; file, the contents of <br />this file become:</p><div class="codebox"><pre><code>  Tue Apr 9 01:26:50 CEST 2024 stop</code></pre></div><p>in which only one line is logged, corresponding to the time when I issued the <br />reboot command, with no follow-up lines after the reboot.</p>]]></description>
			<author><![CDATA[dummy@example.com (davide)]]></author>
			<pubDate>Tue, 09 Apr 2024 09:46:24 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=49455#p49455</guid>
		</item>
		<item>
			<title><![CDATA[Re: nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=47313#p47313</link>
			<description><![CDATA[<p>To be honest I too find searching the forum archive for something can be hard - what would be nice, for me, is the ability to surface just the relevant posts when you search by keyword and author rather than the whole threads that include those posts. It&#039;s always worth asking on the forum for solutions at the start - its quite possible someone may remember how a problem has been solved before you are forced to do it all yourself.</p>]]></description>
			<author><![CDATA[dummy@example.com (Marjorie)]]></author>
			<pubDate>Mon, 15 Jan 2024 11:02:33 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=47313#p47313</guid>
		</item>
		<item>
			<title><![CDATA[Re: nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=47248#p47248</link>
			<description><![CDATA[<p>Sorry Marjorie, I&#039;m not sure why I didn&#039;t see your post when I searched for help on this issue. I&#039;m glad you went ahead and posted the whole script in this thread, since the maintainer has said he might remove it from future versions.</p><p>Edit to add: I see you also said this nftables init script is included in recent versions of orphan-sysvinit-scripts. I&#039;m not familiar with that package, but I just read the description, and it sounds as if it should install the script for you automatically when you install the nftables package.</p>]]></description>
			<author><![CDATA[dummy@example.com (stultumanto)]]></author>
			<pubDate>Fri, 12 Jan 2024 23:23:40 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=47248#p47248</guid>
		</item>
		<item>
			<title><![CDATA[Re: nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=47247#p47247</link>
			<description><![CDATA[<p>I <em>thought</em> I&#039;d already posted on this at least once in the distant past in another thread.</p><p>And yes I had, covering the main issue of finding a script that worked.</p><p><a href="https://dev1galaxy.org/viewtopic.php?pid=34465#p34465" rel="nofollow">https://dev1galaxy.org/viewtopic.php?pid=34465#p34465</a> posted 7th Feb 2022 17:05:55</p><div class="quotebox"><blockquote><div><p>As HOAS says UFW still accesses the nftables back-end (which uses the nftables kernel module) through an iptables translation layer.</p><p>If you want to run nftables commands natively you need to do as HOAS suggest. </p><p>If you have Chimaera (or above) then use the nftables init script provided by orphan-sysvinit-scripts.</p><p>If you have Beowulf or earlier then there is no orphan-sysvinit-scripts. Having installed nftables and put the commands you want run in the config file you need to copy the example file /usr/share/doc/nftables/examples/sysvinit/nftables.init to /etc/init.d/nftables, change the Default-Start and Default-Stop lines (lines 6 and 7) and then make the init file executable by root.</p><p>Change the lines:</p><p># Default-Start:<br /># Default-Stop:&#160; &#160; &#160; 0 1 2 3 4 5 6</p><p>to:</p><p># Default-Start:&#160; &#160; &#160;S&#160; &#160; <br /># Default-Stop:&#160; &#160; &#160; 0 6</p><p>Then run</p><p>update-rc.d nftables defaults</p><p>as described by HOAS.</p><p>This will then read the config file and start nftables at boot.</p></div></blockquote></div>]]></description>
			<author><![CDATA[dummy@example.com (Marjorie)]]></author>
			<pubDate>Fri, 12 Jan 2024 22:57:01 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=47247#p47247</guid>
		</item>
		<item>
			<title><![CDATA[Re: nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=47246#p47246</link>
			<description><![CDATA[<div class="quotebox"><blockquote><div><p>I think it differs from the current official version in default start and stop.</p></div></blockquote></div><p>Right, and that was the only part I had to edit. If you used the current script as-is, it never actually loads your ruleset. I&#039;m not sure why he set it up that way, maybe to force you to actually read it before using it?</p><p>Another thing that might trip some people up is the fact that &#039;service nftables status&#039; doesn&#039;t actually print anything, the way a lot of service scripts do. It just sets the exit value, so you will need to check that somehow. For example, this will give you a typical status message:</p><div class="codebox"><pre><code>printf &quot;nftables is &quot;; if service nftables status; then printf &quot;running.\n&quot;; else printf &quot;stopped.\n&quot;; fi</code></pre></div><p>Of course, you can always modify the init script to print a status message automatically.</p>]]></description>
			<author><![CDATA[dummy@example.com (stultumanto)]]></author>
			<pubDate>Fri, 12 Jan 2024 22:34:18 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=47246#p47246</guid>
		</item>
		<item>
			<title><![CDATA[Re: nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=47236#p47236</link>
			<description><![CDATA[<p>Here&#039;s the snippet. It&#039;s really just that one line that runs nft, the if statement is just a safety catch to detect the absence of systemd.&#160; I put this in /etc/init.d/networking but in theory it could go in its own script.</p><div class="codebox"><pre><code>	if [ ! -d /run/systemd/system ] ; then
		/usr/sbin/nft -f /etc/nftables.conf
	fi</code></pre></div><p>I wasn&#039;t aware of any environment variables that need to be set; I guess my use case was relatively simple so I didn&#039;t need them.&#160; But YMMV.</p>]]></description>
			<author><![CDATA[dummy@example.com (quickfur)]]></author>
			<pubDate>Fri, 12 Jan 2024 15:27:39 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=47236#p47236</guid>
		</item>
		<item>
			<title><![CDATA[Re: nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=47235#p47235</link>
			<description><![CDATA[<p>This is the /etc/init.d/nftables I have from several year back when I set up my new mailserver. </p><p>It&#039;s always worked to date.</p><p>Author was: Arturo Borrero Gonzalez &lt;arturo@debian.org&gt;</p><p>I think it differs from the current official version in default start and stop.<br />The &#039;official&#039; version now has:</p><div class="codebox"><pre><code># Default-Start:
# Default-Stop:      0 1 2 3 4 5 6</code></pre></div><p>mine is here:</p><div class="codebox"><pre class="vscroll"><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:     S	
# Default-Stop:      0 6
# Short-Description: nftables firewall service
# Description:       nftables firewall system service
### END INIT INFO

# Author: Arturo Borrero Gonzalez &lt;arturo@debian.org&gt;

# Do NOT &quot;set -e&quot;

CONF=/etc/nftables.conf

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC=&quot;firewall service&quot;
NAME=nftables
BIN=/usr/sbin/nft
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x &quot;$BIN&quot; ] || exit 0

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (&gt;= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

VERBOSE=yes

do_start()
{
	# Return
	#  0 if start OK
	#  2 if start NOK

	# nft v0.4 return 0 if ENOENT $CONF
	if [ ! -r &quot;$CONF&quot; ] ; then
		echo &quot;E: No such $NAME $DESC config file $CONF&quot; &gt;&amp;2
		return 2
	fi

	$BIN -f $CONF || return 2
}

do_stop()
{
	# Return
	#   0 if stopped
	#   1 if already stopped
	#   2 if could not be stopped
	if ! do_status ; then
		$BIN flush ruleset || return 2
	fi
}

do_status()
{
	# Return
	#   0 if no rules
	#   1 if rules
	if [ &quot;$($BIN list ruleset 2&gt;/dev/null | wc -l)&quot; = &quot;0&quot; ] ; then
		return 0
	fi

	return 1
}

case &quot;$1&quot; in
  start)
	[ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_daemon_msg &quot;Starting $DESC&quot; &quot;$NAME&quot;
	do_start
	ret=&quot;$?&quot;
	case &quot;$ret&quot; in
		0|1) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 0 ;;
		2) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 1 ;;
	esac
	exit $ret
	;;
  restart|force-reload)
	[ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_daemon_msg &quot;Restarting $DESC&quot; &quot;$NAME&quot;
	do_start
	ret=&quot;$?&quot;
	case &quot;$ret&quot; in
		0|1) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 0 ;;
		2) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 1 ;;
	esac
	exit $ret
	;;
  stop)
	[ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_daemon_msg &quot;Stopping $DESC&quot; &quot;$NAME&quot;
	do_stop
	ret=&quot;$?&quot;
	case &quot;$ret&quot; in
		0|1) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 0 ;;
		2) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 1 ;;
	esac
	exit $ret
	;;
  status)
	if ! do_status ; then
		[ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_daemon_msg &quot;Status of ${DESC}: rules loaded&quot; &quot;$NAME&quot;
		[ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 0
		exit 0
	else
		[ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_daemon_msg &quot;Status of ${DESC}: no rules loaded&quot; &quot;$NAME&quot;
		[ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 1
		exit 1
	fi
	;;
  *)
	echo &quot;Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}&quot; &gt;&amp;2
	exit 3
	;;
esac</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (Marjorie)]]></author>
			<pubDate>Fri, 12 Jan 2024 15:26:16 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=47235#p47235</guid>
		</item>
		<item>
			<title><![CDATA[Re: nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=47233#p47233</link>
			<description><![CDATA[<p>How does that script compare to the <a href="https://sources.debian.org/src/orphan-sysvinit-scripts/0.15/scripts/nftables/" rel="nofollow">nftables init script</a> which is already in the <a href="https://pkginfo.devuan.org/orphan-sysvinit-scripts" rel="nofollow">orphan-sysvinit-scripts</a> package?</p><p>...</p><p><span style="color: grey">edit:</span><br />Looking at the <a href="https://sources.debian.org/src/nftables/1.0.9-1/debian/examples/sysvinit/nftables.init/" rel="nofollow">nftables.init script</a> the answer seems to be: the official-but-going-away script has better logging with a verbose option, and correctly sets name/desc variables, but not sure if there&#039;s any material difference...?</p>]]></description>
			<author><![CDATA[dummy@example.com (boughtonp)]]></author>
			<pubDate>Fri, 12 Jan 2024 13:52:45 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=47233#p47233</guid>
		</item>
		<item>
			<title><![CDATA[Re: nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=47226#p47226</link>
			<description><![CDATA[<p>@stultumanto, @quickfur:</p><p>In that case, why not copy the script-text here + location. (TIA)</p>]]></description>
			<author><![CDATA[dummy@example.com (alexkemp)]]></author>
			<pubDate>Fri, 12 Jan 2024 10:18:38 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=47226#p47226</guid>
		</item>
		<item>
			<title><![CDATA[Re: nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=47222#p47222</link>
			<description><![CDATA[<p>I ran into the same problem when I first switched to Devuan, I solved it by inserting a call to nft in one of the scripts in /etc/init.d.&#160; I didn&#039;t know there was a sample script already available 😅 But it wasn&#039;t too hard to figure out the exact command needed; it&#039;s listed in the systemd unit file, just gotta copy it somewhere sysvinit will run.</p>]]></description>
			<author><![CDATA[dummy@example.com (quickfur)]]></author>
			<pubDate>Fri, 12 Jan 2024 03:49:54 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=47222#p47222</guid>
		</item>
		<item>
			<title><![CDATA[nftables init script]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=47221#p47221</link>
			<description><![CDATA[<p>I thought other users attempting to build a firewall with nftables might find this information useful. While the nftables package doesn&#039;t install an init script on Devuan, there is a sample init script located under the installed documentation at /usr/share/doc/nftables/examples/sysvinit. However, it may go away soon, according to the README:</p><div class="quotebox"><blockquote><div><p>Given Debian default init system is systemd, I have no intention to support sysvinit apart of providing this example file... I will probably drop all sysvinit-related stuff like this in the future.</p></div></blockquote></div><p>The script needs to be edited to add the appropriate runlevels, but otherwise, it seems to work fine as-is. I copied it to /etc/init.d/, and installed it with update-rc.d. After rebooting, my nftables.conf was loaded automatically.</p>]]></description>
			<author><![CDATA[dummy@example.com (stultumanto)]]></author>
			<pubDate>Fri, 12 Jan 2024 03:35:10 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=47221#p47221</guid>
		</item>
	</channel>
</rss>
