|
| 1 | +--- |
| 2 | +title: Congigure IP firewall for Azure Relay namespace |
| 3 | +description: This article describes how to Use firewall rules to allow connections from specific IP addresses to Azure Relay namespaces. |
| 4 | +services: service-bus-relay |
| 5 | +documentationcenter: '' |
| 6 | +author: spelluru |
| 7 | + |
| 8 | +ms.service: service-bus-relay |
| 9 | +ms.devlang: na |
| 10 | +ms.custom: seodec18 |
| 11 | +ms.topic: article |
| 12 | +ms.date: 05/07/2020 |
| 13 | +ms.author: spelluru |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +# Configure IP firewall for an Azure Relay namespace |
| 18 | +By default, Relay namespaces are accessible from internet as long as the request comes with valid authentication and authorization. With IP firewall, you can restrict it further to only a set of IPv4 addresses or IPv4 address ranges in [CIDR (Classless Inter-Domain Routing)](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) notation. |
| 19 | + |
| 20 | +This feature is helpful in scenarios in which Azure Relay should be only accessible from certain well-known sites. Firewall rules enable you to configure rules to accept traffic originating from specific IPv4 addresses. For example, if you use Relay with [Azure Express Route](../expressroute/expressroute-faqs.md#supported-services), you can create a **firewall rule** to allow traffic from only your on-premises infrastructure IP addresses. |
| 21 | + |
| 22 | + |
| 23 | +> [!IMPORTANT] |
| 24 | +> This feature is currently in preview. |
| 25 | +
|
| 26 | + |
| 27 | +## Enable IP firewall rules |
| 28 | +The IP firewall rules are applied at the namespace level. Therefore, the rules apply to all connections from clients using any supported protocol. Any connection attempt from an IP address that does not match an allowed IP rule on the namespace is rejected as unauthorized. The response does not mention the IP rule. IP filter rules are applied in order, and the first rule that matches the IP address determines the accept or reject action. |
| 29 | + |
| 30 | +### Use Azure portal |
| 31 | +This section shows you how to use the Azure portal to create IP firewall rules for a namespace. |
| 32 | + |
| 33 | +1. Navigate to your **Relay namespace** in the [Azure portal](https://portal.azure.com). |
| 34 | +2. On the left menu, select **Networking** option. If you select the **All networks** option in the **Allow access from** section, the Relay namespace accepts connections from any IP address. This setting is equivalent to a rule that accepts the 0.0.0.0/0 IP address range. |
| 35 | + |
| 36 | +  |
| 37 | +1. To restrict access to specific networks and IP addresses, select the **Selected networks** option. In the **Firewall** section, follow these steps: |
| 38 | + 1. Select **Add your client IP address** option to give your current client IP the access to the namespace. |
| 39 | + 2. For **address range**, enter a specific IPv4 address or a range of IPv4 address in CIDR notation. |
| 40 | + 3. Specify whether you want to **allow trusted Microsoft services to bypass this firewall**. |
| 41 | + |
| 42 | +  |
| 43 | +3. Select **Save** on the toolbar to save the settings. Wait for a few minutes for the confirmation to show up on the portal notifications. |
| 44 | + |
| 45 | + |
| 46 | +### Use Resource Manager template |
| 47 | +The following Resource Manager template enables adding an IP filter rule to an existing Relay namespace. |
| 48 | + |
| 49 | +The template takes one parameter: **ipMask**, which is a single IPv4 address or a block of IP addresses in CIDR notation. For example, in CIDR notation 70.37.104.0/24 represents the 256 IPv4 addresses from 70.37.104.0 to 70.37.104.255, with 24 indicating the number of significant prefix bits for the range. |
| 50 | + |
| 51 | +> [!NOTE] |
| 52 | +> While there are no deny rules possible, the Azure Resource Manager template has the default action set to **"Allow"** which doesn't restrict connections. |
| 53 | +> When making Virtual Network or Firewalls rules, we must change the |
| 54 | +> ***"defaultAction"*** |
| 55 | +> |
| 56 | +> from |
| 57 | +> ```json |
| 58 | +> "defaultAction": "Allow" |
| 59 | +> ``` |
| 60 | +> to |
| 61 | +> ```json |
| 62 | +> "defaultAction": "Deny" |
| 63 | +> ``` |
| 64 | +> |
| 65 | +
|
| 66 | +```json |
| 67 | +{ |
| 68 | + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", |
| 69 | + "contentVersion": "1.0.0.0", |
| 70 | + "parameters": { |
| 71 | + "relayNamespaceName": { |
| 72 | + "type": "string", |
| 73 | + "metadata": { |
| 74 | + "description": "Name of the Relay namespace" |
| 75 | + } |
| 76 | + }, |
| 77 | + "location": { |
| 78 | + "type": "string", |
| 79 | + "metadata": { |
| 80 | + "description": "Location for Namespace" |
| 81 | + } |
| 82 | + } |
| 83 | + }, |
| 84 | + "variables": { |
| 85 | + "namespaceNetworkRuleSetName": "[concat(parameters('relayNamespaceName'), concat('/', 'default'))]", |
| 86 | + }, |
| 87 | + "resources": [ |
| 88 | + { |
| 89 | + "apiVersion": "2018-01-01-preview", |
| 90 | + "name": "[parameters('relayNamespaceName')]", |
| 91 | + "type": "Microsoft.Relay/namespaces", |
| 92 | + "location": "[parameters('location')]", |
| 93 | + "sku": { |
| 94 | + "name": "Standard", |
| 95 | + "tier": "Standard" |
| 96 | + }, |
| 97 | + "properties": { } |
| 98 | + }, |
| 99 | + { |
| 100 | + "apiVersion": "2018-01-01-preview", |
| 101 | + "name": "[variables('namespaceNetworkRuleSetName')]", |
| 102 | + "type": "Microsoft.Relay/namespaces/networkruleset", |
| 103 | + "dependsOn": [ |
| 104 | + "[concat('Microsoft.Relay/namespaces/', parameters('relayNamespaceName'))]" |
| 105 | + ], |
| 106 | + "properties": { |
| 107 | + "ipRules": |
| 108 | + [ |
| 109 | + { |
| 110 | + "ipMask":"10.1.1.1", |
| 111 | + "action":"Allow" |
| 112 | + }, |
| 113 | + { |
| 114 | + "ipMask":"11.0.0.0/24", |
| 115 | + "action":"Allow" |
| 116 | + } |
| 117 | + ], |
| 118 | + "trustedServiceAccessEnabled": false, |
| 119 | + "defaultAction": "Deny" |
| 120 | + } |
| 121 | + } |
| 122 | + ], |
| 123 | + "outputs": { } |
| 124 | + } |
| 125 | +``` |
| 126 | +
|
| 127 | +To deploy the template, follow the instructions for [Azure Resource Manager](../azure-resource-manager/templates/deploy-powershell.md). |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | +## Next steps |
| 132 | +To learn about other network security-related features, see [Network security](network-security.md). |
| 133 | + |
| 134 | + |
| 135 | +<!-- Links --> |
| 136 | + |
| 137 | +[express-route]: /azure/expressroute/expressroute-faqs#supported-services |
| 138 | +[lnk-deploy]: |
0 commit comments