{"id":680,"date":"2021-07-06T20:44:58","date_gmt":"2021-07-06T20:44:58","guid":{"rendered":"https:\/\/www.spktechfit.com\/?p=680"},"modified":"2021-07-06T20:44:58","modified_gmt":"2021-07-06T20:44:58","slug":"22-secure-access-to-virtual-networks","status":"publish","type":"post","link":"https:\/\/www.spktechfit.com\/?p=680","title":{"rendered":"22. Secure Access to Virtual Networks"},"content":{"rendered":"<p style=\"margin: 0in; font-family: Calibri; font-size: 10.0pt; color: #767676;\">\n<h1 style=\"margin: 0in; font-family: Calibri; font-size: 16.0pt; color: #1e4e79;\">NSGs (Network Security Groups)<\/h1>\n<p style=\"margin: 0in;\"><span style=\"font-style: italic; font-family: Calibri; font-size: 11.0pt;\">&#8220;You can use an Azure network security group to filter network traffic to and from Azure resources in an Azure virtual network. A network security group contains\u00a0<\/span><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/virtual-network\/network-security-groups-overview#security-rules\"><span style=\"font-style: italic; font-family: 'Segoe UI'; font-size: 12.0pt; background: white;\">security rules<\/span><\/a><span style=\"font-style: italic; font-family: Calibri; font-size: 11.0pt;\">\u00a0that allow or deny inbound network traffic to, or outbound network traffic from, several types of Azure resources. For each rule, you can specify source and destination, port, and protocol.&#8221;<\/span><\/p>\n<p><cite style=\"margin: 0in; font-family: Calibri; font-size: 9.0pt; color: #595959;\">From &lt;<a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/virtual-network\/network-security-groups-overview\">https:\/\/docs.microsoft.com\/en-us\/azure\/virtual-network\/network-security-groups-overview<\/a>&gt; <\/cite><\/p>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">The NSG can be attached to a subnet or a device network interface.<\/p>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">Azure creates a number of default security rules in a NSG when you create a device. They are:<\/p>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">Inbound rules<\/p>\n<ol style=\"margin-left: .375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\" type=\"1\">\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\" value=\"1\"><span style=\"font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\">Allow inbound traffic from devices in the same virtual network<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Allow incoming traffic from a load balancer<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">All other traffic inbound gets denied<\/span><\/li>\n<\/ol>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">Outbound rules<\/p>\n<ol style=\"margin-left: .375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\" type=\"1\">\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\" value=\"1\"><span style=\"font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\">Allow outbound traffic to any devices on the same VNet<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Allow outbound traffic to the internet<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Deny everything else <\/span><span style=\"font-style: italic; font-family: Calibri; font-size: 11.0pt;\">(what else is there if the internet is allowed\u2026)<\/span><\/li>\n<\/ol>\n<p style=\"margin: 0in; margin-left: .375in; font-family: Calibri; font-size: 11.0pt;\">\n<h2 style=\"margin: 0in; font-family: Calibri; font-size: 14.0pt; color: #2e75b5;\">Adding a rule<\/h2>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">In this example we will allow RDP traffic from any devices<\/p>\n<ol style=\"margin-left: .375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\" type=\"1\">\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\" value=\"1\"><span style=\"font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\">Go the NSG -&gt; Inbound security rules<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Click on Add<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Source: any (just for the test)<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Source port range: *<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Destination: any<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Destination port: 3389<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Protocol: TCP<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Action: Allow<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Priority: this needs to higher (lower number) than the deny rule. EG: 1000<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Click Add<\/span><\/li>\n<\/ol>\n<p style=\"margin: 0in; margin-left: .375in; font-family: Calibri; font-size: 11.0pt;\">\n<p style=\"margin: 0in; margin-left: .375in; font-family: Calibri; font-size: 11.0pt;\">\n<h1 style=\"margin: 0in; font-family: Calibri; font-size: 16.0pt; color: #1e4e79;\">Implement Effective NSG Rules<\/h1>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">Azure automatically creates an NSG every time you create a VM. But if you had 100 VM&#8217;s you probably don\u2019t want to manage 100 NSG&#8217;s (not only is this annoying but it would be a security risk).<\/p>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">You want to have NSG&#8217;s with specific roles. EG:<\/p>\n<ul style=\"margin-left: .375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in;\" type=\"disc\">\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">If you have a number of front end web servers, you would have an NSG for them with HTTPS access<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Backend servers may need certain ports allowed for database access etc\u2026<\/span><\/li>\n<\/ul>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<h2 style=\"margin: 0in; font-family: Calibri; font-size: 14.0pt; color: #2e75b5;\">Associating a VM with an NSG<\/h2>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">You associate the network interface of the VM with the NSG. To do this:<\/p>\n<ol style=\"margin-left: .375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\" type=\"1\">\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\" value=\"1\"><span style=\"font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\">Go to the VM network interface<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Go to &#8220;Network Security Group&#8221;<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Click Edit<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Select the preferred NSG<\/span><\/li>\n<\/ol>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\"><span style=\"font-weight: bold;\">NOTE: once you have associated the VM with the &#8220;role&#8221; NSG, you can then delete the NSG that was created with the VM. This is the best practice.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>NSGs (Network Security Groups) &#8220;You can use an Azure network security group to filter network traffic to and from Azure resources in an Azure virtual network. A network security group contains\u00a0security rules\u00a0that allow or deny inbound network traffic to, or outbound network traffic from, several types of Azure resources. For each rule, you can specify [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[13,3],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/680"}],"collection":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=680"}],"version-history":[{"count":1,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/680\/revisions"}],"predecessor-version":[{"id":681,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/680\/revisions\/681"}],"wp:attachment":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}