Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • DSA
  • Practice Problems
  • C
  • C++
  • Java
  • Python
  • JavaScript
  • Data Science
  • Machine Learning
  • Courses
  • Linux
  • DevOps
  • SQL
  • Web Development
  • System Design
  • Aptitude
  • GfG Premium
Open In App
Next Article:
Azure Network Security Groups
Next article icon

Azure Network Security Groups

Last Updated : 16 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Network Security Groups (NSG) play a crucial role in securing the virtual environment within Azure. Azure provides various services to help users secure their applications and the infrastructure that users create.

Table of Content

  • What is Azure?
  • What are Azure Networks?
  • Traditional Server Management
  • Problem in Traditional Server Management
  • Network Security Groups As A Solution
  • How Do Azure Network Security Groups Work?
  • Azure Network Security Rules
  • Default Security Rules
  • Augmented Security Group Rules
  • Service Tags In Azure Networks
  • What Are Application Security Groups?
  • How Azure Network Security Groups Filter Network Traffic?
  • Best Practices For Implementing NSG in Azure
  • How to Create NSG in Azure Portal? A Step-By-Step Guide
  • Video Demonstration of Azure Network Security Groups with Virtual Machine
  • Association of Network Security Groups
  • Virtual Network And Subnet Design
  • Azure Platform Considerations
  • Conclusion
  • Azure Network Security Groups - FAQs


What is Azure?

Azure is the leading cloud computing platform provided by Microsoft that offers various range of services and solutions for users to build, deploy, and manage applications on the pay-as-you-use module. To know more about Microsoft Azure refer to this Article - Azure Tutorials.

What are Azure Networks?

Azure networks are virtual networks that allow users to connect their organizational resources and services. All the things related to Azure Networks are monitored and maintained by Azure. So user has to just create their virtual networks, subnets, IP addresses, network interfaces, and other network components.

Traditional Server Management

Consider a scenario where we have five servers: three dedicated to handling web application traffic, one managing business logic, and an additional server hosting our database. As per our organization's architectural decision, we segment these servers into subnets. For instance, one subnet is designated for microservices and web application traffic, while another subnet is dedicated to handling our data-tier applications. These subnets must reside within a virtual network.

Problem in Traditional Server Management

Without additional configuration, if we create an infrastructure in this manner, all incoming traffic from the internet would be allowed to reach all these servers, and inter-server communication would also be unrestricted. Consequently, every component could communicate with each other a situation we want to avoid. It's imperative that internet traffic doesn't reach our database, and not all services should have unrestricted communication with one another. This is where NSG comes into play.

Network Security Groups As A Solution

By placing a Network Security Group on the first subnet, we can permit traffic from the internet to reach our web-tier services. Simultaneously, by implementing an NSG on the second subnet, we can prevent internet traffic while still allowing communication from our internal services.

How Do Azure Network Security Groups Work?

NSG is a tool for activating rules that manage traffic to the Virtual networks. Within NSG, an inbound rule refers to incoming traffic requests, while an outbound rule relates to outgoing traffic requests. These rules align with our organizational policy, dictating the permissions for both incoming and outgoing access.

After the creation of NSG, there are default security rules that we can't change, but we can override those rules with custom rules. By default, NSG allows inbound and outbound traffic from the same virtual network.

Azure Network Security Rules

Azure Network security provides custom control over the inbound and outbound traffic to the Azure services. It facilitates with secure cloud network by defining the network security groups with customized rules specifying what protocol, IP address, ports based traffic are allowed to Azure services. The following are the some of the key points:

  • Traffic Control: Network Security Groups provides the facility of defining the rules to allow or deny the traffic based on specific criteria letting control over the network communication.
  • Port-Leve Security: The rules defined in the network security groups will restrict the traffic based on TCP/UDP ports preventing the unauthorized access to sensitive services or applications.
  • IP Filtering: Network security groups support the application level filteringby enabling or blocking the traffic based on the application protocols, and enhancing the security for cloud based applications.

Default Security Rules

Azure provides the default security rules for both incoming and outcoming traffic in each network security group that we create:

Default Inbound Security Rules

PriorityNameSourceSource Port RangesDestinationDestination Port RangesProtocolAction
100AllowVnetInBoundVirtualNetwork*VirtualNetwork**Allow
200AllowAzureLoadBalancerInBoundAzureLoadBalancer*Any**Allow
65000DenyAllInBoundAny*Any**Deny

Default Outbound Security Rules

PriorityNameSourceSource Port RangesDestinationDestination Port RangesProtocolAction
100AllowVnetOutBoundVirtualNetwork*VirtualNetwork**Allow
65000DenyAllOutBoundAny*Any**Deny

