| 1 |
# Host Firewall |
| 2 |
|
| 3 |
Following examples apply for: |
| 4 |
|
| 5 |
* Your personal laptop |
| 6 |
* Your personal workstation |
| 7 |
* Corporate server behind [router firewall](router-firewall.md) |
| 8 |
* Corporate server on cloud |
| 9 |
* Any other system with only one network connection |
| 10 |
|
| 11 |
|
| 12 |
## Incoming only |
| 13 |
|
| 14 |
This is the simplest possible firewall. All outgoing traffic is accepted |
| 15 |
and few listed incoming services are accepted. |
| 16 |
|
| 17 |
``` mermaid |
| 18 |
flowchart LR |
| 19 |
public@{shape: cloud} --> localhost@{shape: stadium} |
| 20 |
``` |
| 21 |
|
| 22 |
``` |
| 23 |
zone { |
| 24 |
localhost |
| 25 |
public * # All network interfaces belong to zone "public" |
| 26 |
} |
| 27 |
|
| 28 |
public-localhost { # Allow specified incoming traffic |
| 29 |
dhcp-client |
| 30 |
dhcpv6-client |
| 31 |
ping |
| 32 |
ssh |
| 33 |
drop log |
| 34 |
} |
| 35 |
|
| 36 |
localhost-public { # Allow all outgoing traffic |
| 37 |
accept |
| 38 |
} |
| 39 |
``` |
| 40 |
|
| 41 |
Above example is complete `/etc/foomuuri/foomuuri.conf` configuration |
| 42 |
file - there is nothing else to be added. It allows incoming |
| 43 |
(`public-localhost`) traffic: |
| 44 |
|
| 45 |
* DHCP reply packets to obtain a lease from external DHCP server (IPv4 and |
| 46 |
IPv6) |
| 47 |
* Ping packets (no ping-flood protection) |
| 48 |
* SSH |
| 49 |
* Everything else is dropped and logged |
| 50 |
|
| 51 |
All outgoing (`localhost-public`) traffic is accepted. This is usually safe |
| 52 |
but more specific bidirectional firewall is safer. |
| 53 |
|
| 54 |
|
| 55 |
## Bidirectional |
| 56 |
|
| 57 |
This example accepts listed incoming services and listed outgoing services. |
| 58 |
|
| 59 |
``` mermaid |
| 60 |
flowchart LR |
| 61 |
public@{shape: cloud} <--> localhost@{shape: stadium} |
| 62 |
``` |
| 63 |
|
| 64 |
``` |
| 65 |
zone { |
| 66 |
localhost |
| 67 |
public * |
| 68 |
} |
| 69 |
|
| 70 |
public-localhost { |
| 71 |
dhcp-client |
| 72 |
dhcpv6-client |
| 73 |
ping saddr_rate "5/second burst 20" |
| 74 |
ssh saddr_rate "5/minute burst 5" |
| 75 |
drop log |
| 76 |
} |
| 77 |
|
| 78 |
localhost-public { |
| 79 |
dhcp-server |
| 80 |
dhcpv6-server |
| 81 |
domain |
| 82 |
http |
| 83 |
https |
| 84 |
imap |
| 85 |
ntp |
| 86 |
ping |
| 87 |
smtp |
| 88 |
ssh |
| 89 |
reject log |
| 90 |
} |
| 91 |
``` |
| 92 |
|
| 93 |
This complete `/etc/foomuuri/foomuuri.conf` configuration file allows incoming: |
| 94 |
|
| 95 |
* DHCP reply packets |
| 96 |
* Ping packets, except ping-flood |
| 97 |
* SSH, up to 5 connections per minute per source IP |
| 98 |
* Everything else is dropped and logged |
| 99 |
|
| 100 |
Following outgoing traffic is allowed: |
| 101 |
|
| 102 |
* DHCP request packets to obtain a lease |
| 103 |
* DNS queries |
| 104 |
* HTTP and HTTPS |
| 105 |
* IMAP |
| 106 |
* NTP |
| 107 |
* Ping packets |
| 108 |
* SMTP |
| 109 |
* SSH |
| 110 |
* Everything else is rejected and logged |
| 111 |
|
| 112 |
|
| 113 |
## Multi-zone |
| 114 |
|
| 115 |
This is similar to bidirectional example, except there are two outgoing |
| 116 |
zones: |
| 117 |
|
| 118 |
* `public` is the default untrusted connection. There is no network interface |
| 119 |
listed. Use NetworkManager to assign network interface to `public` zone when |
| 120 |
you're connecting to untrusted Wi-Fi network, for example in a cafe. |
| 121 |
* `home` is trusted connection. Again use NetworkManager to select `home` |
| 122 |
zone when you're in a safe place, like at your home or office. |
| 123 |
|
| 124 |
This example also shows you how to use `template` to avoid listing |
| 125 |
same basic services in `localhost-public` and in `localhost-home`. |
| 126 |
|
| 127 |
``` mermaid |
| 128 |
flowchart LR |
| 129 |
subgraph WAN |
| 130 |
direction TB |
| 131 |
public@{shape: cloud} |
| 132 |
home@{shape: cloud} |
| 133 |
end |
| 134 |
public <--> localhost@{shape: stadium} |
| 135 |
home <--> localhost |
| 136 |
``` |
| 137 |
|
| 138 |
``` |
| 139 |
zone { |
| 140 |
localhost |
| 141 |
public |
| 142 |
home |
| 143 |
} |
| 144 |
|
| 145 |
public-localhost { # Incoming traffic in a cafe |
| 146 |
dhcp-client |
| 147 |
dhcpv6-client |
| 148 |
ping saddr_rate "5/second burst 20" |
| 149 |
ssh saddr_rate "5/minute burst 5" |
| 150 |
drop log |
| 151 |
} |
| 152 |
|
| 153 |
home-localhost { # Incoming traffic in safe location |
| 154 |
dhcp-client |
| 155 |
dhcpv6-client |
| 156 |
lsdp |
| 157 |
mdns |
| 158 |
ping |
| 159 |
ssdp |
| 160 |
ssh |
| 161 |
drop log |
| 162 |
} |
| 163 |
|
| 164 |
template outgoing_services { # Common outgoing traffic |
| 165 |
dhcp-server |
| 166 |
dhcpv6-server |
| 167 |
domain |
| 168 |
http |
| 169 |
https |
| 170 |
imap |
| 171 |
ntp |
| 172 |
ping |
| 173 |
smtp |
| 174 |
ssh |
| 175 |
} |
| 176 |
|
| 177 |
localhost-public { # Outgoing traffic in a cafe |
| 178 |
template outgoing_services |
| 179 |
reject log |
| 180 |
} |
| 181 |
|
| 182 |
localhost-home { # Outgoing traffic in safe location |
| 183 |
template outgoing_services |
| 184 |
googlemeet |
| 185 |
ipp |
| 186 |
mdns |
| 187 |
ssdp |
| 188 |
reject log |
| 189 |
} |
| 190 |
``` |