|
| 1 | +--- |
| 2 | +meta: |
| 3 | + title: Understanding Network ACLs |
| 4 | + description: Learn how to Network Access Control Lists (NACL) filter inbound and outbound traffic bewteen the different Private Networks of your VPC. Understand concepts, best practices, and key use cases. |
| 5 | +content: |
| 6 | + h1: Understanding Network ACLs |
| 7 | + paragraph: ELearn how to Network Access Control Lists (NACL) filter inbound and outbound traffic bewteen the different Private Networks of your VPC. Understand concepts, best practices, and key use cases. |
| 8 | +tags: vpc nacl network-access-control-list default-rule stateless inbound outbound port |
| 9 | +dates: |
| 10 | + validation: 2025-02-07 |
| 11 | + posted: 2025-02-07 |
| 12 | +categories: |
| 13 | + - network |
| 14 | +--- |
| 15 | + |
| 16 | +Every VPC has a Network **A**ccess **C**ontrol **L**ist (NACL). This list is composed of stateless rules to control the flow of traffic between the Private Networks fo the VPC. By default, at first the list contains no rules and therefore traffic is allowed to flow unrestrictedly. |
| 17 | + |
| 18 | +This document sets out general information and best practices about Scaleway VPC NACLs. |
| 19 | + |
| 20 | +- For instructions on managing NACLs via the Scaleway console, see [How to manage Network ACLs](/vpc/how-to/manage-nacl/) |
| 21 | +- To manage NACLs via the Scaleway API, see the [VPC API doumentation](https://www.scaleway.com/en/developers/api/vpc/) |
| 22 | +- For other interfaces, see the documentation of the [relevant developer tool](https://www.scaleway.com/en/developers/) |
| 23 | + |
| 24 | +## Network ACL overview |
| 25 | + |
| 26 | +Every Scaleway VPC has a Network ACL. In its initial state, it contains no rules and allows all traffic to flow freely between the Private Networks of the VPC. |
| 27 | + |
| 28 | +When you start adding rules to your NACL, traffic flow is restricted between certain sources and destinations within the VPC, according to the rules you set. A default rule is added to the NACL, which dictates the action to take on traffic that does not match of the rules in the list: it can either be **allowed** or **denied**. |
| 29 | + |
| 30 | +<Lightbox src="scaleway-nacl-diag-simple.webp" alt="A schema shows how the NACL sits at the intersection of two Private Networks in a Scaleway VPC" /> |
| 31 | + |
| 32 | +NACL rules are stateless, meaning that the state of connections is not tracked, and return traffic is not automatically allowed, just because the outbound request was allowed. Explicit rules are required for each direction of traffic. |
| 33 | + |
| 34 | +NACLs only control traffic as it enters or exits the Private Network(s) of a VPC. They do not: |
| 35 | +- Filter traffic between resources attached to the same Private Network |
| 36 | +- Filter traffic from/to the public internet (for this, use [security groups](/instances/how-to/use-security-groups/) for Instances, or equivalent features for [other resource types](/ipam/reference-content/)). |
| 37 | + |
| 38 | +The diagram below shows how a NACL blocks an Instance on Private Network A from sending any traffic to any resources on Private B. The Instance's attempt to send a packet (in green) is denied. |
| 39 | + |
| 40 | +However, an Instance on Private Network B is able to send a packet to an Instance on Private Network A, because no specific rules deny it from doing so, and the default rule is set to allow. |
| 41 | + |
| 42 | +<Lightbox src="scaleway-nacl-diag-detail.webp" alt="A schema shows how the NACL sits at the intersection of two Private Networks in a Scaleway VPC. Packets attempt to travel between Private Networks, and are either allowed or denied according to NACL rules" /> |
| 43 | + |
| 44 | +## NACL rule configuration |
| 45 | + |
| 46 | +When defining an NACL rule, you must enter the following settings: |
| 47 | + |
| 48 | +- **IP version**: Either IPv4 or IPv6. The rule will apply only to traffic matching this IP version, meaning that in effect, each VPC has two NACLs: one for IPv4 and one for IPv6. If you want to create an equivalent rule for the other IP version, you must do so separately. |
| 49 | + |
| 50 | +- **Protocol**: Either `TCP`, `UDP` or `ICMP`. The rule will apply only to traffic matching this protocol. Alternatively, you can choose `All` if you want it to apply to traffic matching any protocol. |
| 51 | + |
| 52 | +- **Source** and **destination**: The rule will apply to traffic originating from this source and being sent to this destination. For both, enter an IP range range in [CIDR format](/vpc/concepts/#cidr-block), and a port or port range. Alternatively, you can opt for the rule to apply to**All IPs** and/or **All ports**. |
| 53 | + |
| 54 | +- **Action**: The NACL will either **Allow** or *Deny** traffic that matches the rule, to to proceed to its destination. |
| 55 | + |
| 56 | +## Rule priority and application |
| 57 | + |
| 58 | +The Network Access Control List should be read from top to bottom. Rules closer to the top of the list are applied first. If traffic matches a rule for an **Allow** or **Deny** action, the action is applied immediately. That traffic is not then subject to any further filtering or any further actions by any rules that follow. |
| 59 | + |
| 60 | +## Statelessness |
| 61 | + |
| 62 | +**NACL rules are stateless**. This means the state of connections is not tracked, and inbound and outbound traffic is filtered separately. Return traffic is not automatically allowed, just because the outbound request was allowed. Explicit rules are required for each direction of traffic. |
| 63 | + |
| 64 | +Therefore, if you create a rule to allow traffic in one direction, you may also need a separate rule to allow the response in the opposite direction. There is a functionality to auto-generate matching inverse rules for this purpose when creating a new rule. |
| 65 | + |
| 66 | +TODO: example of how traffic that is allowed to one destination won't be llowed to return without correct rule |
| 67 | + |
| 68 | +## Default rule |
| 69 | + |
| 70 | +Each NACL must have a default rule, which is automatically at the bottom of the list of rules. You can choose whether the rule has an action of **Allow** or **Deny**. The default rule applies this action to all traffic that did not match any other rules in the list. |
| 71 | + |
| 72 | +TODO: examples of how default rule works as either allow or deny (see https://docs.aws.amazon.com/vpc/latest/userguide/default-network-acl.html ) |
| 73 | + |
| 74 | + |
| 75 | +TODO: |
| 76 | +- Ephemeral ports? |
| 77 | +- Examples |
| 78 | +- Best practices (see https://docs.aws.amazon.com/vpc/latest/userguide/vpc-security-best-practices.html) |
0 commit comments