Connect to Azure SQL Server from computer with dynamic external IP - azure

I am trying to connect an on-premises laptop with dynamic external IP to our Azure SQL Server. To do this, I created a virtual network gateway and connected the laptop to the gateway. Also, I added a private endpoint to the SQL server. After this, I can successfully connect to the SQL server IP using telnet, and if I resolve the SQL server FQDS in hosts file, I can connect to the server via SSMS. But without hosts file, the laptop always tries to connect to the SQL server via its public endpoint/address.
I found the following article: https://techcommunity.microsoft.com/t5/azure-database-support-blog/azure-sql-db-private-link-private-endpoint-connectivity/ba-p/1235573 The article is great. It recommends using your own DNS server to resolve the SQL server FQDN to the local IP. Unfortunately, the laptop does not have access to any custom DNS, so this solution does not suit.
There are two questions:
Is there any possibility to establish connection between an on-premises computer with dynamic IP and an Azure SQL server using a private endpoint but without own DNS server?
If the answer to the first question is "No", is there another way to connect an on-premises computer with dynamic IP to an Azure SQL server using any other Azure application(s)?

First of all, you can not use FQDN without DNS service. So you indeed need a custom DNS server in using FQDN of the server in connection strings for your clients to connect from on-premise VM to the Azure SQL server.
Since you are using a laptop, the DNS servers used by your computer are most likely specified by your ISP. You have no more control over it or ask your ISP to configure the DNS forwarder. Otherwise, you need to deploy a DNS server in your internal network. Currently, in this scenario, the best method is to use the HOSTS file on the local machine to override the Public DNS.
However, if you don't like using the HOSTS file, you can provision an Azure VM as the DNS server in the same Azure virtual network as the virtual network gateway.
Main steps:
Deploy an Azure VM, and RDP to that VM and run the PowerShell commands to install the DNS server role.
Install-WindowsFeature -Name DNS -IncludeManagementTools
Get-WindowsFeature *DNS*
Add Azure DNS (168.63.129.16) as a forwarder on your custom DNS server according to the step 5 in this blog. If you do not want to use forwarder you can also create a forward lookup zone and added manually the host to match the FQDN. You could read On-premises workloads using a DNS forwarder for more details.
After you have configured the DNS server and set the DNS forwarder. You could change the DNS server of Azure VNet to your Azure VM's private IP address.
Restart your Azure VM and re-download the VPN client package and re-connect the VPN connection to make the networking update. Check the DNS server on the local VPN client machine and set the DNS server to the custom DNS server in the TCP/IP settings. Then you will look up your private IP address via the default FQDN of Azure service.
In my example, I am using Azure storage account but it works the same with Azure
SQL database when using a private endpoint on the Azure and P2S VPN connection.
In this way, it requires that there are not any other VPN connections except the
P2S VPN connection on the local machine.
Then you could resolve the Azure SQL server FQDN to the private IP address of the private endpoint. However, it perhaps does not have a better performance to connect to Azure SQL Server with a VPN connection than directly connect to it through the public Internet and public DNS sevice.

Related

SSMS IP address changes after disconnecting from Azure SQL server

We are connecting to Azure SQL server for our work through SSMS. We are whitelisting all the developers IP in Networking section of Azure SQL Server. Whenever we close SSMS connection all the time SSMS IP get changes. Then we need to go and update the new IP in Azure portal. Why SSMS changes the IP all the time. Any solution for this in SSMS settings.
Your ISP is properly providing you a dynamic IP. You can check your egress IP with a lot of online IP discover services. If it changes overnight/day e.g. https://wtfismyip.com/
To avoid dealing with IP Whitelists you could use a VPN Gateway or Express Route to tunnle your Devs to an Azure VNET and connect the Azure SQL DB with private Link into that VNET.
Alternatively, you could use a Bastion host to run SSMS there.
But in the End, there is nothing which you or Microsoft can do on Azure Side to prevent your client IP from changing when your ISP doesn't provide you a static IP.
Of course, you can ask them to upgrade your internet to a static IP address, or do you use multiple egress IPs in your company? In this case maybe speak with your network admin to get all egress IPs and whitelist those.

Access Azure Private Endpoint Using Azure VPN

