<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://things.bleu255.com/runyourown/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Brendan</id>
	<title>Run Your Own - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://things.bleu255.com/runyourown/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Brendan"/>
	<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/Special:Contributions/Brendan"/>
	<updated>2026-06-04T23:04:47Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Larix_streams_and_chats_service&amp;diff=670</id>
		<title>Larix streams and chats service</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Larix_streams_and_chats_service&amp;diff=670"/>
		<updated>2026-06-03T14:59:40Z</updated>

		<summary type="html">&lt;p&gt;Brendan: Created page with &amp;quot;Danny is setting up a new live streams + chatroom thing to run virtual conferences or live stream sessions.  Docs to follow…&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Danny is setting up a new live streams + chatroom thing to run virtual conferences or live stream sessions.&lt;br /&gt;
&lt;br /&gt;
Docs to follow…&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Wildcard_Certificates_with_acme.sh&amp;diff=655</id>
		<title>Wildcard Certificates with acme.sh</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Wildcard_Certificates_with_acme.sh&amp;diff=655"/>
		<updated>2025-03-05T10:31:28Z</updated>

		<summary type="html">&lt;p&gt;Brendan: add cron and icecast stuff&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;code&amp;gt;acme.sh&amp;lt;/code&amp;gt; is a lightweight shell script based tool to handle Let&#039;s Encrypt certificates, etc.&lt;br /&gt;
&lt;br /&gt;
== Install the bash script ==&lt;br /&gt;
 wget https://get.acme.sh &lt;br /&gt;
&lt;br /&gt;
As root:&lt;br /&gt;
&lt;br /&gt;
 sh acme.sh&lt;br /&gt;
&lt;br /&gt;
This will install the script to &amp;lt;code&amp;gt;/root/.acme&amp;lt;/code&amp;gt; and add it to path by sourcing a script from root&#039;s &amp;lt;code&amp;gt;.bashrc&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Request a wildcard cert for lurk.org ==&lt;br /&gt;
We use wildcard certificates with DNS authentification, and we use the DNS server of our registrar, porkbun. It&#039;s not great (terrible UI for DNS editing), but it&#039;s cheap. Porkbun DNS support was added in recent versions of &amp;lt;code&amp;gt;acme.sh&amp;lt;/code&amp;gt;. To make it work, we first need to find our Porkbun API keys and use them to set the following environment variables in root&#039;s &amp;lt;code&amp;gt;.bashrc&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 export PORKBUN_API_KEY=&amp;quot;...&amp;quot;&lt;br /&gt;
 export PORKBUN_SECRET_API_KEY=&amp;quot;...&amp;quot;&lt;br /&gt;
&lt;br /&gt;
When ready and reloaded:&lt;br /&gt;
&lt;br /&gt;
 acme.sh --issue --dns dns_porkbun -d lurk.org -d *.lurk.org&lt;br /&gt;
&lt;br /&gt;
result:&lt;br /&gt;
&lt;br /&gt;
* cert is in: &amp;lt;code&amp;gt;/root/.acme.sh/lurk.org_ecc/lurk.org.cer&amp;lt;/code&amp;gt;&lt;br /&gt;
* cert key is in: &amp;lt;code&amp;gt;/root/.acme.sh/lurk.org_ecc/lurk.org.key&amp;lt;/code&amp;gt;&lt;br /&gt;
* intermediate CA cert is in: &amp;lt;code&amp;gt;/root/.acme.sh/lurk.org_ecc/ca.cer&amp;lt;/code&amp;gt;&lt;br /&gt;
* full-chain cert is in: &amp;lt;code&amp;gt;/root/.acme.sh/lurk.org_ecc/fullchain.cer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install the certs for nginx ==&lt;br /&gt;
The following command will install the certs for nginx, assuming there is a &amp;lt;code&amp;gt;/etc/nginx/certs/&amp;lt;/code&amp;gt; directory. Should be set and forget.&lt;br /&gt;
 acme.sh --install-cert -d lurk.org -d *.lurk.org --key-file /etc/nginx/certs/key.pem --fullchain-file /etc/nginx/certs/cert.pem --reloadcmd &amp;quot;systemctl force-reload nginx&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Deployment for other services ==&lt;br /&gt;
&amp;lt;code&amp;gt;acme.sh&amp;lt;/code&amp;gt; can also support custom installs of the certificates. They call this deployment, and all the scripts provided by the project can be found in &amp;lt;code&amp;gt;/root/.acme.sh/deploy&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to make new deploy scripts quite easily, here is an example for &amp;lt;code&amp;gt;cooldaemon.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# this makes accessible as variables all the necessary paths and files&lt;br /&gt;
cooldaemon_deploy() {&lt;br /&gt;
_cdomain=&amp;quot;$1&amp;quot;&lt;br /&gt;
_ckey=&amp;quot;$2&amp;quot;&lt;br /&gt;
_ccert=&amp;quot;$3&amp;quot;&lt;br /&gt;
_cca=&amp;quot;$4&amp;quot;&lt;br /&gt;
_cfullchain=&amp;quot;$5&amp;quot;&lt;br /&gt;
&lt;br /&gt;
_debug _cdomain &amp;quot;$_cdomain&amp;quot;&lt;br /&gt;
_debug _ckey &amp;quot;$_ckey&amp;quot;&lt;br /&gt;
_debug _ccert &amp;quot;$_ccert&amp;quot;&lt;br /&gt;
_debug _cca &amp;quot;$_cca&amp;quot;&lt;br /&gt;
_debug _cfullchain &amp;quot;$_cfullchain&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# make a var for the target location&lt;br /&gt;
_ssl_path=&amp;quot;/etc/cooldaemon/certs/&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# cooldaemon only needs the fullchain perm and the key so&lt;br /&gt;
# we only copy these&lt;br /&gt;
cp $_ckey $_ssl_path&lt;br /&gt;
cp $_cfullchain $_ssl_path&lt;br /&gt;
&lt;br /&gt;
# any extra commands can be added here for instance&lt;br /&gt;
# maybe cooldaemon is picky about cert ownership&lt;br /&gt;
chown -R cooldaemon:cooldaemon $_ssl_path&lt;br /&gt;
&lt;br /&gt;
# last but not least we reload cool daemon&lt;br /&gt;
# please note that some other daemons may need a restart instead&lt;br /&gt;
systemctl reload mumble-server&lt;br /&gt;
&lt;br /&gt;
return 0&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To enable the deployment at every cert renewal:&lt;br /&gt;
 acme.sh --deploy -d lurk.org -d *.lurk.org --deploy-hook cooldaemon&lt;br /&gt;
&lt;br /&gt;
== set up a cron job ==&lt;br /&gt;
 24 3 * * * &amp;quot;/root/.acme.sh&amp;quot;/acme.sh --cron --home &amp;quot;/root/.acme.sh&amp;quot; --reloadcmd &amp;quot;systemctl force-reload nginx&amp;quot; --renew-hook &amp;quot;/root/icecast_certs.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
To be fully modern and cool, we should probably switch from cron to a systemd timer but that&#039;s for another day. There&#039;s also a deploy script for icecast so this could theoretically all be done in one run but there are no docs for --cron so it&#039;s not clear how to set this up. For now we use a post renewal hook that smooshes the certs together for icecast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
# turn the acme certs in to a certificate chain for icecast streaming&lt;br /&gt;
cat /root/.acme.sh/\*.lurk.org/fullchain.cer &amp;gt; /usr/local/share/icecast/icecast.pem&lt;br /&gt;
cat /root/.acme.sh/\*.lurk.org/\*.lurk.org.key &amp;gt;&amp;gt; /usr/local/share/icecast/icecast.pem&lt;br /&gt;
systemctl restart icecast&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Certificates]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=FilesystemMonitoring&amp;diff=654</id>
		<title>FilesystemMonitoring</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=FilesystemMonitoring&amp;diff=654"/>
		<updated>2025-02-22T17:25:31Z</updated>

		<summary type="html">&lt;p&gt;Brendan: /* Filesystem Monitoring */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Filesystem Monitoring =&lt;br /&gt;
