Niklas Otter Wiki
Attachments
History
Blame
View Source
Documentation
Toggle dark mode
Login
Home
A - Z
Changelog
Page Index
Linux
CHMOD
INSTALL
Linux Directory Structure
NAMEI
RCLONE
Rename LAN Connections
SAMBA
SSD
STAT
SYSTEMD
TAR
UFW
Various
An Otter Wiki
Linux
UFW
f8d430
Commit
f8d430
2026-08-06 23:47:25
Niklas Polke
: Update with content of ufw-init.sh
linux/ufw.md
..
@@ 12,12 12,33 @@
If port 22/tcp is not allowed, ssh will be terminated and no connection will be possible any more!
:::
```bash
+
#!/usr/bin/env bash
+
+
LAN_NETWORK="192.168.2.0/24"
+
+
# stop & reset
+
sudo ufw disable
+
sudo ufw reset
+
+
# defaults
sudo ufw default deny incoming
sudo ufw default allow outgoing
-
sudo ufw allow 22/tcp # SSH
-
sudo ufw allow 80/tcp # HTTP
-
sudo ufw allow 443/tcp # HTTPS
+
# config
+
# .0/24 means only specify 24 Bits / the first 3 numbers -> .0 is ignored
+
sudo ufw allow in from "${LAN_NETWORK}" to any port 22 proto tcp comment 'LAN - SSH'
+
sudo ufw allow in from "${LAN_NETWORK}" to any port 445 proto tcp comment 'LAN - Samba'
+
sudo ufw allow in 80/tcp comment 'WWW - HTTP -> NGINX'
+
sudo ufw allow in 443/tcp comment 'WWW - HTTPS -> NGINX'
+
+
sudo ufw allow in to any port 8100 proto tcp from "${LAN_NETWORK}" comment 'LAN - Gunicorn'
+
sudo ufw allow in to any port 8200 proto tcp from "${LAN_NETWORK}" comment 'LAN - Otterwiki/Gunicorn'
+
sudo ufw allow in to any port 8300 proto tcp from "${LAN_NETWORK}" comment 'LAN - Django/Development'
+
+
# start
sudo ufw enable
+
+
# show
+
sudo ufw status verbose
```
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9