Skip to content

Commit 2f59635

Browse files
author
Adam Ciarciński
committed
More on firewall internals
1 parent e1893d1 commit 2f59635

File tree

4 files changed

+192
-117
lines changed

4 files changed

+192
-117
lines changed

.gitbook/assets/image (5).png

-3.44 KB
Binary file not shown.

enterprise/all-enteprise-features/access-control-list/README.md

Lines changed: 18 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Default policy defines how to treat network traffic (with regarding to resources
3636
* **Allow** - users and devices connected to a location will be able to access all resources within the network, if the resource access is not modified by one of ACL rules.
3737
* **Deny** - all traffic to network resources that is not regulated by one of the ACL rules will be blocked.
3838

39-
### How to define the default ACL Policy
39+
### How to define Default ACL Policy
4040

4141
Make sure ACL has been enabled (see above), otherwise the policy setting will not be inactive.
4242

@@ -64,7 +64,7 @@ Defguard does not track rule application status per location. In the event of ne
6464
* modified rules
6565
* deleted rules
6666

67-
Use the ![](<../../../.gitbook/assets/image (5).png>) button to apply all the rules from **Pending Changes** section.
67+
Use the **Deploy pending changes** button to apply all the rules from **Pending Changes** section.
6868

6969
{% hint style="info" %}
7070

@@ -95,15 +95,15 @@ The ACL form consists of three main sections:
9595

9696
* rule name
9797
* locations where the rule should be applied
98-
* enabling / disabling of the rule
98+
* enabling / disabling of the rule
9999

100100
{% hint style="info" %}
101101
Each rule in Defguard can be **enabled** or **disabled** individually. When a rule is disabled, it remains stored in the system but is not applied to any locations, meaning it has no effect on access control until re-enabled. This allows administrators to temporarily deactivate rules without deleting them, making it easy to toggle access policies as needed.
102102
{% endhint %}
103103

104104
#### Destination
105105

106-
This section is meant to define the resource to which access should be granted or restricted. Think of this section as the **"destination"** part of a firewall rule.
106+
This section is meant to define the resource to which access should be granted or restricted. Think of this section as the **destination** part of a firewall rule.
107107

108108
* IP addresses (IPv4 or IPv6) of the resources for which access will be granted or restricted. The addresses can be specified individually, by CIDR addresses (with a mask) or as a range. You can specify multiple comma-separated addresses. Examples of valid values for this field include:
109109
* `10.1.1.10, 10.1.2.0/24`
@@ -180,118 +180,29 @@ Now, click on **Deploy pending changes (1)** button. After that, the rule should
180180

181181
<figure><img src="../../../.gitbook/assets/image (75).png" alt=""><figcaption></figcaption></figure>
182182

183-
#### Implementation details
184-
185-
##### Linux
186-
187-
All applied rules are deployed to Defguard Gateway. This means that the firewall on the Gateway that handles the _Office-Berlin_ location should contain appropriate [NFTables](https://nftables.org/) rules that implement the specified requirements. Let's see how this looks like in practice. Below is the `nftables list ruleset` output:
188-
189-
```
190-
...
191-
table inet DEFGUARD {
192-
chain FORWARD {
193-
type filter hook forward priority filter; policy drop;
194-
ct state established,related counter packets 0 bytes 0 accept
195-
ip saddr { 10.100.200.155-10.100.200.156 } ip daddr { 10.1.1.0/24 } counter packets 0 bytes 0 accept comment "ACL 132 - Office access Berlin ALLOW"
196-
ip daddr { 10.1.1.0/24 } counter packets 0 bytes 0 drop comment "ACL 132 - Office access Berlin DENY"
197-
}
198-
}
199-
...
200-
```
201-
202-
As you can see, Defguard has created a new inet-type table. This is to make sure Defguard's configuration won't interfere with your existing nftables.
203-
204-
The FORWARD chain specifies our rules. First you can see the `policy drop` default, which is a result of setting the **"default Deny"** policy in the location settings. Then the `established,related` line to skip reevaluation of established connections.
205-
206-
Finally the two lines that directly deal with our requirement to allow the two users into the network.
207-
208-
```
209-
ip saddr { 10.100.200.155-10.100.200.156 } ip daddr { 10.1.1.0/24 } counter packets 0 bytes 0 accept comment "ACL 132 - Office access Berlin ALLOW"
210-
```
211-
212-
This rule specifies two addresses as the **"traffic source" -** `10.100.200.155` and `10.100.200.156` . Those happen to be device addresses of our two users in the Wireguard VPN network that the gateway manages for this Location. The destination address **"10.1.1.0/24"** is exactly the network address we specified in the rule. And finally the **"accept"** verdict. All together, this rule allows the traffic specified in the UI to the network.
213-
214-
You may also notice that Defguard added a comment to the rule. The comment includes rule name so that it is easy for you to find the rule using tools like grep etc.
215-
216-
Finally, the last line:
217-
218-
```
219-
ip daddr { 10.1.1.0/24 } counter packets 0 bytes 0 drop comment "ACL 132 - Office access Berlin DENY"
220-
```
221-
222-
This line effectively blocks all other traffic to the 10.1.1.0/24 network. As mentioned earlier, the ACL rules in Defguard are self-contained and fully define access for their target resource. This set of rules can now be deployed to any gateway, no regardless of the **"default policy"** setting, and they will effectively do the same thing.
183+
(See [Implementation Details](firewall-internals.md) documentation to understand integrationn with system packet filtering.)
223184

224185
#### Adding access exceptions for specific users
225186

226-
Let's build on the last example. The example defined a single rule that grants access to a network to two users. In this example we will block access for one specific user. But first let's rethink our approach.
187+
Let's build on the last example. The example defined a single rule that grants network access for two users. In this example we will block access for one specific user. But first let's rethink our approach.
227188

228-
You may be tempted to specify the access for each user individually like we did while constructing the first rule. This may work at first or if your users don't change too often. But what if you have a constant influx of new users? This might get tedious pretty fast.
189+
It may be tempting to specify the access for each user individually, like we did while constructing the first rule. This may work at first or if your users don't change too often. But what if you have a constant influx of new users? This might get tedious pretty fast.
229190

230191
So what we will do is:
231192

232-
* we will define two groups
233-
* staff-berlin
234-
* externals
235-
* we will add all the users that work in our "Berlin" office to staff-berlin group
236-
* we will add all users we collaborate with in Berlin, but are not our direct employees, to the "externals" group
237-
* we will allow all users in staff-berlin group access to the network
238-
* we will add an exception for the users in "externals" group so that they are not allowed to access the network
193+
* we will define two groups:
194+
* _Staff-Berlin_
195+
* _Externals_
196+
* we will add all the users that work in our _Berlin_ office to _Staff-Berlin_ group
197+
* we will add all users we collaborate with in _Berlin_, but are not our direct employees, to the _Externals_ group
198+
* we will allow all users in _Staff-Berlin_ group access to the network
199+
* we will add an exception for the users in _Externals_ group so that they are not allowed to access the network
239200

240201
Once you have created appropriate groups and assigned the users, let's update the ACL rule. The rule should now:
241202

242-
* still be assigned to the **"office-berlin"** location
243-
* still define the destination resource address as "10.1.1.0/24"
244-
* instead of specific users in the **"Allowed Users"** input we now select the **"staff-berlin"** group in the **"Allowed Groups"** input
245-
* in **"Denied Groups"** input we should now select the **"externals"** group
203+
* still be assigned to the _Office-Berlin_ location
204+
* still define the destination resource address as `10.1.1.0/24`
205+
* instead of specific users in the **Allowed Users** input, we now select the _Staff-Berlin_ group in the **Allowed Groups** input
206+
* in **Denied Groups** input we should now select the _Externals_ group
246207

247208
<figure><img src="../../../.gitbook/assets/image (80).png" alt=""><figcaption></figcaption></figure>
248-
249-
## Gateway deployment with ACL
250-
251-
Under the hood, Access Control functionality uses [nftables](https://wiki.nftables.org/wiki-nftables/index.php/What_is_nftables%3F) to interact with the firewall and implement the rules. This means you'll need kernel version ≥ 5.10 to enable all kernel features required for proper operation.
252-
253-
### IP Forwarding
254-
255-
For traffic to flow between your network interfaces on Linux you may also need to enable IP forwarding, if you haven't done it already. This can be achieved by setting the `ip_forward` variable with the following command:
256-
257-
```
258-
sysctl -w net.ipv4.ip_forward=1
259-
```
260-
261-
If you want to make the change persistent, you will need to edit the `/etc/sysctl.conf` file and add the following line to it:
262-
263-
```
264-
net.ipv4.ip_forward = 1
265-
```
266-
267-
To load your changes in `sysctl.conf`, you can use `sysctl -p`.
268-
269-
### Masquerade
270-
271-
Masquerading between network interfaces falls outside the scope of Defguard’s responsibilities and must be handled by the system administrator. If your environment doesn’t already provide proper routing between the gateway’s interfaces, you may need to enable masquerading to ensure seamless communication.
272-
273-
As a shortcut, Defguard Gateway offers the `--masquerade` flag (or the `DEFGUARD_MASQUERADE=true` environment variable), which applies source NAT between all interfaces automatically, saving you from manually configuring masquerade rules at the system level. It results in this masquerade nftables rule:
274-
275-
```
276-
chain POSTROUTING {
277-
...
278-
oifname != "lo" counter packets 4 bytes 240 masquerade
279-
}
280-
```
281-
282-
{% hint style="warning" %}
283-
The `--masquerade` option applies masquerading between **all** interfaces on the gateway, which may be more permissive than necessary in some environments. While convenient, this broad behavior might not align with more restrictive or segmented network designs. For greater control and tighter security, we recommend that administrators configure masquerading manually between only the interfaces that require it.
284-
{% endhint %}
285-
286-
### Forward chain priority
287-
288-
Defguard creates a forward chain in its namespace to control which forwarded packets are being allowed or blocked. This may interfere with your other nftables rules and chains.
289-
290-
```
291-
chain FORWARD {
292-
type filter hook forward priority filter; policy deny;
293-
ct state established,related counter packets 119 bytes 13404 accept
294-
}
295-
```
296-
297-
By default this chain has the priority of `filter` (0). You can edit the priority by setting the `DEFGUARD_FW_PRIORITY` environment variable (or `fw_priority` config option) to chosen number, e.g. 1. The higher the priority, the later the chain runs in regard to your other forward chains.

enterprise/all-enteprise-features/access-control-list/acl-aliases.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# ACL Aliases
22

3-
ACL alias functionality allows administrators to create reusable elements which can then be used when defining a destination in multiple ACL rules.&#x20;
3+
ACL alias functionality allows administrators to create reusable elements which can then be used when defining a destination in multiple ACL rules.
44

5-
For example you can define aliases for commonly used ports (e.g. 22 for SSH) or for services within your infrustructure (e.g. 1.2.3.4:5432 for a PostgreSQL server).
5+
For example you can define aliases for commonly used ports (e.g. 22 for SSH) or for services within your infrustructure (e.g. 1.2.3.4:5432 for a particular PostgreSQL server).
66

77
{% hint style="warning" %}
88
Access Control is an [enterprise feature](../../license.md). To use it you'll need to [purchase a license](../../license.md#purchasing-the-license) or ensure your deployment does not [exceed the limits](../../license.md#enterprise-is-free-up-to-certain-limits).
@@ -20,24 +20,24 @@ All the aliases defined in your systems are displayed in the second tab of the *
2020

2121
Similarly to ACL rules themselves, the list is split into two sections:
2222

23-
* **Deployed Aliases** - aliases that are active and can be used by ACL rules
24-
* **Pending Changes** - aliases that have been modified and have not yet been deployed
23+
* **Deployed Aliases** aliases that are active and can be used by ACL rules.
24+
* **Pending Changes** aliases that have been modified and have not yet been deployed.
2525

26-
To deploy pending changes use the **Deploy pending changes** button. It will deploy selected changes or all pending changes if none have been selected.
26+
To deploy pending changes use the **Deploy pending changes** button. It will deploy selected or all pending changes.
2727

2828
{% hint style="warning" %}
29-
When alias changes are deployed, firewall rules will be updated for all affected locations.
29+
When the alias changes are deployed, firewall rules will be updated for all affected locations.
3030
{% endhint %}
3131

3232
### How to add and modify aliases
3333

34-
To create a new rule, use the ![](<../../../.gitbook/assets/image (6).png>) button in the list view.
34+
To create a new rule, use the **Add new** button on the list view.
3535

3636
You can edit an existing rule by using the ![](<../../../.gitbook/assets/image (12).png>) context menu and selecting **Edit** in the list view.
3737

3838
<figure><img src="../../../.gitbook/assets/image (102).png" alt=""><figcaption><p>Alias creation form</p></figcaption></figure>
3939

40-
In the ACL alias form you can specify alias name and [type](acl-aliases.md#alias-types).&#x20;
40+
In the ACL alias form you can specify alias name and [type](.#alias-types).
4141

4242
Below in the **Destination** section you can enter the same resource configuration as in the [ACL rule Destination](./#destination):
4343

@@ -71,8 +71,8 @@ Aliases can be used to define an ACL rule destination by selecting them in the i
7171

7272
Aliases are divided into two distinct types to handle various use-cases:
7373

74-
* **Destination** alias - defines a complete [ACL destination](./#destination); it will be translated into a separate set of firewall rules
75-
* **Component** alias - defines a part of [ACL destination](./#destination); it will be merged with destination manually configured in a given ACL rule when generating firewall rules
74+
* **Destination** alias defines a complete [ACL destination](./#destination); it will be translated into a separate set of firewall rules.
75+
* **Component** alias defines a part of [ACL destination](./#destination); it will be merged with destination manually configured in a given ACL rule when generating firewall rules.
7676

7777
### Examples
7878

0 commit comments

Comments
 (0)