Azure Firewall Rules are a crucial component of Azure Firewall, allowing you to manage internet traffic effectively. They help ensure that only authorized traffic is allowed to flow in and out of your Azure resources.
By configuring Azure Firewall Rules, you can block or allow specific traffic based on source and destination IP addresses, ports, and protocols. This level of control helps prevent unauthorized access to your resources.
Azure Firewall Rules can be applied at different levels, including Network Rule Collections, Application Rule Collections, and Threat Intelligence-based Rule Sets. Each level offers varying degrees of granularity and flexibility.
Understanding how to configure Azure Firewall Rules effectively is essential for securing your Azure environment.
Azure Firewall Rules
Azure Firewall Rules are a crucial aspect of securing your Azure resources. A server-level firewall rule is applicable for Azure SQL Server and all underlying Azure SQL Databases, blocking all connections to the public endpoint by default.
You can configure server-level firewall rules using Azure Portal, Azure CLI, Azure PowerShell, or T-SQL statements. Each connection must pass through the firewall before reaching the Azure server or database.
To add a new server-level firewall rule, you can use Azure Portal or Azure CLI. The maximum number of server-level firewall rules for an Azure server is 128.
In Azure Firewall, a rule collection group is used to group rule collections. There are three default rule collection groups with preset priority values, and you can create custom rule collection groups with your desired priority values.
A rule collection belongs to a rule collection group and contains one or multiple rules. Rule collections must have a defined action (allow or deny) and a priority value. The defined action applies to all the rules within the rule collection.
Here is a summary of the Azure Firewall rule types:
- DNAT (Destination Network Address Translation) rules allow or deny inbound traffic through one or more firewall public IP addresses.
- Network rules can be configured for TCP, UDP, ICMP, or Any IP protocol, and can be used to filter traffic based on source and destination IP addresses and ports.
- Application rules can be used to filter traffic based on the application protocol (e.g. HTTP, HTTPS) and can include TLS inspection.
Azure Firewall also has a rule processing order, where network rules are applied first, followed by application rules. If no match is found, the packet is denied by default.
Server Level
Azure Firewall Rules can be configured at the server level, which applies to all underlying Azure SQL Databases. This means that each connection must pass through the firewall before it can reach the Azure server or database.
By default, a new Azure logical SQL Server blocks all connections to the public endpoint. The public endpoint is the FQDN of the Azure server in the form of [AzureServer].database.windows.net. Azure stores the firewall rules in the master database, allowing a maximum of 128 server-level firewall rules for an Azure server.
To configure the server-level firewall rule, you can use Azure Portal, Azure CLI, Azure PowerShell, or T-SQL statements. If you enable the option – Allow Azure Services and resources to access this server, it is considered a single server firewall rule.
The server-level firewall rules are applied after the database-level firewall rules. If the client IP is within the database firewall rule, it gets direct access to the database. If there is no database-level firewall or client IP is not allowed in DB firewall, Azure checks the Server level firewall rule.
Server-level firewall rules can be deleted using the Azure portal or the T-SQL statement. For example, you can run the stored procedure sp_delete_firewall_rule on the master database to remove a server-level firewall rule.
Here are some key facts about server-level firewall rules:
- Maximum of 128 rules per Azure server
- Can be configured using Azure Portal, Azure CLI, Azure PowerShell, or T-SQL statements
- Considered a single rule if Allow Azure Services and resources to access this server is enabled
- Applied after database-level firewall rules
- Can be deleted using the Azure portal or T-SQL statement
SQL Database Key Points
Implementing a database firewall rule is recommended instead of a server firewall rule for client connections, as it enhances security by restricting clients from accessing all databases in an Azure SQL Server.
Most of the time, changes to Azure firewalls are instantaneous, but it may take up to five minutes for changes to be effective.
To connect to Azure SQL Databases, ensure that the Azure server or database level firewall allows the client IP address to connect.
If your client has a local firewall, you must allow port 1433 in the local firewall to ensure your request reaches the Azure boundary for connection.
If your computer uses dynamic IP addresses, you may face issues with DB connections, and you can resolve this by using the Azure portal to view the current public IP address or by using the portal https://www.whatismyip.com/.
Threat Intelligence
Threat Intelligence is a powerful feature in Azure Firewall that helps protect your network from known threats. It's enabled by default, but you can adjust the settings to suit your needs.
Threat intelligence-based filtering takes priority over other rules, so if a threat is detected, it will be blocked first. This ensures your network is protected from the most critical threats.
The rules for threat intelligence are highest priority and are always processed first, before network and application rules. This means that if a threat is detected, it will be blocked before any other rules can be applied.
Threat intelligence filtering may deny traffic before any configured rules are processed, so it's essential to understand how it works and configure it correctly.
Changes
Changing Azure Firewall rules can have significant effects on your network. If you change a rule to deny previously allowed traffic, any relevant existing sessions are dropped.
You should be aware of this before making changes, especially if you have active sessions running. This is a crucial consideration when updating your rules.
Changing a rule to allow previously denied traffic will not automatically restore existing dropped sessions.
Three-Way Handshake Behavior
Three-way handshake behavior is crucial to understand when working with Azure Firewall rules.
As a stateful service, Azure Firewall completes a TCP three-way handshake for allowed traffic, from a source to the destination.
Creating an allow rule from one virtual network to another doesn't automatically allow new initiated connections in the opposite direction.
There's no need to create an explicit deny rule from the second virtual network to the first, as the three-way handshake behavior will handle it.
SKU Features Comparison
Azure Firewall offers three SKUs – Basic, Standard, and Premium. The Basic SKU is recommended for small and medium size businesses with an estimated throughput of up to 250 Mbps.
The Basic SKU comes with a range of features, including Fully Qualified Domain Name (FQDN) tags, Service tags, Threat intelligence in alert mode, and Outbound SNAT and Inbound DNAT support.
Azure Firewall Basic also supports Multiple public IP addresses, Azure Monitor logging, Certifications, Network traffic filtering rules, Application FQDN filtering rules, Availability Zones, and High availability.
Here's a comparison of the features across the three SKUs:
The Standard SKU adds features like Unrestricted cloud scalability, DNS proxy, Custom DNS, and Forced tunnelling.
IP and Traffic Management
IP and Traffic Management is a crucial aspect of Azure Firewall Rules. Firewalls are a key component of this management.
To configure IP firewall rules for Azure SQL Databases, you'll need to consider four main areas: Firewalls, authentication, authorization, and Permissions. These areas work together to restrict connections to the database.
Firewalls help filter incoming and outgoing network traffic based on predetermined security rules. This ensures that only authorized traffic reaches your Azure SQL Database.
Here are the main components you'll need to configure for IP firewall rules:
- Firewalls
- Authentication
- Authorization
- Permissions
- Encryption
Encryption is also important for securing data in transit. By configuring IP firewall rules correctly, you can protect your Azure SQL Database from unauthorized access and ensure the security of your data.
Policy and Rules
Azure Firewall rules are a crucial part of securing your Azure resources. You can create inbound and outbound security rules using Application Security Groups. To do this, open the network security group you created earlier, click on Inbound security rules, and configure it.
You can also set up server-level firewall rules using the Azure Portal. To do this, navigate to the Azure SQL Database dashboard, click on Set Server Firewall, and add the client IP address or specify the Rule name and IP address range. Azure SQL Server allows DB to connect to default port 1433 for a single IP address or a range of IP addresses.
To create a NAT rule, select the NAT rule collection tab, click on + Add NAT rule collection, and enter the values, such as the NAT rule collection name, priority, and rules. You can also create a DNAT rule to allow RDP access by adding a NAT rule collection with the necessary details, including the protocol, source type, source, destination address, and destination ports.
Here's a summary of the different types of rules you can create:
Server/Database Level Application
Server-level firewall rules are applicable for Azure SQL Server and apply to all underlying Azure SQL Databases. Each connection must pass through the firewall before it can reach out to the Azure server or database.
By default, once we create a new Azure logical SQL Server, the server-level firewall blocks all connections to the public endpoint. The public endpoint is the FQDN of the Azure server in the form of [AzureServer].database.windows.net.
You can use Azure Portal, Azure CLI, Azure PowerShell, or T-SQL statements to configure the server-level firewall rule.
Azure stores the firewall rules in the master database and allows a maximum of 128 server-level firewall rules for an Azure server.
To configure the server-level firewall rule, you can use Azure Portal, Azure CLI, Azure PowerShell, or T-SQL statements.
Here are the options to configure server-level firewall rules:
- Add client IP: You can use this option to add the current client IP in the allowed IP that connects to Azure SQL Server.
- Specify the Rule name and IP address range in the Start IP and End IP section.
Once you click on Add client IP, it creates a rule with the same start and End IP address.
Azure SQL Server allows DB to connect to default port 1433 for a single IP address or a range of IP addresses.
To remove a server firewall rule, you can use the Azure portal or the T-SQL statement. For example, you can run the stored procedure sp_delete_firewall_rule on the master database.
Note that the server or database-level firewall restricts the client connections to Azure SQL Databases. However, you still require authentication using SQL or Azure Active Directory Authentication.
How to Filter Inbound Internet Traffic with Policy DNAT
Filtering inbound internet traffic with policy DNAT is a crucial step in securing your network.
Azure Firewall policy DNAT allows you to redirect traffic from a specific IP address or port to a different destination within Azure. This feature is useful for exposing internal resources to the web or changing the traffic direction to specific services or servers.
To filter inbound internet traffic with policy DNAT, you need to create a DNAT rule in your Azure Firewall. This rule will specify the source IP address, destination IP address, and port numbers for the traffic redirection.
Here are the steps to create a DNAT rule:
- In the Azure portal, go to your resource group and select your firewall policy.
- Under Settings, select DNAT rules and click + Add a rule collection.
- Enter the following values: Name, Priority, and NAT rule details.
The Azure Firewall public IP addresses can be used to listen to inbound traffic from the Internet, filter the traffic, and translate this traffic to internal resources in Azure.
By following these steps, you can effectively filter inbound internet traffic with policy DNAT and secure your network.
Policy
A policy is a set of rules that guide decision-making and behavior within an organization or community.
Clear policies help prevent misunderstandings and promote a sense of fairness.
Policies can be formal or informal, but they should always be communicated clearly to all stakeholders.
For example, a company's social media policy might dictate what types of posts are allowed on their official accounts.
Policies can be updated or revised as needed, but it's essential to communicate these changes to everyone affected.
In some cases, policies may be written down in a single document, while in others, they may be scattered across various sources.
Filtering Work
In Azure, filtering work is a crucial aspect of network security. Azure processes rules associated with subnets first for inbound security rules.
For inbound rules, Azure checks if a subnet has associated rules before processing rules linked to a VM's network interface. This means subnet rules can override interface rules if there's a conflict.
Inbound security rules associated with network interfaces are applied last, so they can override subnet rules if there's a conflict. This is different from outbound rules, where Azure processes interface rules before subnet rules.
Here's a summary of how Azure processes inbound and outbound rules:
Azure's approach to filtering work ensures that subnet rules are applied first for inbound traffic, while interface rules take priority for outbound traffic. This helps to maintain a secure network environment by allowing for more granular control over incoming and outgoing traffic.
Sources
- https://www.sqlshack.com/configure-ip-firewall-rules-for-azure-sql-databases/
- https://learn.microsoft.com/en-us/azure/firewall/policy-rule-sets
- https://learn.microsoft.com/en-us/azure/firewall/rule-processing
- https://www.whizlabs.com/blog/filter-inbound-traffic-azure-firewall/
- https://infrasos.com/secure-azure-network-with-azure-firewall-security-groups/
Featured Images: pexels.com