Augmented Security Group Rules

Augement ed security rules in Azure network security groups provides the simplified definition for larger and complex network security policies. These rules lets to combine the multiple ports and explicit IP addresses and ranges into a single rule enhancing the clarity and see of understanding. The service tags or application security groups with augmented rules maintenance of security rule definitions ensuring the efficient management of network security policies.

Service Tags In Azure Networks

Serivce Tags in Azure Neworks facilitates with simplified management of grouping all the commonly used Azure services with predefined IP address ranges. These tags allows the administrators to easily define the network security rules for the Azure services by reducing the complexity and enhancing its security. It associates the security rules with service tags and helps with administrators in ensuring the consistent and secured network access for Azure services across their environment.

What Are Application Security Groups?

Application Security Groups in Azure facilitates with simplifying the network security with managing the groups of virtual machines based on the application tiers or roles. These groups provides the administrators to define the network security rules based on the application level of constructs rather than the individual IP addresses. By associating Azure network security groups with network security rules it facilitates with dynamic and scalable policies to adapt the changes in the Azure environment.

How Azure Network Security Groups Filter Network Traffic?

Azure Network Security Groups filter the network traffic by letting in or out for the communication based on defining the rules, offering a crucial layer of security for Azure resources. The following aspects discusses on Azure network security groups filters:

  • Rule Based Routing: NSGs are configured with the inbound and outbound security rules that decides the allow or deny of the traffic for accessing the Azure services based on criteria such as source and destination, IP address, port ranges and protocols.
  • Traffic Prioritization: NSGs priortizes the rules based on their order of precedence, with higher priority rues taking precedence over lower priority ones.

Inbound Traffic Control

  • Inbound rules control the incoming traffic to the services allowing administrators to specify which incoming connections should be permitted or blocked.
  • It refers to the data coming into the network or a specific resource within a network from the external sources. It often requires the security measures such as firewalls and network security groups to control the access and protect against the incoming threats/

Outbound Traffic

It represents the data that leaving from the network to outside or a specific resources within a network. we have to restrict the data flow that going to outside to avoid it is not get collected to authorized users and unsecured networks. It typically subjects to the filtering and monitoring of outbound traffic to ensure a security, compliance and efficient resource utilization.

Intra-Subnet Traffic

It facilitates with establishing the communication between the resources within the same subnet or virtual network. It often considered the trusted traffic but still requires the monitoring and ensuring potential security measures to prevent the authorized access or security breaches.

Best Practices For Implementing NSG in Azure

  • Plan and design network topology and network security rules before the creation of a virtual network.
  • Use descriptive tag names for NSG and security rules.
  • Deny all traffic, then allow the necessary traffic for the network.
  • Review and audit the network.
  • Test the network before deploying

How to Create NSG in Azure Portal? A Step-By-Step Guide

Step 1: Firstly Sign in to your Microsoft Azure Portal.Search for "Network Security Group" and click on respective.

Click on Network Security Group

step 2: Now, click on "Create," fill in the details in the Azure Portal, and click on "Review + Create." Finally, click on "Create."

Creating Network Security Group

Step 3: After successfully creation of NSG click on "Go to resource".

Successful creation of NSGs

Step 4: To associate this NSG with a subnet or interface, click on the "Subnets" service interface from the left menu present under Settings section.

  • Now, click on the "Associate" button and select a virtual network where you want to associate this NSG and click on OK.
Configuring the Associate Subnets

Let's See How The NSG Works In A Accessing Virtual Machine(VM)

Step 5: Sign in to your Microsoft Azure Portal.Search for "Virtual Machine" and click on respective.

Searching Virtual Machine
  • Click on "Create" and select "Azure Virtual Machine".
Creating Virtual Machine

Step 6: Enter and choose the configuration for your VM. Pick the 'Subscription' and 'Resource group' for your VM. Provide a unique name for your VM and select the 'Region' where you want to host it.

  • Choose the number of 'availability zones' for your VM. The crucial step is the Image selection; in this case, we are using a 'Windows' image, but you can select any you prefer.
  • Now, pick a 'Size' based on your requirements. Enter a username and password for your VM. These credentials will allow you to access your VM from anywhere. For the inbound port rule, select 'RDP'. Finally, click on "Review+create."

Configuring the Virtual Machine

Step 7: After configuring the Virtual Machine resources, Review once the configuration of resources and Click on Create as confirmation to create the Virtual Machine.

Reviewing the VM

  • Take a moment to check your VM configuration, then click on "Create."
Creating the VM

Step 8: After creating the VM successfully, click on "Go to resource."

Go to Resource Interface
  • Click on "Connect" and then select "Download RDP file."
