Azure Networking(5) : Network security Groups

Azure Networking(5) : Network security Groups

We cannot talk about Azure network security group without mentioning Network security group, so in this article I will explain how NSG works, explain what Inbound and outbound security rules are, how to connect NSG to a subnet and how all the VMs in that Subnet will inherent the inbound and outbound rules we may create inside that NSG.

Where to find Network Security Group:

NSG can be attached to Subnets or NICs (Network Interface Card) which is attached to the VM (Virtual machine)

Aucun texte alternatif pour cette image
NSG attached to VM
Aucun texte alternatif pour cette image
NSG attached to Subnet



How to Create a Network Security Group :

The NSG can be directly created from the Azure portal or by using Azure CLI and more.

Aucun texte alternatif pour cette image
To create NSG using Azure Portal
Aucun texte alternatif pour cette image
To create NSG using Azure CLI


Inbounds Security Rules:

These are all the rules that control the incoming traffic to the VM, and they have one of two actions, Deny or Allow.

Aucun texte alternatif pour cette image
The default inbound security rules


There are three default inbound security rules and they cannot be deleted. The first for allowing connection coming from Vents when peering happens (Source: Vnet, Destination: Vnet), the second is to allow connection coming from azure load balancer (Source : load balancer, Destination : any) and the last one for denying any other connection regardless of its source or destination.

When there are two similar rules but with different actions, Priority comes to the picture, and the rule that has the lesser priority win.

Outbound Security Rules:

These are all the rules that control the out-coming traffic from the VM, and they have one of two actions, Deny or Allow.

Aucun texte alternatif pour cette image
The default outbound security rules


There are also three outbound security rules and cannot either be deleted. First one is to allow connection toward Vents when peering happens (Source: Vnet, Destination: Vnet), the second for allowing connection to Internet (Source: Any, Destination : Internet) and the third one is to deny any other connection regardless of its source or destination.

Also, it is true for outbound security rules, when there are two similar rules but with different actions, Priority comes to the picture, and the rule that has the lesser priority win.

Some practice

Here we will create inbound security rule, so we could connect to our VM through SSH (secure shell) protocol, and to make that happen we need to create inbound rule with allow action, and port 22 and see what happens.


Before creating the inbound security rule:

Aucun texte alternatif pour cette image
Before creating the inbound rule that allows ssh connection.


First, let us try to connect before creating the rule.

Aucun texte alternatif pour cette image


As you can see, it is impossible because the network security group doesn’t have a rule that allow such connection.

After creating the inbound security rule:

Let us first create an inbound security rule that allows SSH and to do that, we will follow the images just below.

Aucun texte alternatif pour cette image
Adding the inbound security rule of SSH, so we could connect
Aucun texte alternatif pour cette image
After adding the inbound security rule that allows ssh connection.


Let us now try to connect.

Aucun texte alternatif pour cette image


Now here we go, we could connect to the VM and that is because now the NSG has a rule that allow such connection.

I hope this could be helpful and useful, and you’ve enjoyed. I welcome any comment or question.

要查看或添加评论,请登录

Mohamed-Lamin Taleb的更多文章

  • Azure Networking (4) : VPNGateway (Vnet-to-Vnet)

    Azure Networking (4) : VPNGateway (Vnet-to-Vnet)

    In this fourth articles about Azure networking, I would like to share with how to establish connection between two…

  • How To Build Your Own ChatGPT API With Express_js

    How To Build Your Own ChatGPT API With Express_js

    As AI is going so popular, I felt the need to explain how someone could build his own ChatGPT API using one of the…

  • Azure Networking(3) : Peering

    Azure Networking(3) : Peering

    Peering is the best way to open a connection between two virtual networks, so the virtual machines inside those virtual…

  • Azure Networking (2) : Private Endpoints

    Azure Networking (2) : Private Endpoints

    Private endpoints are somehow extremely Important when it comes to the privacy of the cloud and its security parameter,…

  • Azure Networking (1): Azure Private DNS Zones

    Azure Networking (1): Azure Private DNS Zones

    Azure private DNS zone is one of azure services to keep privacy on virtual networks (Vnet) in Azure networking, in this…

  • Patch Function in Power Apps : SharePoint Number Column

    Patch Function in Power Apps : SharePoint Number Column

    Patch Function in Power Apps : SharePoint Number Column Let me show you, how to update a column of the type Number in…

  • How To Call Power Automate From Canvas App

    How To Call Power Automate From Canvas App

    Here in this article, we’ll see how to call Power Automate From Canvas App using PowerApps(V2) Action in Power Automate…

  • How To Install WordPress: Step-by-Step Guide

    How To Install WordPress: Step-by-Step Guide

    Used by more than 455 million sites, WordPress is a content management system (CMS) that has existed since 2003. It…

  • How To Get Started With NextJS

    How To Get Started With NextJS

    Nextjs is a Framework for creating pre-rendered React websites by server-side rendering (SSR) or static side generation…

  • How to use GPS in PowerApps.

    How to use GPS in PowerApps.

    Maps can be used to show contextual information to your users, reason for witch allowing you to represent location data…

    1 条评论

社区洞察

其他会员也浏览了