Expose Mosquitto MQTT running in Azure ARO via Azure Firewall - azure

We are facing an issue with exposing Mosquitto MQTT running on private Azure Redhat Openshift to internet over TLS using Azure firewall . I think this will be relevant for any private openshift cluster running mosquitto. To access MQTT server the client needs to access it using hostname assigned to the Openshift passthrough router since it is using TLS as mentioned in this document
https://developers.redhat.com/blog/2021/04/26/deploying-the-mosquitto-mqtt-message-broker-on-red-hat-openshift-part-2
We have successfully tested access to the MQTT service from a VM running on the same VNet as ARO using mosquitto_pub/sub client. The command is as below where the –host is very important as it allows Openshift passthrough router to determine the pod which hosts the service
$ mosquitto_pub -t foo -m "text" --cafile mosquitto_ca.crt
--insecure -u admin -P admin --host mosquitto.apps.my_domain --port 443
When we try to expose the service using Azure firewall, we are using DNAT rules to allow access from public internet. But DNAT rules don’t allow FQDN in the destination address. So we are forced to use the load balancer address of the cluster as the destination address. But this results is TLS error as SNI is not working using IP address. To enable SNI we somehow need to redirect using the hostname.
Would anyone have idea on how to expose such passthrough routes via Azure Firewall? Is there any way Azure firewall could support FQDNs for target address for inbound traffic? We could as an alternative use App Gateway with Websocket protocol - but since this is non http traffic we wanted to use Azure firewall and also for its enhanced traffic control ability over app gateway.
Any help much appreciated.

Related

Azure VM Port for Localhost

So I'm using an Azure VM that has a public IP address, and I've opened an inbound port, let's say it's 5555.
What I'm trying to do now is to run an application on the VM that has an API via localhost, also with the port 5555. I'm calling it then with public_ip:5555/api/...
Since I was not able to connect to the application from outside, is there something missing here? Most tutorials and resources I've found just mentioned opening the port.
Thanks.
Take a look at Azure's IP Flow Verify utility, which will check your NSG rules to ensure traffic can reach your VM. https://learn.microsoft.com/en-us/azure/network-watcher/network-watcher-ip-flow-verify-overview
If traffic is reaching your VM, check your host firewall and then your application server logs.

Unable to access server hosted on VM via https

I have a server running on ubuntu installed on azure vm. I am able to access the server via http, however when I am trying to connect via https, I am getting error: ERR_CONNECTION_REFUSED
I have added inbound rule to allow port 443, but still I am facing the issue.
To secure the websites on azure VM, you need to inject the SSL certificate into the VM and configure your web server with a TLS binding. Read this Tutorial: Secure a web server on a Linux virtual machine in Azure with TLS/SSL certificates stored in Key Vault. Also, you need ensure the port 443 is allowed in the inbound firewall of Azure VM.
When you have done it, you can check if the port 443 is listening on the Azure linux VM via netstat -tulpn | grep LISTEN, see How to check if port is in use on Linux or Unix
Let me know if you have any question.

Azure virtual network hybrid connection

