UFW should be installed by default in Ubuntu servers. If not, see below.
 
#### Installation of UFW
```ad-command
~~~bash
sudo apt install ufw
~~~
```
 
#### Activation of UFW
```ad-command
~~~bash
sudo ufw status
~~~
```
If disabled:
```ad-command
~~~bash
sudo ufw enable
~~~
```
 
---
 
### Basic commands
[[#^Top|TOP]]
 
#### UFW rules status
```ad-command
~~~bash
sudo ufw status
~~~
```
Commands can be appended:
-`verbose`: details incoming/outgoing rules
-`numbered`: display rule numbers
 
#### UFW rule management
[[#^Top|TOP]]
##### Allow / Deny
```ad-command
~~~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:
```ad-command
~~~bash
insert 1 (or any place in the pecking order)
~~~
```
 
##### Complex rule syntax
Finer rules can be defined with the following syntax.
- [ ] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-10-19
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-10-12 ✅ 2024-10-14
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-10-05 ✅ 2024-10-04
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-09-28 ✅ 2024-09-27
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-09-21 ✅ 2024-09-20
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-09-14 ✅ 2024-09-13
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-09-07 ✅ 2024-09-08
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-08-31 ✅ 2024-09-01
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-08-24 ✅ 2024-08-24
- [ ] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-10-19
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-10-12 ✅ 2024-10-14
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-10-05 ✅ 2024-10-04
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-09-28 ✅ 2024-09-27
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-09-21 ✅ 2024-09-20
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-09-14 ✅ 2024-09-13
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-09-07 ✅ 2024-09-08
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-08-31 ✅ 2024-09-01
- [x] 🖥 [[Selfhosting]], [[Configuring UFW|Firewall]] Get IP addresses caught by Postfix %%done_del%% 🔁 every week on Saturday 📅 2024-08-24 ✅ 2024-08-24