Connect the VM


Once connect the respective VM try on downloading the RDP File by clicking on "Download RDP file"

Download the RDP file

Step 9: Click on the file you downloaded and provide the necessary permissions. Enter your VM password and click OK.

Login the VM with Credentials
  • Congratulations! Now, in just a few seconds, you can access your VM.

Accessing the VM from Windows

Step 10: Go to the "Network Settings" of your VM and delete the Inbound rule that we made. After that, try connecting to your VM again.

  • You will encounter an error message stating that you don't have access. This happens because the NSG is restricting access.
Error Generation for Remote Access
  • To regain access, we need to set up an inbound rule again. Navigate to "network settings," click on "Create port rule," then choose "inbound port rule."
  • Set the "Destination port ranges" to 3389, select the TCP protocol, and click on "add."
In bound Security Rules

Congratulations! Now, in just a few seconds, you can access your VM.

Video Demonstration of Azure Network Security Groups with Virtual Machine

This video shows how we use Azure Network Security Groups with Azure Virtual Machine. It demonstrates the process of connecting to the VM. When we delete our inbound rule, we are unable to connect to our VM. However, after creating an inbound rule specified during VM creation, we regain access to our VM.

Association of Network Security Groups

  • Granular control: It facilitates wit assigning the network security groups to subnets or individual interfaces and provides the granular control over the traffic flow within the Azure environment.
  • Security Segmentation: It provides the segmentation of the resources based on their security requirements. It allows administrators to define the specific security policies for different parts of networks.
  • Effective Security Enforcement: On association with NSGs with resources facilitates the administrators to provide the security policies such as allowing or denying the traffic based on source or Destination IP addresses, port ranges and protocols.

Virtual Network And Subnet Design

  • Isolation And Segmentation: Virtual Network Desing involves in creating and isolated network environments for segment the resources logically. It ensure the better security, performance and management.
  • Scalability and Performance: On implementing proper subnet deign with virtual networks provides and efficient resource allocation and scalability to optimize the performance and minimize the latency.
  • Connectivity and Accessibility: It designs the virtual networks and subnets involves planning for establishing VPC connections, Azure ExpressRoute or peering relationships. It ensure seamless communication between resources while maintaining the security and compliance.

Azure Platform Considerations

The following are the considerations for deploying applications on the Azure platform:

  • Scalability: Azure provides the scalable services like Azure App service and Azure Kubernetes Service (AKS) for facilitating the application to handle based on varying workloads.
  • Integration: Azure provides the seamless integration with other Azure services and third party tools with supporting easy development, deployment and management of applications.
  • Monitoring and Analytics: On usage of Azure Monitor and Azure log Analytics, it facilitates with gaining the insights into the application performance, troubleshoot issues and optimize the resource utilization.

Conclusion

In this article, we have observed the practical use of NSG by making changes in Virtual Machine configuration. Additionally, we discussed Traditional Server Management at the beginning and how to overcome it with NSG. We also covered best practices for implementing NSG and the steps to create NSG in the Azure portal


Next Article
Azure Network Security Groups

S

sushant_bagul
Improve
Article Tags :
  • Cloud Computing
  • azure
  • Geeks Premier League 2023

Similar Reads

    Configuring Network Settings for Azure VMs
    Microsoft Azure virtual machines (VMs) provide scalable on-demand computing resources. Configuring the network settings of these virtual machines is important to ensure they communicate effectively and securely within your infrastructure. This article walks you through the basics and step-by-step pr
    3 min read
    What is Azure Virtual Network Manager
    If you think about it, in the big picture of cloud computing, network management is a critical functionality for proper operation and communication signaling across disparate nodes. Of course, Microsoft Azure offers you quite a bit more than just this and that is what we are going to explore shortly
    11 min read
    Microsoft Azure - Rename Resource Group
    Pre-requisite:- Azure In this article, we will show you the process of renaming resource groups in azure. Is renaming really possible in azure for resource groups? The answer to this is not exactly, however, alternatively, we can create a new resource group and move the existing resource from the ol
    2 min read
    Microsoft Azure - Security in Azure SQL
    Pre-requisite: Azure VM Microsoft Azure is a cloud computing service offered by Microsoft for the purpose of application management through Microsoft-managed data centers. Microsoft Azure provides users with numerous application management options, which helps them freely and conveniently manage the
    7 min read
    Best Practices and Tips For Azure Security
    Pre-requisite:- Azure Azure is a cloud computing platform provided by Microsoft that offers a wide range of security features to help protect your resources and workloads. In this article, we will provide an overview of these security features and discuss how they can be used to secure your Azure re
    12 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences