You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 KiB
21 KiB
Alias | Tag | Date | DocType | Hierarchy | TimeStamp | location | CollapseMetaTable | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
2021-10-04 | Personal | NonRoot |
|
true |
Parent:: Selfhosting, Server Alias, Server Cloud, Server Tools, Server VPN
^Top
name Save
type command
action Save current file
id Save
^button-UFWSave
Configuring UFW
title: Summary
collapse: open
Description of basic commands for UFW
style: number
Installation and activation
UFW should be installed by default in Ubuntu servers. If not, see below.
Installation of UFW
~~~bash
sudo apt install ufw
~~~
Activation of UFW
~~~bash
sudo ufw status
~~~
If disabled:
~~~bash
sudo ufw enable
~~~
Basic commands
UFW rules status
~~~bash
sudo ufw status
~~~
Commands can be appended:
verbose
: details incoming/outgoing rulesnumbered
: display rule numbers
UFW rule management
Allow / Deny
~~~bash
sudo ufw allow/deny
~~~
Then:
Type to allow | Syntax |
---|---|
IP | from (ip address/range) |
Port | (portnumber)/(protocol) |
Service | (service name) |
Protocol | proto (protocol name) |
Rule priority
Certain rules like IP denial need to be put on top of the rule stack as UFW reads rules in order one after another. Insert the following in the command to force insertion:
~~~bash
insert 1 (or any place in the pecking order)
~~~
Complex rule syntax
Finer rules can be defined with the following syntax.
rule condition | syntax |
---|---|
connecting IP | from (ip or any) |
internal IP | to (ip or any) |
protocol | proto (protocol or any) |
port | port (port or any) |
outgoing traffic | out |
Delete a rule
~~~bash
sudo ufw delete <rule number>
~~~
Ban List management
Ban List Folder
/etc/addip4ban/
Ban List Script
title: addip4ban.sh
~~~bash
#!/bin/bash
INPUT="/etc/addip4ban/blocked.ip.list"
while IFS= read -r block
do
sudo ufw insert 1 deny from "$block"
done < "$INPUT"
~~~
Once written, the script needs to be executed. To prepare:
~~~bash
sudo chmod +x /etc/addip4ban/addip4ban.sh
~~~
Ban List Document
title: blocked.ip.list
~~~bash
< ip1 >
< ip2/range >
< ip3 >
~~~
Ban list Update Process
Copy/paste the new ban list into blocked.ip.list
and run:
~~~bash
sudo bash /etc/addip4ban/addip4ban.sh
~~~
Ban List Tasks
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-03-09
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-03-02 ✅ 2024-03-01
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-02-24 ✅ 2024-02-23
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-02-17 ✅ 2024-02-17
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-02-10 ✅ 2024-02-09
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-02-03 ✅ 2024-02-02
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-01-27 ✅ 2024-01-27
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-01-20 ✅ 2024-01-20
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-01-13 ✅ 2024-01-12
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-01-06 ✅ 2024-01-06
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-12-30 ✅ 2023-12-31
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-12-23 ✅ 2023-12-23
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-12-16 ✅ 2023-12-16
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-12-09 ✅ 2023-12-08
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-12-02 ✅ 2023-12-01
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-11-25 ✅ 2023-11-24
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-11-18 ✅ 2023-11-17
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-11-11 ✅ 2023-11-10
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-11-04 ✅ 2023-11-03
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-10-28 ✅ 2023-10-27
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-10-21 ✅ 2023-10-20
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-10-14 ✅ 2023-10-13
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-10-07 ✅ 2023-10-06
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-09-30 ✅ 2023-09-29
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-09-23 ✅ 2023-09-23
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-09-16 ✅ 2023-09-15
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-09-09 ✅ 2023-09-08
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-09-02 ✅ 2023-09-04
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-08-26 ✅ 2023-08-26
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-08-19 ✅ 2023-08-20
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-08-12 ✅ 2023-08-12
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-08-05 ✅ 2023-08-05
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-07-29 ✅ 2023-08-04
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-07-22 ✅ 2023-07-22
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-07-15 ✅ 2023-07-14
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-07-08 ✅ 2023-07-08
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-07-01 ✅ 2023-07-04
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-06-24 ✅ 2023-06-24
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-06-17 ✅ 2023-06-16
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-06-10 ✅ 2023-06-10
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-06-03 ✅ 2023-06-03
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-05-27 ✅ 2023-05-27
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-05-20 ✅ 2023-05-22
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-05-13 ✅ 2023-05-13
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-05-06 ✅ 2023-05-06
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-04-29 ✅ 2023-05-01
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-04-22 ✅ 2023-04-21
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-04-15 ✅ 2023-04-15
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-04-08 ✅ 2023-04-07
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-04-01 ✅ 2023-04-03
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-03-25 ✅ 2023-03-25
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-03-18 ✅ 2023-03-18
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-03-11 ✅ 2023-03-10
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-03-04 ✅ 2023-03-03
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-02-25 ✅ 2023-02-24
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-02-18 ✅ 2023-02-17
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-02-11 ✅ 2023-02-11
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-08-12 ✅ 2023-08-07
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-08-05 ✅ 2023-08-05
- 🖥 Selfhosting, Configuring UFW Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2023-07-29 ✅ 2023-08-04
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2024-03-09
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2024-03-02 ✅ 2024-03-01
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2024-02-24 ✅ 2024-02-23
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2024-02-17 ✅ 2024-02-17
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2024-02-10 ✅ 2024-02-09
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2024-02-03 ✅ 2024-02-02
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2024-01-27 ✅ 2024-01-27
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2024-01-20 ✅ 2024-01-20
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2024-01-13 ✅ 2024-01-12
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2024-01-06 ✅ 2024-01-06
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-12-30 ✅ 2023-12-31
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-12-23 ✅ 2023-12-23
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-12-16 ✅ 2023-12-16
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-12-09 ✅ 2023-12-08
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-12-02 ✅ 2023-12-01
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-11-25 ✅ 2023-11-24
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-11-18 ✅ 2023-11-17
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-11-11 ✅ 2023-11-10
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-11-04 ✅ 2023-11-03
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-10-28 ✅ 2023-10-27
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-10-21 ✅ 2023-10-20
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-10-14 ✅ 2023-10-13
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-10-07 ✅ 2023-10-06
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-09-30 ✅ 2023-09-29
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-09-23 ✅ 2023-09-23
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-09-16 ✅ 2023-09-15
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-09-09 ✅ 2023-09-08
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-09-02 ✅ 2023-09-04
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-08-26 ✅ 2023-08-26
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-08-19 ✅ 2023-08-20
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-08-12 ✅ 2023-08-12
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-08-05 ✅ 2023-08-07
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-07-29 ✅ 2023-08-07
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-07-22 ✅ 2023-07-22
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-07-15 ✅ 2023-07-14
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-07-08 ✅ 2023-07-08
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-07-01 ✅ 2023-07-04
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-06-24 ✅ 2023-06-24
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-06-17 ✅ 2023-06-16
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-06-10 ✅ 2023-06-10
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-06-03 ✅ 2023-06-03
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-05-27 ✅ 2023-05-27
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-05-20 ✅ 2023-05-22
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-05-13 ✅ 2023-05-13
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-05-06 ✅ 2023-05-06
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-04-29 ✅ 2023-05-01
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-04-22 ✅ 2023-04-21
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-04-15 ✅ 2023-04-15
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-04-08 ✅ 2023-04-07
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-04-01 ✅ 2023-04-03
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-03-25 ✅ 2023-03-25
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-03-18 ✅ 2023-03-18
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-03-11 ✅ 2023-03-10
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-03-04 ✅ 2023-03-03
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-02-25 ✅ 2023-02-24
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-02-18 ✅ 2023-02-17
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-02-11 ✅ 2023-02-11
- 🖥 Selfhosting, Configuring UFW: Update the Blocked IP list %%done_del%% 🔁 every month on Saturday 📅 2023-02-04 ✅ 2023-02-04