&lt;br /&gt;
If you have applications with a propensity to blow up it can be helpful to have an alert before you run out of disk space.&lt;br /&gt;
&lt;br /&gt;
Thinks like mastodon and certain file-sharing systems can steadily eat up lots of space caching things that you might not need any more. There also the always present danger that logs or backup files can inflate to huge sizes due to unobserved errors or missing clean-ups. So let&#039;s make a little script that will send us an alarm email if it looks dicey:&lt;br /&gt;
&lt;br /&gt;
* save this script somewhere useful like disk-monitor.sh in your private bin folder&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# set -x&lt;br /&gt;
# Shell script to monitor or watch the disk space&lt;br /&gt;
# It will send an email to $ADMIN, if the (free available) percentage of space is &amp;gt;= 90%.&lt;br /&gt;
# --------------------------------------------------------------------------------------------------------&lt;br /&gt;
# Set admin email so that you can get email.&lt;br /&gt;
ADMIN=&amp;quot;admins@example.com&amp;quot;&lt;br /&gt;
# set alert level 90% is default&lt;br /&gt;
ALERT=90&lt;br /&gt;
# Exclude list of unwanted monitoring, if several partions then use &amp;quot;|&amp;quot; to separate the partitions.&lt;br /&gt;
# An example: EXCLUDE_LIST=&amp;quot;/dev/hdd1|/dev/hdc5&amp;quot;&lt;br /&gt;
EXCLUDE_LIST=&amp;quot;/auto/ripper|loop|udev&amp;quot;&lt;br /&gt;
#&lt;br /&gt;
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;br /&gt;
#&lt;br /&gt;
main_prog() {&lt;br /&gt;
while read -r output;&lt;br /&gt;
do&lt;br /&gt;
  servername=$(hostname)&lt;br /&gt;
  usep=$(echo &amp;quot;$output&amp;quot; | awk &#039;{ print $1}&#039; | cut -d&#039;%&#039; -f1)&lt;br /&gt;
  partition=$(echo &amp;quot;$output&amp;quot; | awk &#039;{print $2}&#039;)&lt;br /&gt;
  echo &amp;quot;partition $partition is at $usep% useage&amp;quot;&lt;br /&gt;
  if [ $usep -ge $ALERT ] ; then&lt;br /&gt;
     echo &amp;quot;Running out of space \&amp;quot;$partition ($usep%)\&amp;quot; on server $(hostname), $(date)&amp;quot; | \&lt;br /&gt;
     mail -s &amp;quot;***ALERT*** $servername is almost out of disk space: $usep% on $partition&amp;quot; &amp;quot;$ADMIN&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
done&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$EXCLUDE_LIST&amp;quot; != &amp;quot;&amp;quot; ] ; then&lt;br /&gt;
  df -h | grep -vE &amp;quot;^Filesystem|tmpfs|cdrom|${EXCLUDE_LIST}&amp;quot; | awk &#039;{print $5 &amp;quot; &amp;quot; $6}&#039; | main_prog&lt;br /&gt;
else&lt;br /&gt;
  df -h | grep -vE &amp;quot;^Filesystem|tmpfs|cdrom&amp;quot; | awk &#039;{print $5 &amp;quot; &amp;quot; $6}&#039; | main_prog&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* now create a systemd service in /etc/systemd/system/diskmonitor.service&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=Check filesystems and alert when approaching full&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=oneshot&lt;br /&gt;
ExecStart=/home/borf/disk-monitor.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* then create a systemd timer /etc/systemd/system/diskmonitor.timer - this will run once per hour&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=Check disks are not about to be full&lt;br /&gt;
&lt;br /&gt;
[Timer]&lt;br /&gt;
OnBootSec=15m&lt;br /&gt;
OnUnitActiveSec=1h&lt;br /&gt;
&lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=diskmonitor.target&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* enable the timer&lt;br /&gt;
 sudo systemctl enable diskmonitor.timer&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=653</id>
		<title>Firewall</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=653"/>
		<updated>2025-02-21T10:48:49Z</updated>

		<summary type="html">&lt;p&gt;Brendan: added l4proto and ipv6-icmp&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Different ways to handle &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;nftables&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Using &amp;lt;code&amp;gt;iptables-persistent&amp;lt;/code&amp;gt; on Debian ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; In use on &amp;lt;code&amp;gt;vrijdagmiddagborrel&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s basically a set of &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; plugins for &amp;lt;code&amp;gt;netfilter-persistent&amp;lt;/code&amp;gt;, which itself is a loader for different netfilter configuration. Once installed, it will take care of restoring rules at boot time, and through a small helper, can be used to reload/update/save rules on the fly.&lt;br /&gt;
&lt;br /&gt;
=== Installation and config ===&lt;br /&gt;
* Installation:&lt;br /&gt;
 apt install iptables-persistent netfilter-persistent&lt;br /&gt;
* Add/change iptables rules located at &amp;lt;code&amp;gt;/etc/iptables/rules.v4&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/iptables/rules.v6&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
* Apply new rules after changes made to &amp;lt;code&amp;gt;rules.v*&amp;lt;/code&amp;gt; files and check result&lt;br /&gt;
 netfilter-persistent reload&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; oneliners ==&lt;br /&gt;
note - for newer setups see nftables below. iptables commands still work but directly using nftables is preferred.&lt;br /&gt;
&lt;br /&gt;
* list all rules from all chains&lt;br /&gt;
 iptables -L&lt;br /&gt;
* block an IP&lt;br /&gt;
 iptables -I INPUT -s 192.168.111.111 -j DROP&lt;br /&gt;
 iptables -I OUTPUT -d 192.168.111.111 -j DROP&lt;br /&gt;
&lt;br /&gt;
== nftables ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;nftables&#039;&#039; is the hip new thing in the kernel. It has nicer, easier to read config syntax and has a bunch of performance improvements. Current Debian (12) comes with it installed (but turned off).&lt;br /&gt;
&lt;br /&gt;
* enable the firewall&lt;br /&gt;
 systemctl enable nftables&lt;br /&gt;
&lt;br /&gt;
* a basic firewall config you can drop into /etc/nftables.conf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # open vpn traffic&lt;br /&gt;
    iifname lurknet accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    icmp type echo-request accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 655, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 655, 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
table ip6 firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # invalid connections&lt;br /&gt;
    ct state invalid drop&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # vpn interface&lt;br /&gt;
    iifname lurknet accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    # routers may also want: mld-listener-query, nd-router-solicit&lt;br /&gt;
    icmpv6 type { echo-request, nd-neighbor-solicit } accept&lt;br /&gt;
    meta l4proto ipv6-icmp accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 655, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 655, 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* start the firewall&lt;br /&gt;
 systemctl start nftables&lt;br /&gt;
&lt;br /&gt;
* see how it looks (assuming you have not just accidentally locked yourself out of the server)&lt;br /&gt;
 nft list ruleset&lt;br /&gt;
&lt;br /&gt;
get rich off your NFT!&lt;br /&gt;
&lt;br /&gt;
[[Category:System]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=FilesystemMonitoring&amp;diff=652</id>
		<title>FilesystemMonitoring</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=FilesystemMonitoring&amp;diff=652"/>
		<updated>2025-02-19T16:25:51Z</updated>

		<summary type="html">&lt;p&gt;Brendan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Filesystem Monitoring =&lt;br /&gt;
&lt;br /&gt;
If you have applications with a propensity to blow up it can be helpful to have an alert before you run out of disk space.&lt;br /&gt;
&lt;br /&gt;
Thinks like mastodon and certain file-sharing systems can steadily eat up lots of space caching things that you might not need any more. There also the always present danger that logs or backup files can inflate to huge sizes due to unobserved errors or missing clean-ups. So let&#039;s make a little script that will send us an alarm email if it looks dicey:&lt;br /&gt;
&lt;br /&gt;
* save this script somewhere useful like disk-monitor.sh in your private bin folder&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# set -x&lt;br /&gt;
# Shell script to monitor or watch the disk space&lt;br /&gt;
# It will send an email to $ADMIN, if the (free available) percentage of space is &amp;gt;= 90%.&lt;br /&gt;
# --------------------------------------------------------------------------------------------------------&lt;br /&gt;
# Set admin email so that you can get email.&lt;br /&gt;
ADMIN=&amp;quot;admins@example.com&amp;quot;&lt;br /&gt;
# set alert level 90% is default&lt;br /&gt;
ALERT=90&lt;br /&gt;
# Exclude list of unwanted monitoring, if several partions then use &amp;quot;|&amp;quot; to separate the partitions.&lt;br /&gt;
# An example: EXCLUDE_LIST=&amp;quot;/dev/hdd1|/dev/hdc5&amp;quot;&lt;br /&gt;
EXCLUDE_LIST=&amp;quot;/auto/ripper|loop|udev&amp;quot;&lt;br /&gt;
#&lt;br /&gt;
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;br /&gt;
#&lt;br /&gt;
main_prog() {&lt;br /&gt;
while read -r output;&lt;br /&gt;
do&lt;br /&gt;
  #echo &amp;quot;Working on $output ...&amp;quot;&lt;br /&gt;
  servername=$(hostname)&lt;br /&gt;
  usep=$(echo &amp;quot;$output&amp;quot; | awk &#039;{ print $1}&#039; | cut -d&#039;%&#039; -f1)&lt;br /&gt;
  partition=$(echo &amp;quot;$output&amp;quot; | awk &#039;{print $2}&#039;)&lt;br /&gt;
  #echo &amp;quot;alert level is $ALERT&amp;quot;&lt;br /&gt;
  echo &amp;quot;partition $partition is at $usep% useage&amp;quot;&lt;br /&gt;
  if [ $usep -ge $ALERT ] ; then&lt;br /&gt;
     #echo &amp;quot;ALERT $partition is now up to $usep percent utilization!&amp;quot;&lt;br /&gt;
     echo &amp;quot;Running out of space \&amp;quot;$partition ($usep%)\&amp;quot; on server $(hostname), $(date)&amp;quot; | \&lt;br /&gt;
     mail -s &amp;quot;***ALERT*** $servername is almost out of disk space: $usep% on $partition&amp;quot; &amp;quot;$ADMIN&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
done&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$EXCLUDE_LIST&amp;quot; != &amp;quot;&amp;quot; ] ; then&lt;br /&gt;
  df -h | grep -vE &amp;quot;^Filesystem|tmpfs|cdrom|${EXCLUDE_LIST}&amp;quot; | awk &#039;{print $5 &amp;quot; &amp;quot; $6}&#039; | main_prog&lt;br /&gt;
else&lt;br /&gt;
  df -h | grep -vE &amp;quot;^Filesystem|tmpfs|cdrom&amp;quot; | awk &#039;{print $5 &amp;quot; &amp;quot; $6}&#039; | main_prog&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* now create a systemd service in /etc/systemd/system/diskmonitor.service&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=Check filesystems and alert when approaching full&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=oneshot&lt;br /&gt;
ExecStart=/home/borf/disk-monitor.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* then create a systemd timer /etc/systemd/system/diskmonitor.timer - this will run once per hour&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=Check disks are not about to be full&lt;br /&gt;
&lt;br /&gt;
[Timer]&lt;br /&gt;
OnBootSec=15m&lt;br /&gt;
OnUnitActiveSec=1h&lt;br /&gt;
&lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=diskmonitor.target&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* enable the timer&lt;br /&gt;
 sudo systemctl enable diskmonitor.timer&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=FilesystemMonitoring&amp;diff=651</id>
		<title>FilesystemMonitoring</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=FilesystemMonitoring&amp;diff=651"/>
		<updated>2025-02-19T15:06:29Z</updated>

		<summary type="html">&lt;p&gt;Brendan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Filesystem Monitoring =&lt;br /&gt;
&lt;br /&gt;
If you have applications with a propensity to blow up it can be helpful to have an alert before you run out of disk space.&lt;br /&gt;
&lt;br /&gt;
Thinks like mastodon and certain file-sharing systems can steadily eat up lots of space caching things that you might not need any more. There also the always present danger that logs or backup files can inflate to huge sizes due to unobserved errors or missing clean-ups. So let&#039;s make a little script that will send us an alarm email if it looks dicey:&lt;br /&gt;
&lt;br /&gt;
* save this script somewhere useful like disk-monitor.sh in your private bin folder&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# set -x&lt;br /&gt;
# Shell script to monitor or watch the disk space&lt;br /&gt;
# It will send an email to $ADMIN, if the (free available) percentage of space is &amp;gt;= 90%.&lt;br /&gt;
# --------------------------------------------------------------------------------------------------------&lt;br /&gt;
# Set admin email so that you can get email.&lt;br /&gt;
ADMIN=&amp;quot;admins@example.com&amp;quot;&lt;br /&gt;
# set alert level 90% is default&lt;br /&gt;
ALERT=90&lt;br /&gt;
# Exclude list of unwanted monitoring, if several partions then use &amp;quot;|&amp;quot; to separate the partitions.&lt;br /&gt;
# An example: EXCLUDE_LIST=&amp;quot;/dev/hdd1|/dev/hdc5&amp;quot;&lt;br /&gt;
EXCLUDE_LIST=&amp;quot;/auto/ripper|loop|udev&amp;quot;&lt;br /&gt;
#&lt;br /&gt;
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;br /&gt;
#&lt;br /&gt;
main_prog() {&lt;br /&gt;
while read -r output;&lt;br /&gt;
do&lt;br /&gt;
  #echo &amp;quot;Working on $output ...&amp;quot;&lt;br /&gt;
  servername=$(hostname)&lt;br /&gt;
  usep=$(echo &amp;quot;$output&amp;quot; | awk &#039;{ print $1}&#039; | cut -d&#039;%&#039; -f1)&lt;br /&gt;
  partition=$(echo &amp;quot;$output&amp;quot; | awk &#039;{print $2}&#039;)&lt;br /&gt;
  #echo &amp;quot;alert level is $ALERT&amp;quot;&lt;br /&gt;
  echo &amp;quot;partition $partition is at $usep% useage&amp;quot;&lt;br /&gt;
  if [ $usep -ge $ALERT ] ; then&lt;br /&gt;
     #echo &amp;quot;ALERT $partition is now up to $usep percent utilization!&amp;quot;&lt;br /&gt;
     echo &amp;quot;Running out of space \&amp;quot;$partition ($usep%)\&amp;quot; on server $(hostname), $(date)&amp;quot; | \&lt;br /&gt;
     mail -s &amp;quot;***ALERT*** $servername is almost out of disk space: $usep% on $partition&amp;quot; &amp;quot;$ADMIN&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
done&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$EXCLUDE_LIST&amp;quot; != &amp;quot;&amp;quot; ] ; then&lt;br /&gt;
  df -h | grep -vE &amp;quot;^Filesystem|tmpfs|cdrom|${EXCLUDE_LIST}&amp;quot; | awk &#039;{print $5 &amp;quot; &amp;quot; $6}&#039; | main_prog&lt;br /&gt;
else&lt;br /&gt;
  df -h | grep -vE &amp;quot;^Filesystem|tmpfs|cdrom&amp;quot; | awk &#039;{print $5 &amp;quot; &amp;quot; $6}&#039; | main_prog&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* now create a systemd service in /etc/systemd/system/diskmonitor.service&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=Check filesystems and alert when approaching full&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=oneshot&lt;br /&gt;
ExecStart=/home/borf/disk-monitor.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* then create a systemd timer /etc/systemd/system/diskmonitor.timer - this will run once per hour&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=Check disks are not about to be full&lt;br /&gt;
&lt;br /&gt;
[Timer]&lt;br /&gt;
OnBootSec=15m&lt;br /&gt;
OnUnitActiveSec=1h&lt;br /&gt;
&lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=diskmonitor.target&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* enable the timer&lt;br /&gt;
 sudo systemctl enable diskmonitor.timer&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=FilesystemMonitoring&amp;diff=650</id>
		<title>FilesystemMonitoring</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=FilesystemMonitoring&amp;diff=650"/>
		<updated>2025-02-19T15:05:24Z</updated>

		<summary type="html">&lt;p&gt;Brendan: create page documenting a filesystem fill-up email alarm&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;# Filesystem Monitoring #&lt;br /&gt;
&lt;br /&gt;
If you have applications with a propensity to blow up it can be helpful to have an alert before you run out of disk space.&lt;br /&gt;
&lt;br /&gt;
Thinks like mastodon and certain file-sharing systems can steadily eat up lots of space caching things that you might not need any more. There also the always present danger that logs or backup files can inflate to huge sizes due to unobserved errors or missing clean-ups. So let&#039;s make a little script that will send us an alarm email if it looks dicey:&lt;br /&gt;
&lt;br /&gt;
* save this script somewhere useful like disk-monitor.sh in your private bin folder&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# set -x&lt;br /&gt;
# Shell script to monitor or watch the disk space&lt;br /&gt;
# It will send an email to $ADMIN, if the (free available) percentage of space is &amp;gt;= 90%.&lt;br /&gt;
# --------------------------------------------------------------------------------------------------------&lt;br /&gt;
# Set admin email so that you can get email.&lt;br /&gt;
ADMIN=&amp;quot;admins@example.com&amp;quot;&lt;br /&gt;
# set alert level 90% is default&lt;br /&gt;
ALERT=90&lt;br /&gt;
# Exclude list of unwanted monitoring, if several partions then use &amp;quot;|&amp;quot; to separate the partitions.&lt;br /&gt;
# An example: EXCLUDE_LIST=&amp;quot;/dev/hdd1|/dev/hdc5&amp;quot;&lt;br /&gt;
EXCLUDE_LIST=&amp;quot;/auto/ripper|loop|udev&amp;quot;&lt;br /&gt;
#&lt;br /&gt;
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;br /&gt;
#&lt;br /&gt;
main_prog() {&lt;br /&gt;
while read -r output;&lt;br /&gt;
do&lt;br /&gt;
  #echo &amp;quot;Working on $output ...&amp;quot;&lt;br /&gt;
  servername=$(hostname)&lt;br /&gt;
  usep=$(echo &amp;quot;$output&amp;quot; | awk &#039;{ print $1}&#039; | cut -d&#039;%&#039; -f1)&lt;br /&gt;
  partition=$(echo &amp;quot;$output&amp;quot; | awk &#039;{print $2}&#039;)&lt;br /&gt;
  #echo &amp;quot;alert level is $ALERT&amp;quot;&lt;br /&gt;
  echo &amp;quot;partition $partition is at $usep% useage&amp;quot;&lt;br /&gt;
  if [ $usep -ge $ALERT ] ; then&lt;br /&gt;
     #echo &amp;quot;ALERT $partition is now up to $usep percent utilization!&amp;quot;&lt;br /&gt;
     echo &amp;quot;Running out of space \&amp;quot;$partition ($usep%)\&amp;quot; on server $(hostname), $(date)&amp;quot; | \&lt;br /&gt;
     mail -s &amp;quot;***ALERT*** $servername is almost out of disk space: $usep% on $partition&amp;quot; &amp;quot;$ADMIN&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
done&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$EXCLUDE_LIST&amp;quot; != &amp;quot;&amp;quot; ] ; then&lt;br /&gt;
  df -h | grep -vE &amp;quot;^Filesystem|tmpfs|cdrom|${EXCLUDE_LIST}&amp;quot; | awk &#039;{print $5 &amp;quot; &amp;quot; $6}&#039; | main_prog&lt;br /&gt;
else&lt;br /&gt;
  df -h | grep -vE &amp;quot;^Filesystem|tmpfs|cdrom&amp;quot; | awk &#039;{print $5 &amp;quot; &amp;quot; $6}&#039; | main_prog&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* now create a systemd service in /etc/systemd/system/diskmonitor.service&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=Check filesystems and alert when approaching full&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=oneshot&lt;br /&gt;
ExecStart=/home/borf/disk-monitor.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* then create a systemd timer /etc/systemd/system/diskmonitor.timer - this will run once per hour&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=Check disks are not about to be full&lt;br /&gt;
&lt;br /&gt;
[Timer]&lt;br /&gt;
OnBootSec=15m&lt;br /&gt;
OnUnitActiveSec=1h&lt;br /&gt;
&lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=diskmonitor.target&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* enable the timer&lt;br /&gt;
sudo systemctl enable diskmonitor.timer&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=649</id>
		<title>Firewall</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=649"/>
		<updated>2025-02-18T17:55:21Z</updated>

		<summary type="html">&lt;p&gt;Brendan: /* iptables oneliners */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Different ways to handle &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;nftables&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Using &amp;lt;code&amp;gt;iptables-persistent&amp;lt;/code&amp;gt; on Debian ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; In use on &amp;lt;code&amp;gt;vrijdagmiddagborrel&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s basically a set of &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; plugins for &amp;lt;code&amp;gt;netfilter-persistent&amp;lt;/code&amp;gt;, which itself is a loader for different netfilter configuration. Once installed, it will take care of restoring rules at boot time, and through a small helper, can be used to reload/update/save rules on the fly.&lt;br /&gt;
&lt;br /&gt;
=== Installation and config ===&lt;br /&gt;
* Installation:&lt;br /&gt;
 apt install iptables-persistent netfilter-persistent&lt;br /&gt;
* Add/change iptables rules located at &amp;lt;code&amp;gt;/etc/iptables/rules.v4&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/iptables/rules.v6&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
* Apply new rules after changes made to &amp;lt;code&amp;gt;rules.v*&amp;lt;/code&amp;gt; files and check result&lt;br /&gt;
 netfilter-persistent reload&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; oneliners ==&lt;br /&gt;
note - for newer setups see nftables below. iptables commands still work but directly using nftables is preferred.&lt;br /&gt;
&lt;br /&gt;
* list all rules from all chains&lt;br /&gt;
 iptables -L&lt;br /&gt;
* block an IP&lt;br /&gt;
 iptables -I INPUT -s 192.168.111.111 -j DROP&lt;br /&gt;
 iptables -I OUTPUT -d 192.168.111.111 -j DROP&lt;br /&gt;
&lt;br /&gt;
== nftables ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;nftables&#039;&#039; is the hip new thing in the kernel. It has nicer, easier to read config syntax and has a bunch of performance improvements. Current Debian (12) comes with it installed (but turned off).&lt;br /&gt;
&lt;br /&gt;
* enable the firewall&lt;br /&gt;
 systemctl enable nftables&lt;br /&gt;
&lt;br /&gt;
* a basic firewall config you can drop into /etc/nftables.conf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # open vpn traffic&lt;br /&gt;
    iifname lurknet accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    icmp type echo-request accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 655, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 655, 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
table ip6 firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # invalid connections&lt;br /&gt;
    ct state invalid drop&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # vpn interface&lt;br /&gt;
    iifname lurknet accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    # routers may also want: mld-listener-query, nd-router-solicit&lt;br /&gt;
    icmpv6 type { echo-request, nd-neighbor-solicit } accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 655, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 655, 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* start the firewall&lt;br /&gt;
 systemctl start nftables&lt;br /&gt;
&lt;br /&gt;
* see how it looks (assuming you have not just accidentally locked yourself out of the server)&lt;br /&gt;
 nft list ruleset&lt;br /&gt;
&lt;br /&gt;
get rich off your NFT!&lt;br /&gt;
&lt;br /&gt;
[[Category:System]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=648</id>
		<title>Firewall</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=648"/>
		<updated>2025-02-18T17:53:58Z</updated>

		<summary type="html">&lt;p&gt;Brendan: add interface and ports to help tinc&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Different ways to handle &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;nftables&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Using &amp;lt;code&amp;gt;iptables-persistent&amp;lt;/code&amp;gt; on Debian ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; In use on &amp;lt;code&amp;gt;vrijdagmiddagborrel&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s basically a set of &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; plugins for &amp;lt;code&amp;gt;netfilter-persistent&amp;lt;/code&amp;gt;, which itself is a loader for different netfilter configuration. Once installed, it will take care of restoring rules at boot time, and through a small helper, can be used to reload/update/save rules on the fly.&lt;br /&gt;
&lt;br /&gt;
=== Installation and config ===&lt;br /&gt;
* Installation:&lt;br /&gt;
 apt install iptables-persistent netfilter-persistent&lt;br /&gt;
* Add/change iptables rules located at &amp;lt;code&amp;gt;/etc/iptables/rules.v4&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/iptables/rules.v6&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
* Apply new rules after changes made to &amp;lt;code&amp;gt;rules.v*&amp;lt;/code&amp;gt; files and check result&lt;br /&gt;
 netfilter-persistent reload&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; oneliners ==&lt;br /&gt;
* list all rules from all chains&lt;br /&gt;
 iptables -L&lt;br /&gt;
* block an IP&lt;br /&gt;
 iptables -I INPUT -s 192.168.111.111 -j DROP&lt;br /&gt;
 iptables -I OUTPUT -d 192.168.111.111 -j DROP&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== nftables ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;nftables&#039;&#039; is the hip new thing in the kernel. It has nicer, easier to read config syntax and has a bunch of performance improvements. Current Debian (12) comes with it installed (but turned off).&lt;br /&gt;
&lt;br /&gt;
* enable the firewall&lt;br /&gt;
 systemctl enable nftables&lt;br /&gt;
&lt;br /&gt;
* a basic firewall config you can drop into /etc/nftables.conf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # open vpn traffic&lt;br /&gt;
    iifname lurknet accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    icmp type echo-request accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 655, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 655, 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
table ip6 firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # invalid connections&lt;br /&gt;
    ct state invalid drop&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # vpn interface&lt;br /&gt;
    iifname lurknet accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    # routers may also want: mld-listener-query, nd-router-solicit&lt;br /&gt;
    icmpv6 type { echo-request, nd-neighbor-solicit } accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 655, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 655, 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* start the firewall&lt;br /&gt;
 systemctl start nftables&lt;br /&gt;
&lt;br /&gt;
* see how it looks (assuming you have not just accidentally locked yourself out of the server)&lt;br /&gt;
 nft list ruleset&lt;br /&gt;
&lt;br /&gt;
get rich off your NFT!&lt;br /&gt;
&lt;br /&gt;
[[Category:System]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Tinc_Settings_for_LURK&amp;diff=647</id>
		<title>Tinc Settings for LURK</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Tinc_Settings_for_LURK&amp;diff=647"/>
		<updated>2025-02-18T17:16:41Z</updated>

		<summary type="html">&lt;p&gt;Brendan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== LURK specific settings ==&lt;br /&gt;
&lt;br /&gt;
Tinc is currently installed to connect nodes in the lurk network&lt;br /&gt;
&lt;br /&gt;
 agnesbaxter = 10.0.1.3&lt;br /&gt;
 skattkista = 10.0.1.2 (currently dead)&lt;br /&gt;
 vrijdagmiddagborrel = 10.0.1.4&lt;br /&gt;
 manis = 10.0.1.5&lt;br /&gt;
 poplar = 10.0.1.6&lt;br /&gt;
 ns334441 = 10.0.1.7&lt;br /&gt;
 tilia = 10.0.1.8&lt;br /&gt;
 larix = 10.0.1.9&lt;br /&gt;
&lt;br /&gt;
all clients that connect via server agnesbaxter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: VPN]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Tinc_Settings_for_LURK&amp;diff=646</id>
		<title>Tinc Settings for LURK</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Tinc_Settings_for_LURK&amp;diff=646"/>
		<updated>2025-02-18T17:15:25Z</updated>

		<summary type="html">&lt;p&gt;Brendan: add larix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== LURK specific settings ==&lt;br /&gt;
&lt;br /&gt;
Tinc is currently installed to connect nodes in the lurk network&lt;br /&gt;
&lt;br /&gt;
 agnesbaxter = 10.0.1.3&lt;br /&gt;
 skattkista = 10.0.1.2 (currently dead)&lt;br /&gt;
 vrijdagmiddagborrel = 10.0.1.4&lt;br /&gt;
 manis = 10.0.1.5&lt;br /&gt;
 poplar = 10.0.1.6&lt;br /&gt;
 ns334441 = 10.0.1.7&lt;br /&gt;
 tilia = 10.0.1.8&lt;br /&gt;
 larix = 10.0.1.9&lt;br /&gt;
&lt;br /&gt;
skattkista, vmb, manis and poplar connect to agnesbaxter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: VPN]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=645</id>
		<title>Firewall</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=645"/>
		<updated>2025-02-18T12:40:58Z</updated>

		<summary type="html">&lt;p&gt;Brendan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Different ways to handle &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;nftables&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Using &amp;lt;code&amp;gt;iptables-persistent&amp;lt;/code&amp;gt; on Debian ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; In use on &amp;lt;code&amp;gt;vrijdagmiddagborrel&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s basically a set of &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; plugins for &amp;lt;code&amp;gt;netfilter-persistent&amp;lt;/code&amp;gt;, which itself is a loader for different netfilter configuration. Once installed, it will take care of restoring rules at boot time, and through a small helper, can be used to reload/update/save rules on the fly.&lt;br /&gt;
&lt;br /&gt;
=== Installation and config ===&lt;br /&gt;
* Installation:&lt;br /&gt;
 apt install iptables-persistent netfilter-persistent&lt;br /&gt;
* Add/change iptables rules located at &amp;lt;code&amp;gt;/etc/iptables/rules.v4&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/iptables/rules.v6&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
* Apply new rules after changes made to &amp;lt;code&amp;gt;rules.v*&amp;lt;/code&amp;gt; files and check result&lt;br /&gt;
 netfilter-persistent reload&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; oneliners ==&lt;br /&gt;
* list all rules from all chains&lt;br /&gt;
 iptables -L&lt;br /&gt;
* block an IP&lt;br /&gt;
 iptables -I INPUT -s 192.168.111.111 -j DROP&lt;br /&gt;
 iptables -I OUTPUT -d 192.168.111.111 -j DROP&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== nftables ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;nftables&#039;&#039; is the hip new thing in the kernel. It has nicer, easier to read config syntax and has a bunch of performance improvements. Current Debian (12) comes with it installed (but turned off).&lt;br /&gt;
&lt;br /&gt;
* enable the firewall&lt;br /&gt;
 systemctl enable nftables&lt;br /&gt;
&lt;br /&gt;
* a basic firewall config you can drop into /etc/nftables.conf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    icmp type echo-request accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
table ip6 firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # invalid connections&lt;br /&gt;
    ct state invalid drop&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    # routers may also want: mld-listener-query, nd-router-solicit&lt;br /&gt;
    icmpv6 type { echo-request, nd-neighbor-solicit } accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* start the firewall&lt;br /&gt;
 systemctl start nftables&lt;br /&gt;
&lt;br /&gt;
* see how it looks (assuming you have not just accidentally locked yourself out of the server)&lt;br /&gt;
 nft list ruleset&lt;br /&gt;
&lt;br /&gt;
get rich off your NFT!&lt;br /&gt;
&lt;br /&gt;
[[Category:System]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=644</id>
		<title>Firewall</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=644"/>
		<updated>2025-02-18T12:40:02Z</updated>

		<summary type="html">&lt;p&gt;Brendan: aha. need to use PRE tags for code blocks (and ascii art I suppose)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Different ways to handle &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;nftables&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Using &amp;lt;code&amp;gt;iptables-persistent&amp;lt;/code&amp;gt; on Debian ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; In use on &amp;lt;code&amp;gt;vrijdagmiddagborrel&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s basically a set of &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; plugins for &amp;lt;code&amp;gt;netfilter-persistent&amp;lt;/code&amp;gt;, which itself is a loader for different netfilter configuration. Once installed, it will take care of restoring rules at boot time, and through a small helper, can be used to reload/update/save rules on the fly.&lt;br /&gt;
&lt;br /&gt;
=== Installation and config ===&lt;br /&gt;
* Installation:&lt;br /&gt;
 apt install iptables-persistent netfilter-persistent&lt;br /&gt;
* Add/change iptables rules located at &amp;lt;code&amp;gt;/etc/iptables/rules.v4&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/iptables/rules.v6&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
* Apply new rules after changes made to &amp;lt;code&amp;gt;rules.v*&amp;lt;/code&amp;gt; files and check result&lt;br /&gt;
 netfilter-persistent reload&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; oneliners ==&lt;br /&gt;
* list all rules from all chains&lt;br /&gt;
 iptables -L&lt;br /&gt;
* block an IP&lt;br /&gt;
 iptables -I INPUT -s 192.168.111.111 -j DROP&lt;br /&gt;
 iptables -I OUTPUT -d 192.168.111.111 -j DROP&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== nftables ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;nftables&#039;&#039; is the hip new thing in the kernel. It has nicer, easier to read config syntax and has a bunch of performance improvements. Current Debian (12) comes with it installed (but turned off).&lt;br /&gt;
&lt;br /&gt;
* enable the firewall&lt;br /&gt;
 systemctl enable nftables&lt;br /&gt;
&lt;br /&gt;
* a basic firewall config you can drop into /etc/nftables.conf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    icmp type echo-request accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
table ip6 firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # invalid connections&lt;br /&gt;
    ct state invalid drop&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    # routers may also want: mld-listener-query, nd-router-solicit&lt;br /&gt;
    icmpv6 type { echo-request, nd-neighbor-solicit } accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* start the firewall&lt;br /&gt;
systemctl start nftables&lt;br /&gt;
&lt;br /&gt;
* see how it looks (assuming you have not just accidentally locked yourself out of the server)&lt;br /&gt;
nft list ruleset&lt;br /&gt;
&lt;br /&gt;
get rich off your NFT!&lt;br /&gt;
&lt;br /&gt;
[[Category:System]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=643</id>
		<title>Firewall</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=643"/>
		<updated>2025-02-18T12:36:58Z</updated>

		<summary type="html">&lt;p&gt;Brendan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Different ways to handle &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;nftables&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Using &amp;lt;code&amp;gt;iptables-persistent&amp;lt;/code&amp;gt; on Debian ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; In use on &amp;lt;code&amp;gt;vrijdagmiddagborrel&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s basically a set of &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; plugins for &amp;lt;code&amp;gt;netfilter-persistent&amp;lt;/code&amp;gt;, which itself is a loader for different netfilter configuration. Once installed, it will take care of restoring rules at boot time, and through a small helper, can be used to reload/update/save rules on the fly.&lt;br /&gt;
&lt;br /&gt;
=== Installation and config ===&lt;br /&gt;
* Installation:&lt;br /&gt;
 apt install iptables-persistent netfilter-persistent&lt;br /&gt;
* Add/change iptables rules located at &amp;lt;code&amp;gt;/etc/iptables/rules.v4&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/iptables/rules.v6&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
* Apply new rules after changes made to &amp;lt;code&amp;gt;rules.v*&amp;lt;/code&amp;gt; files and check result&lt;br /&gt;
 netfilter-persistent reload&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; oneliners ==&lt;br /&gt;
* list all rules from all chains&lt;br /&gt;
 iptables -L&lt;br /&gt;
* block an IP&lt;br /&gt;
 iptables -I INPUT -s 192.168.111.111 -j DROP&lt;br /&gt;
 iptables -I OUTPUT -d 192.168.111.111 -j DROP&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== nftables ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;nftables&#039;&#039; is the hip new thing in the kernel. It has nicer, easier to read config syntax and has a bunch of performance improvements. Current Debian (12) comes with it installed (but turned off).&lt;br /&gt;
&lt;br /&gt;
* enable the firewall&lt;br /&gt;
 systemctl enable nftables&lt;br /&gt;
&lt;br /&gt;
* a basic firewall config you can drop into /etc/nftables.conf&lt;br /&gt;
{{Codesample |&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    icmp type echo-request accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
table ip6 firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # invalid connections&lt;br /&gt;
    ct state invalid drop&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    # routers may also want: mld-listener-query, nd-router-solicit&lt;br /&gt;
    icmpv6 type { echo-request, nd-neighbor-solicit } accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
* start the firewall&lt;br /&gt;
systemctl start nftables&lt;br /&gt;
&lt;br /&gt;
* see how it looks (assuming you have not just accidentally locked yourself out of the server)&lt;br /&gt;
nft list ruleset&lt;br /&gt;
&lt;br /&gt;
get rich off your NFT!&lt;br /&gt;
&lt;br /&gt;
[[Category:System]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=642</id>
		<title>Firewall</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=642"/>
		<updated>2025-02-18T12:35:32Z</updated>

		<summary type="html">&lt;p&gt;Brendan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Different ways to handle &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;nftables&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Using &amp;lt;code&amp;gt;iptables-persistent&amp;lt;/code&amp;gt; on Debian ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; In use on &amp;lt;code&amp;gt;vrijdagmiddagborrel&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s basically a set of &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; plugins for &amp;lt;code&amp;gt;netfilter-persistent&amp;lt;/code&amp;gt;, which itself is a loader for different netfilter configuration. Once installed, it will take care of restoring rules at boot time, and through a small helper, can be used to reload/update/save rules on the fly.&lt;br /&gt;
&lt;br /&gt;
=== Installation and config ===&lt;br /&gt;
* Installation:&lt;br /&gt;
 apt install iptables-persistent netfilter-persistent&lt;br /&gt;
* Add/change iptables rules located at &amp;lt;code&amp;gt;/etc/iptables/rules.v4&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/iptables/rules.v6&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
* Apply new rules after changes made to &amp;lt;code&amp;gt;rules.v*&amp;lt;/code&amp;gt; files and check result&lt;br /&gt;
 netfilter-persistent reload&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; oneliners ==&lt;br /&gt;
* list all rules from all chains&lt;br /&gt;
 iptables -L&lt;br /&gt;
* block an IP&lt;br /&gt;
 iptables -I INPUT -s 192.168.111.111 -j DROP&lt;br /&gt;
 iptables -I OUTPUT -d 192.168.111.111 -j DROP&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== nftables ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;nftables&#039;&#039; is the hip new thing in the kernel. It has nicer, easier to read config syntax and has a bunch of performance improvements. Current Debian (12) comes with it installed (but turned off).&lt;br /&gt;
&lt;br /&gt;
* enable the firewall&lt;br /&gt;
 systemctl enable nftables&lt;br /&gt;
&lt;br /&gt;
* a basic firewall config you can drop into /etc/nftables.conf&lt;br /&gt;
{{code |&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    icmp type echo-request accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
table ip6 firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # invalid connections&lt;br /&gt;
    ct state invalid drop&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    # routers may also want: mld-listener-query, nd-router-solicit&lt;br /&gt;
    icmpv6 type { echo-request, nd-neighbor-solicit } accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
* start the firewall&lt;br /&gt;
systemctl start nftables&lt;br /&gt;
&lt;br /&gt;
* see how it looks (assuming you have not just accidentally locked yourself out of the server)&lt;br /&gt;
nft list ruleset&lt;br /&gt;
&lt;br /&gt;
get rich off your NFT!&lt;br /&gt;
&lt;br /&gt;
[[Category:System]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=641</id>
		<title>Firewall</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Firewall&amp;diff=641"/>
		<updated>2025-02-18T12:30:23Z</updated>

		<summary type="html">&lt;p&gt;Brendan: add docs for nftables firewall&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Different ways to handle &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;nftables&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Using &amp;lt;code&amp;gt;iptables-persistent&amp;lt;/code&amp;gt; on Debian ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; In use on &amp;lt;code&amp;gt;vrijdagmiddagborrel&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It&#039;s basically a set of &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; plugins for &amp;lt;code&amp;gt;netfilter-persistent&amp;lt;/code&amp;gt;, which itself is a loader for different netfilter configuration. Once installed, it will take care of restoring rules at boot time, and through a small helper, can be used to reload/update/save rules on the fly.&lt;br /&gt;
&lt;br /&gt;
=== Installation and config ===&lt;br /&gt;
* Installation:&lt;br /&gt;
 apt install iptables-persistent netfilter-persistent&lt;br /&gt;
* Add/change iptables rules located at &amp;lt;code&amp;gt;/etc/iptables/rules.v4&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/iptables/rules.v6&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
* Apply new rules after changes made to &amp;lt;code&amp;gt;rules.v*&amp;lt;/code&amp;gt; files and check result&lt;br /&gt;
 netfilter-persistent reload&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; oneliners ==&lt;br /&gt;
* list all rules from all chains&lt;br /&gt;
 iptables -L&lt;br /&gt;
* block an IP&lt;br /&gt;
 iptables -I INPUT -s 192.168.111.111 -j DROP&lt;br /&gt;
 iptables -I OUTPUT -d 192.168.111.111 -j DROP&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== nftables ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;nftables&#039;&#039; is the hip new thing in the kernel. It has nicer, easier to read config syntax and has a bunch of performance improvements. Current Debian (12) comes with it installed (but turned off).&lt;br /&gt;
&lt;br /&gt;
* enable the firewall&lt;br /&gt;
 systemctl enable nftables&lt;br /&gt;
&lt;br /&gt;
* a basic firewall config you can drop into /etc/nftables.conf&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    icmp type echo-request accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
table ip6 firewall {&lt;br /&gt;
  chain incoming {&lt;br /&gt;
    type filter hook input priority 0; policy drop;&lt;br /&gt;
&lt;br /&gt;
    # established/related connections&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # invalid connections&lt;br /&gt;
    ct state invalid drop&lt;br /&gt;
&lt;br /&gt;
    # loopback interface&lt;br /&gt;
    iifname lo accept&lt;br /&gt;
&lt;br /&gt;
    # icmp&lt;br /&gt;
    # routers may also want: mld-listener-query, nd-router-solicit&lt;br /&gt;
    icmpv6 type { echo-request, nd-neighbor-solicit } accept&lt;br /&gt;
&lt;br /&gt;
    # open tcp ports: sshd (22), httpd (80)&lt;br /&gt;
    tcp dport { ssh, http, https, 999 } accept&lt;br /&gt;
&lt;br /&gt;
    # tinc&lt;br /&gt;
    udp dport { 60000-61000 } accept&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* start the firewall&lt;br /&gt;
systemctl start nftables&lt;br /&gt;
&lt;br /&gt;
* see how it looks (assuming you have not just accidentally locked yourself out of the server)&lt;br /&gt;
nft list ruleset&lt;br /&gt;
&lt;br /&gt;
get rich off your NFT!&lt;br /&gt;
&lt;br /&gt;
[[Category:System]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Tinc_Settings_for_LURK&amp;diff=625</id>
		<title>Tinc Settings for LURK</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Tinc_Settings_for_LURK&amp;diff=625"/>
		<updated>2024-07-17T19:26:26Z</updated>

		<summary type="html">&lt;p&gt;Brendan: add ns334441&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== LURK specific settings ==&lt;br /&gt;
&lt;br /&gt;
Tinc is currently installed to connect nodes in the lurk network&lt;br /&gt;
&lt;br /&gt;
 agnesbaxter = 10.0.1.3&lt;br /&gt;
 skattkista = 10.0.1.2 (currently dead)&lt;br /&gt;
 vrijdagmiddagborrel = 10.0.1.4&lt;br /&gt;
 manis = 10.0.1.5&lt;br /&gt;
 poplar = 10.0.1.6&lt;br /&gt;
 ns334441 = 10.0.1.7&lt;br /&gt;
 tilia = 10.0.1.8&lt;br /&gt;
&lt;br /&gt;
skattkista, vmb, manis and poplar connect to agnesbaxter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: VPN]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Tinc_Settings_for_LURK&amp;diff=624</id>
		<title>Tinc Settings for LURK</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Tinc_Settings_for_LURK&amp;diff=624"/>
		<updated>2024-07-17T16:30:40Z</updated>

		<summary type="html">&lt;p&gt;Brendan: add tilia&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== LURK specific settings ==&lt;br /&gt;
&lt;br /&gt;
Tinc is currently installed to connect nodes in the lurk network&lt;br /&gt;
&lt;br /&gt;
 agnesbaxter = 10.0.1.3&lt;br /&gt;
 skattkista = 10.0.1.2 (currently dead)&lt;br /&gt;
 vrijdagmiddagborrel = 10.0.1.4&lt;br /&gt;
 manis = 10.0.1.5&lt;br /&gt;
 poplar = 10.0.1.6&lt;br /&gt;
 tilia = 10.0.1.7&lt;br /&gt;
&lt;br /&gt;
skattkista, vmb, manis and poplar connect to agnesbaxter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: VPN]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
	<entry>
		<id>https://things.bleu255.com/runyourown/index.php?title=Tinc_Settings_for_LURK&amp;diff=524</id>
		<title>Tinc Settings for LURK</title>
		<link rel="alternate" type="text/html" href="https://things.bleu255.com/runyourown/index.php?title=Tinc_Settings_for_LURK&amp;diff=524"/>
		<updated>2023-09-13T12:01:36Z</updated>

		<summary type="html">&lt;p&gt;Brendan: update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== LURK specific settings ==&lt;br /&gt;
&lt;br /&gt;
Tinc is currently installed to connect nodes in the lurk network&lt;br /&gt;
&lt;br /&gt;
 agnesbaxter = 10.0.1.3&lt;br /&gt;
 skattkista = 10.0.1.2 (currently dead)&lt;br /&gt;
 vrijdagmiddagborrel = 10.0.1.4&lt;br /&gt;
 manis = 10.0.1.5&lt;br /&gt;
 poplar = 10.0.1.6&lt;br /&gt;
&lt;br /&gt;
skattkista, vmb, manis and poplar connect to agnesbaxter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: VPN]]&lt;/div&gt;</summary>
		<author><name>Brendan</name></author>
	</entry>
</feed>