Azure Bastion and Private Link in the same Virtual Network: Access to Virtual Machine via Bastion fails - azure-virtual-machine

I have a setup in Azure with a Virtual Network that includes Azure Bastion, Azure Virtual Machine and Private Links (among others with a private DNS Zone "privatelink.azure.com") to different Azure resources. I started with Bastion and the VM what worked well. But as soon as I add the Private Links to the same VNET I get an error when trying to access the VM via Bastion:
APP.DIALOG_HEADER_CONNECTION_ERROR
What can I do to resolve that and to be able to access the VM again?

The problem is that whenever a private network link with a private DNS Zone "privatelink.azure.com" is attached to the Bastion Virtual Network, the access to the VM via Bastion fails with the exception mentioned above.
To be able to have Bastion and Private Links using a Private DNS Zone "privatelink.azure.com" in same VNET create a record in your "privatelink.azure.com" zone with
Name = management.privatelink.azure.com
Type = CNAME
Alias = arm-frontdoor-prod.trafficmanager.net

This error message can appear also without having a private link.
I had the same error and the problem was that the NSG was missing from the server. As there was no connectivity for incoming 3389 (RDP port) then the bastion could not enstablish a session. For everyone that may encounter the same issue, make sure that you allow incoming network traffic for the server on which you want to enable bastion service.

Related

Can't access the EC2 instance remotely

I'm trying to connect my friend's MySQL database remotely but I'm getting connection timeout error. I tried to ssh. But same result.
Then I check that instance. It has public IP. Also allowed 3306 and 22 ports on the security group. Allowed 100th rule for all sources in subnet NACL.
What I'm missing? Is there any other way to block those traffic? Can anyone help me? I'm a still beginner
When an SSH connection times-out, it is normally an indication that network traffic is not getting to the Amazon EC2 instance.
Things to check:
The instance is running Linux
The instance is launched in a public subnet, which is defined as having a Route Table entry to points to an Internet Gateway
The instance has a public IP address, which you are using for the connection
The Network Access Control Lists (NACLs) are set to their default "Allow All" values
A Security Group associated with the instance that permits inbound access on port 22 (SSH) either from your IP address, or from the Internet (0.0.0.0/0)
Your corporate network permits an outbound SSH connection (try alternate networks, eg home vs work vs tethered to your phone)
See also: Troubleshooting connecting to your instance - Amazon Elastic Compute Cloud
Based on your descriptions, I would suggest checking whether the instance was launched in a public subnet.
I found the reason. That instance was deployed in a private subnet and didn't have inbound access.
Solution:-
I deployed a bastion host in a public subnet and used SSH agent forwarding to access the instance through the bastion host.

JDBC connection to mySQL RDS instance in a private subnet

We are trying to find out ways to make a JDBC connection to a SQL Server hosted in a private EC2 instance or a private subnet.
Basically, we have an Excel-based small BI report that connects to an On-Prem SQL server and we want to move that DB to cloud and just switch the end points.
There is a lot of information out there about SSH connections to a private subnet RDS SQL server through bastion hosts etc, but I have not found anything related to direct connection.
Due to the infra set up, VPN and direct connect is not possible to use and the users will be directly connecting to private RDS instance over a public internet.
I have not found anything related to direct connection.
Without VPN or Direct Connect, direct connection is not possible. Your RDS is in private subnet, as there is no direct internet connectivity to it - thus the name "private".
If you don't want to use VPN and/or don't have Direct Connect, then the only option is to use ssh tunnel through a bastion host as explained by AWS:
How can I connect to my Amazon RDS DB instance using a bastion host from my Linux/macOS machine?

Connecting to a Cloud SQL instance from VM with public and private IPs - how to ensure the right network interface is chosen for the connection?