I am trying to access resources that are secured behind private endpoint from a remote location using an Azure VPN Point-to-Site connection.
So far I have setup a conditional forwarder to send DNS requests to Azure's internal DNS IP address (168.63.129.16). With my setup I can resolve all my private endpoints using nslookup to their private IP addresses. I can also connect to services such as SQL server from my local machine (using SQL Server Management Studio in the case of SQL server).
The problem I am facing is that I can only access resources if I use a desktop client for a given service. If I try to do anything using the Azure Portal, I get an error stating that I cannot access resources using my Public IP address without adding it as an inbound IP address. Whilst this is certainly an option, I don't want to go down this road.
I am hoping there is an option where I can connect to private endpoint resources from Azure Portal whilst connected to my point-to-site VPN. Any ideas?
So far I have setup a conditional forwarder to send DNS requests toAzure's internal DNS IP address (168.63.129.16). With my setup I can resolve all my private endpoints using nslookup to their private IP addresses. I can also connect to services such as SQL server from my local machine (using SQL Server Management Studio in the case of SQL server.
AfAIK, the process which you are doing is correct, To fix this issue try to update the local host file on client desktop to deploy a recourse with private endpoint please refer this link for more in detail
By default when you create a Private Endpoint in the Azure Portal it will automatically lock out public access. Service Endpoints operate by adding routes to allow traffic out of the virtual network to reach the public endpoint of the service selected. If you are access resources error, update firewall rules to communicate with your Azure resources you really need to configure v-net traffic on the firewall settings
Next option is conditional forwarder, in your scenario the ble from every v-net, its public ip it won't overlap with any private ips, it available from inside of azure v-net unique to each
In conditional for forwarder, client asks the ip of a host like www.seraltos.com .The dns server looks to see the answer if knows, if not a lookup will done based on root servers or forwarder to find the ip address returns that to the client
For more information in detail, please refer below links:
Private Endpoints and DNS in Azure & Cannot access my own public IP
https://learn.microsoft.com/en-us/azure/storage/common/storage-private-endpoints
https://learn.microsoft.com/en-us/azure/private-link/manage-private-endpoint?tabs=manage-private-link-powershell

How to connect to an Azure SQL Server using the PrivateLink IP

I have an Azure logical SQL server to which I added a Private Link, the NIC is attached to an existing vnet\subnet. Our company's VPN is linked to that vnet and I can see other devices on the private link's subnet but not the SQL Server.
The SQL Server is reachable on the public URL (temporarily for testing) but trying to ping or tracert the server with the private IP fails, I can ping and tracert to other VMs on the same subnet.
I'm not using a custom DNS zone because it's imperative that we configure it with the IP and I haven't made any changes to our company DNS (I'm expecting not to have to).
Other than creating the private link and attaching it to the SQL Server, what else needs to be done? What am I missing?
I'am working on the same Issue. It's still not solved yet but there are some steps you need to do.
For the Connectivity it's required to add a DNS, especially if you want to connect from the On-Prem. Azure has a default DNS-Solution for Azure-Resources. The Problem is: From On-Prem you can't access the default Azure-DNS-Service.
So you have to configure a DNS-Zone (in Azure or On-Prem).

Unable to connect to Azure SQL through Virtual Network Gateway

I have SQL Azure Database Server (not managed instance). When setup last year, I added Azure Virtual Network Gateway, and I could access the database via the VPN connection, without whitelisting the IP.
We didn't use this connection via gateway since Jan 2020. There was only couple of developers connection but had their IP whitelisted.
Recently, we tried accessing the database using this connection, and it doesn't work. Prompting to whitelist the IP. Has something changed?
It seems that you just enable Azure virtual network service endpoints for your Azure SQL database server (not managed instance) and add this subnet to your SQL network rules. With service endpoint, the traffics go over the Internet but restrict over the network. Service endpoints and Private endpoints are two different things.
To connect to your Azure SQL database via a VPN connection, you could use a private link. Private Link allows you to connect to various PaaS services in Azure via a private endpoint. You could get the detailed steps from https://learn.microsoft.com/en-us/azure/azure-sql/database/private-endpoint-overview
Alternatively, you could try to use a TCP proxy server to forward traffic to the public IP address for SQL Database. Reference: https://argonsys.com/microsoft-cloud/library/using-a-tcp-proxy-to-connect-to-sql-database-over-vpn/

How to connect to Azure pass DB from a secure network

I would like to connect to Azure SQL server from a Window server via SSMS. In the “set server firewall” from Azure, I have given my server IP ( from the system I would like to connect). I need to know the destination IP adders of the Azure DB Server. From Azure portal the location is showing central US . To allow firewall I need to know the destination IP address.
My questions are:
1. As Central US could have multiple IP addresses, do I need to provide all IPs to my Firewall team?
2. How can I know the destination IP address ( i.e. Azure) so that I can provide that to my firewall team?
Note: From SQL server management studio, the tcp default port for SQL is enabled and services are running fine.
Hope I have explained it correctly.Thanks
No. You cannot get a static IP address assignment for your Azure SQL Database. Moreover, what you refer (mysqlserverdatabase.mysql.database.azure.com designates your Azure SQL Database Server, not a single Database. This is a logical server, in which you can put up to 149 Databases (150 with the Master DB).
You have to workaround your requirement for static IP address assingment to work with the DNS Name (mysqlserverdatabase.mysql.database.azure.com).
Otherwise if your company firewall can't work with the DNS Name ,you need to set the server connection policy to Proxy as documented in Azure SQL Connectivity Architecture. This allows the database gateway to proxy all traffic between the client and the DB server. The gateways all have static IP addresses, which are listed in the above document.
If you have setup a VNet in Azure, checkout VNet Service Endpoints to connect Azure SQL.
https://azure.microsoft.com/en-in/blog/vnet-service-endpoints-for-azure-sql-database-now-generally-available/

Resources