I've got an Azure Virtual Network setup and a VM setup within the network. I've installed the Hybrid Connection Manager app on the VM.
I also have an Azure App Service and I've created a hybrid connection between it and the VM and they are both claiming they are happily connected to each other.
Also on the VM I've installed an app that is listening on http://localhost:1234
Can someone tell me what IP I use from my app service to talk to http://localhost:1234 on the VM? e.g. Is it [VM internal IP]:1234 or [VM public IP]:1234, or something else. Nothing is talking at the moment so I want to make sure the IP address is not the problem.
Just use the computer name of the VM. For example, call to SQLSRV009:1234 from your code in App Service. The Hybrid Connection definition in the portal should reflect the same name (same as computer name, same as what you're calling from your code).
Check out this well written guide for the full picture —
https://learn.microsoft.com/en-us/azure/biztalk-services/integration-hybrid-connection-create-manage
It is possible to set a Hybrid Connection endpoint to an IP address. If you use an IP address, you may or may not reach the on-premises resource, depending on your client.
The Hybrid Connection depends on the client doing a DNS lookup. In most cases, the client is your application code. If the client does not perform a DNS lookup, (it does not try to resolve the IP address as if it were a domain name (x.x.x.x)), then traffic is not sent through the Hybrid Connection.
For example (pseudocode), you define 10.4.5.6 as your on-premises host:
The following scenario works:
Application code -> GetHostByName("10.4.5.6") -> Resolves to 127.0.0.3 -> Connect("127.0.0.3") -> Hybrid Connection -> on-prem host
The following scenario doesn't work:
Application code -> Connect("10.4.5.6") -> ?? -> No route to host
Also make your app listen on either 0.0.0.0 or the private IP since i'm not terribly sure localhost will work with HC.
Why not use VNET integration for the Web App? All you need to do is create a route based (IKEv2) VPN gateway in the VNET, like so —
https://learn.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet
You should use VM host name, thanks for evilSnobu's link .
If you use an IP address, you may or may not reach the on-premises
resource, depending on your client.
If you use VM public IP, traffic packets are transmitted over the Internet to your VM not VPN tunnel. localhost only could be used inside VM.
Also, if your app is listening on localhost(127.0.0.1), the service only could access inside your VM. As evilSnobu said, you need modify your service listening on 0.0.0.0 or private IP(like 10.0.0.4). You could check with following command.
For Linux
netstat -ant|grep 1234
For Windows
netstat -ant|findstr 1234

How can I add support for IPv6 to and Azure application Gateway knowing that it does not support it

I am not a system administrator or network administrator thus I having hard time trying to figure it out a work around to support IPv6 on an Azure Service Fabric Cluster without using the Load Balancer.
From here: IPv6 support for Azure other than the load balancer thing
I have checked that IPv6 is only supported by that lb appliances but the entry point of my current cluster is an application gateway.
Is there a recommended work around for adding Ipv6 support for using a Azure App Gateway
Is there a recommended work around for adding Ipv6 support for using a Azure App Gateway
There is no nice way to do that, only work-arounds.
Anyway, you can do the following:
instanciate an Azure back-end server,
configure this server to establish an IPv6 over IPv4 tunnel to an IPv6 public tunnel broker,
install a reverse-proxy on your back-end server, listening to an IP address chosen inside the IPv6 prefix offered by your tunnel broker,
configure this reverse-proxy to translate the accepted IPv6 https connections into outgoing http or https IPv4 requests to your Azure app gateway (the connection stays inside the Azure network, so you may accept not to encrypt it, using http instead of https).
But this will not be very efficient because:
1- this is your back-end server that will terminate and decrypt ssl connections;
2- IPv6 packets from/to your servers in Azure will go through your tunnel broker and Azure, you will not have direct connections between the clients and Azure.
To find a free IPv6 tunnel broker, see for instance Hurricane Electric.

Connection to azure virtual machine public port is timed out

I am using Azure Virtual Machine (Windows Server 2008 R2 image) provided from the gallery and created Public port and private port using the portal. I did remote log in to VM and I run a TCP server application inside VM (TCP server binds to the private port of the VM). Problem I face is that I can not connect it through the public IP and port (from external machine). I have created a inbound rule in VM's Firewall, where I enable connection to the Private port of VM. I tried recreating the VM, also the new ports. Still problem persists. One more thing I observed is that my TCP Client is able to connect to RemoteDesktop port of the VM also the PowerShell port. But does not connect to the port that I created through the portal. Pls suggest what can be wrong?
Note: I also observed some weird behavior. I enabled all ports for my TCP Server app in Inbound rule of firewall and found that some unknown IP (was similar to azure internal IP) is connecting to my server. Why it is happening?
I would like to understand as to how you are trying to connect with the Virtual Machine, using RDP or trying to test the connectivity, for example, using Port Ping.
Endpoints for RDP and Powershell are configured by default. So if you are trying to connect using Remote Desktop, you can directly connect to the VM using MSTSC from Run and provide the IP of the VM followed by the Port Number using the below format
xx.xx.xx.xx:3389
However if you would like to test the connectivity to the VM, I suggest you to use Port Ping instead of ICMP ping since ICMP traffic is blocked by the Azure load balancer and the ping requests timeout. While Ping.exe uses ICMP, other tools such as PsPing, Nmap, or Telnet allow you to test connectivity to a specific TCP port.
On the other hand, after creating the VM, you can add endpoints additionally as needed. You can also manage incoming traffic to the public port by configuring rules for the Network Access Control List (ACL) of the endpoint.
The private port is used internally by the virtual machine to listen for traffic on that endpoint.
The public port is used by the Azure load balancer to communicate with the virtual machine from
external resources. After you create an endpoint, you can use the network access control list
(ACL) to define rules that help isolate and control the incoming traffic on the public port. For
more information, see About Network Access Control Lists.

Resources