What I'm trying to set up:
Cloud SQL instance with private IP, Postgresql database
A VM with a public IP, but also one private IP on same VPC network as the SQL instance is on (VM, SQL instance and VPC are all in the same region)
VM has a service account with sufficient Cloud SQL client/viewer permissions
Possibility to connect from VM to SQL instance.
What happens?
Any attempt to actually use the connection, from for example psql client or db-migrate, simply hangs - for example psql --host 10.78.0.3 -U gcp-network-issue-demo-staging-db-user gcp-network-issue-demo-staging-database will not prompt for a password, just sit there.
If I remove the VM's public IP address from the setup, it connects fine. However, I need a publicly accessible VM for other services to connect to it..
I assume the psql connection attempt goes through the wrong network interface or something (this may be just my ignorance about network stuff speaking) - how can I get this working? What am I missing?
PS: this is basically same problem as Connecting to Google Cloud SQL instance on private IP from a VM with both private and public IPs fails but commenters there seem to want one Terraform-related and one connection-issue-related question.
Some screenshots:
VM IPs:
DB IPs:
Network config for VM:
Private IP config for DB instance:
This is the setup of the private network:
I don't understand why the private IP of the DB instance (10.78.0.3) is not an IP from the range of the private network (10.2.0.0-10.2.0.24, right?)..? Is that my problem?
To answer your question:
I don't understand why the private IP of the DB instance (10.78.0.3) is not an IP from the range of the private network (10.2.0.0-10.2.0.24, right?)..?
The Cloud SQL instance is assigned an IP address from the allocated range. When you setup a private services access a VPC peering is created between your VPC gcp-network-issue-demo-staging-network and the service producer VPC network that uses the allocated range 10.78.0.0/16
Also, looking at your VM network config, I see that the VM has two Nics in two different VPCs (default and gcp-network-issue-demo-staging-network). In your case, you can use only one Nic.
As a next step, make sure that your VM is using only the VPC network that you have used to create the private connection. Once that done you should be able to connect to the Cloud SQL instance IP using the command bellow:
telnet 10.78.0.3 3306

Connect to a web application in private through bastion host for my local machine in aws

I have an EC2 instance running in AWS and here's the scenario I'm trying to achieve. I have a VPC setup with 3 subnets. 2 of them are private with no access to the internet (even using a NAT gateway/NAT instance), and another is a public subnet.
Bastion Host configured with Public IP (55.55.55.55 for example) in the public subnet.
I have ec2 instance launched in a private subnet that hosts my application, and I want my users to be able to access the application from their workstation browsers.
If I set up the SSH connection as discussed here, it works perfectly fine for the web browser page set up on my bastion host. However, for my use case, I need to achieve another level of SSH forward like above as my application is in the private subnet for that application to be accessible from my local machine. Is that possible somehow? I also need to make sure there are no issues with the DNS.
ssh -N <Bastion_IP/HostName> -L<LocalPort>:<Internal_IP_of_Web_Server>:<WebServer_Port>
Then you can access the webserver http://localhost:<LocalPort>/
Assuming you have a web application on ec2 in a private subnet and you want to make it available for access outside AWS.
You can setup port forwarding on your bastion host following this tutorial, but I suggest you use a load balancer (ELB) as described in this guide. To use an ELB you will need another public subnet in a different AZ. If you're application is serving HTTP traffic, then it's even better to use a Application ELB (ALB). Here is more info about ALB.

Access Database Server hosted in AWS private subnet

I have gone through AWS VPC(Virtual Private Cloud) where I can have public, Private and VPN-only Subnets.
With this, I want to host a Database in Private or VPN-only subnet.
Now that, Private and VPN-only subnet can not have Internet traffic, I wonder if I can access my database server from remote machine (not an EC2 instance nut any random machine on internet) ?
So All I want to know that, how I can access my Database server from random machine using VPN connection ? So the only users those have VPN connections can access the database server. I want this for development purpose.
Any comments links will be helpful.
Note: I am aware that I can do this with VPN EC2 instance, but I don want to have one and directly connect to Database server from remote machine which has VPN connection.
Thanks
When you create a private VPC, all of the subnets you create within it have internal network access to each other by default in their route tables. However you would need to configure a NAT or Bastion instance within the VPC that is public to act as the gateway to the private database.
The private database would need to have an appropriate security group attached to it to allow it to be accessed by the public machine. See about VPCs and Security Groups here.