# Configure a Firewall

Activate and configure a [<mark style="color:blue;">Firewall</mark>](https://docs.ionos.com/support/general-information/glossary-of-terms#firewall) for each Network Interface Card ([<mark style="color:blue;">NIC</mark>](https://docs.ionos.com/support/general-information/glossary-of-terms#nic)) to better protect your servers from attacks. IONOS Cloud Firewalls can filter incoming (ingress), outgoing (egress), or bidirectional traffic. When configuring firewalls, define appropriate rules to filter traffic accordingly.

{% hint style="info" %}
**Note:** We recommend using [<mark style="color:blue;">Network Security Groups (NSGs)</mark>](../../../security/network-security-groups) for centralized and fine-grained firewall management in Virtual Data Centers (VDCs). It will enable you to control and monitor your network traffic efficiently.
{% endhint %}

## Activate a Firewall

To activate a Firewall, follow these steps:

1\. In the **Workspace**, select a Virtual Machine with a **NIC**.

2\. From the **Inspector** pane, open the **Network** tab.

3\. Open the properties of the NIC for which you want to set up a Firewall.

4\. Choose either **Ingress**, **Egress**, or **Bidirectional** traffic flow type for which the Firewall needs to be activated.

![Activate a Firewall](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-75a8662978d35d3034f7e7e1026e554e2eb04596%2Factivate_firewall.png?alt=media\&token=dfe658dd-f9d8-4b1c-b60e-f2f1a5222537)

{% hint style="warning" %}
**Warning:** Activating the Firewall without additional rules will block all incoming traffic. Make sure you set the Firewall rules by using **Manage Rules**.
{% endhint %}

{% hint style="success" %}
**Result:** The Firewall is activated for the selected **NIC**.
{% endhint %}

## Create a Firewall Rule

To create a Firewall rule, follow these steps:

1\. In the **Workspace**, select a VM with a **NIC**.

2\. From the **Inspector** pane, open the **Network** tab.

3\. Open the properties of the NIC for which you wish to manages Firewall Rules.

4\. Click **Manage Rules**.

5\. Click **Create Firewall Rule** and choose from the following type of Firewall rules to add from the drop-down list:

* TCP Rule
* UDP Rule
* ICMP Rule
* ICMPv6 Rule
* VRRP Rule
* GRE Rule
* AH Rule
* ESP Rule
* Any Protocol

![Create a Firewall Rule](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-cae72c60499969e18a93169179455405b7a91371%2Fnew_rules_firewalls.png?alt=media)

6\. Enter values for the following in a Firewall rule:

* **Name:** Enter a name for the rule.
* **Direction** Choose the traffic direction between **Ingress** and **Egress**.
* **Source MAC:** Enter the Media Access Control (MAC) address to be passed through by the firewall.
* **Source IP/CIDR:** Enter the [<mark style="color:blue;">IP address</mark>](https://docs.ionos.com/support/general-information/glossary-of-terms#ip-address) to be passed through by the Firewall.
* **Destination IP/CIDR:** If you use virtual IP addresses on the same network interface, you can enter them here to allow access.
* **Port Range Start:** Set the first port of an entire port range.
* **Port Range End:** Set the last port of a port range or enter the port from Port Range Start if you only want this port to be allowed.
* **ICMP Type:** Enter the ICMP Type to be allowed. Example: 0 or 8 for echo requests (ping) or 30 for traceroutes.
* **ICMP Code:** Enter the ICMP Code to be allowed. Example: 0 for echo requests.
* **IP Version:** Select a version from the drop-down list. By default, it is **Auto**.

![Values for a Firewall Rule](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-76176131990a06cd834ed74e794a38e19a88a79b%2Ffirewall_fields.png?alt=media\&token=49d3449e-620f-45d4-817e-2afa66e90b78)

7\. (Optional) You can add Firewall rules from an existing template by using **Rules from Template**. The **Generic Webserver**, **Mailserver**, **Remote Access Linux**, and **Remote Access Windows** are the types of Firewall rules you can add from the existing rules template.

![Firewall Rules from Template](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-7c09736596e812da36b71c876737c18aa794842d%2Ffirewall-rules-templates.png?alt=media\&token=8377f7ca-452f-4570-9c4e-ffb1dfacc1fc)

8\. Alternatively, you may import an existing rule set from the **Clone Rules from other NIC**.

9\. Click **Save** to confirm creating a Firewall rule.

{% hint style="success" %}
**Result:** A Firewall Rule is created with the configured values.
{% endhint %}
