Azure traffic direction explanation - azure

I am really not clear what outbound(egress) and inbound(ingress) traffic means. I have two theories
inbound just specifies that the origin is outside and target inside i.e. HTTP round trip to some VM hosted web is ingress, the response with HTTP 200 status goes the same established route back
inbound is anything from internet and outbound is anything to internet. So HTTP roundtrip to azure VM is ingress and also egress (HTTP response), both of which can have different route(in case of asymmetric routing.
My question is if the VM does not have route back to internet, will it serve properly the HTTP or the response cannot reach the originator in internet?

Inbound traffic originates from outside the network, while outbound
traffic originates inside the network.
My question is if the VM does not have route back to internet, will it serve properly the HTTP or the response cannot reach the originator in internet?
Assuming you have a web server running on it, you just need to configure on firewall rules to enable inbound / outbound traffic for port 80 and 443

Related

Block port 80 access in Azure Front door

I created a Standard tier Front Door with the necessary Azure WAF with default configurations. If I do this:
Test-NetConnection -ComputerName "<frontdoorurl>-dev-xxxxxx.z01.azurefd.net" -Port 80
ComputerName : <frontdoorurl>-dev-xxxxxx.z01.azurefd.net
RemoteAddress : xxxx:xxx:xx:x::xx
RemotePort : 80
InterfaceAlias : Ethernet 7
SourceAddress : xxxx:xxxx:xx:xxx:xxxx:xxxx:xxx:xxxx
TcpTestSucceeded : True
I am unable to block this permanently - I tried having a rule set on the Server port equal to 80 conditions but there is no suitable action for this that blocks the port 80 access throughout.
How to block this permanently so that the result of Test-NetConnection is False? or is there no way to block the access to port 80 from outside?
P.S. I have tried asking ChatGPT - it tells me to use Network Security Group and block port 80. But in the latest Azure Portal setting for Front Door - no such provision is made.
Azure Front Door will allow https requests by default, but you can restrict the http request for each end point using Routing Rules.
NOTE: With the front door URL, Test-NetConnection will not return a false result because FD will try to fetch the service responses frequently and, if they are not reachable, will send a message such as "Services are down."
Here is the way to restrict port 80 from Front Door.
Step1:
Create front door application with 2 backend pools and Configure routing rule as follows.
Step2:
update route rule with https & https request allows both allow
Verificaiton:
when browse the URL it will allow both http and https calls
Step3:
Now, in order to restrict the http [80] port in the backend, update the routing rule to https only.
Step4:
Save the Front Door settings
Step5:
now https [443] port only allow to access the application and 80 port it won't allow via front door URL.
Note:
We need to restrict port 80 from both the application endpoint side and the server side. Otherwise, when we ping from Test-NetConnection, it will return a true value. Because Front Door will give the response that the site is not reachable
Backend Pool like this
becuase of this configure
Azure Front Door consists of a a distributed network of POPs (Points-of-Presence) and these are listening for both port 80 and 443 on an Anycast IP, meaning you'll just get routed to whatever POP is closest to you. Your AFD endpoint will resolve to one of these Anycast IP's. You cannot block port 80 because these POPs handle more than just your site. There are numerous other customers that have sites hosted on these POPs and some are accepting HTTP, so port 80 is open. It's also needed for HTTP to HTTPS redirection. With respect to a TCP connection, the domain name is irrelevant as we aren't at the HTTP layer yet.
You can always redirect traffic from HTTP to HTTPS but these POPs are not in your control, unlike something like Application Gateway. With App Gateway, you can listen for whatever ports you want because it's not shared with other customers.

Azure Load Balancer Get Originating Client IP

I am using the Azure Standard Load Balancer (client -> external lb => firewall => internal lb => server), when my api request gets to the server I need to be able to identify the originating clients ip address.
I have tried to use X-Forwarded-By and some other request headers but it looks like they're either not supported or have been stripped.
I have not been able to find any documentation online pertaining to the issue - does anyone know how I can access the client ip address?
Thanks
It sounds like you are using the LB for a HTTP backend. Thus, its important to understand what LB does - and what not. There are many good articles out there if you search of "azure load balancer vs application gateway". Here is one example which sums it up well:
The Load Balancer is a TCP/UDP load balancing and port forwarding
engine only. It does not terminate, respond, or otherwise interact
with the traffic. It simply routes traffic based on source IP address
and port, to a destination IP address and port.
Thus, it does not add anything to your HTTP headers etc.
So, LB is more like a router than a proxy. If you want the latter, I suggest you look at Azure Application Gateway. This, btw, can include Web Application Firewall. So you might be able to reduce three components into one.

Azure VM RDP outbound NSG rule

I want to secure my web server vm to limit mainly to 443 and 3389 ports strictly. I denied everything else both outbound and inbound in the NSG for the web vm. But I can't rdp after doing so. When I relax the NSG to allow all outbound, then rdp starts working. My question is what outbound ports and protocols the rdp service needs to be opened in nsg beside 3389?
thesushil: In my case it turns out, I just needed to add an outbound rule to allow Azure AD communication over http and https, because I have azure AD authentication enabled. But I think the answer below would be helpful to others.
Be default, the RDP server listens on TCP port 3389 and UDP port 3389. Read wiki. You also could change the listening port for remote desktop.
If you want to secure your Azure VM limit to 443 and 3389 ports, you can add inbound port rules like this to only allow your client-specific IP address to access your Azure VM.
Also, please note that If inbound traffic is allowed over a port, it's not necessary to
specify an outbound security rule to respond to traffic over the port. Read https://learn.microsoft.com/en-us/azure/virtual-network/security-overview#security-rules
Network security group security rules are evaluated by priority using
the 5-tuple information (source, source port, destination, destination
port, and protocol) to allow or deny the traffic. A flow record is
created for existing connections. Communication is allowed or denied
based on the connection state of the flow record. The flow record
allows a network security group to be stateful. If you specify an
outbound security rule to any address over port 80, for example, it's
not necessary to specify an inbound security rule for the response to
the outbound traffic. You only need to specify an inbound security
rule if communication is initiated externally. The opposite is also
true. If inbound traffic is allowed over a port, it's not necessary to
specify an outbound security rule to respond to traffic over the port.
Existing connections may not be interrupted when you remove a security
rule that enabled the flow. Traffic flows are interrupted when
connections are stopped and no traffic is flowing in either direction,
for at least a few minutes.
Hope it helps.

Azure NSG not working as expected

I have an Azure external loadbalancer with a backend pool that contains 1 kubernetes master server and has a load balancing rule on port 443.
I added a rule with priority 500 to deny all traffic coming from the internet on port 443 to the kubernetes master server. Works fine
I added a rule with priority 400 to accept traffic coming from a certain public ip because I only want to be able to connect from that ip. I expected that I should be able to connect but I can't.
If I change the rule that accepts traffic from the source ip to internet then it works fine.
What am I missing?
Kind Regards
"I added a rule with priority 400 to accept traffic coming from a
certain public ip because I only want to be able to connect from that
ip. I expected that I should be able to connect but I can't.
If I change the rule that accepts traffic from the source ip to
internet then it works fine. What am I missing?"
Things that you might have missed:
Make sure you are not specifying the source port !! It would be
taken from a pool of available ports referred to as ephemeral ports
from the client that you initiate the connection.
You are blocking the Allow Azure Load Balancer IP which is a default rule.
Load Balancer health probes originate from the IP address 168.63.129.16 and must not be blocked for probes to mark your instance up. Review probe source IP address for details.
Create a separate rule to allow this IP as this is a MSFT IP you should have no issues allowing this.** Before deny all (Priority <500)
That should fix your issue for sure !!
Diagnosis & RCA:
Why this is happening, the Azure Load balancer Probe IP is being blocked and hence the backend server is being marked as unhealthy by the load balancer.

Open port for outbound and inbound traffic

I want to send push notifications to devices through the Apple push service server (APNS). Now the APNS requires an unproxied connection to them with some ports open.
To quote Apple from this link - Push providers, iOS devices, and Mac computers are often behind firewalls. To send notifications, you will need to allow inbound and outbound TCP packets over port 2195.
Now the security team is asking why we need to open both inbound and outbound when we will only sending (outwards) the request to APNS.
Now I am no networking guy. My basic web brain tells me we will be sending a POST request (outwards as seen from my server) to APNS, and this POST request will have a response. For this response, I will need to open inbound traffic for that same port i.e. 2195. Am i right?
I think your network is using Statefull/ZBF (Zone Based Firewall). for getting the response of a request you need to open both inbound and outbound requests. the firewall for this port should configured on "Inspection" that lets both inbound and outbound traffic.

Resources