How the IP adressess are connected in Azure vnet to vnet connection - azure

I have just started working on Azure Cloud Services and was trying to establish v-net to v-net Connection within the same subscription and a different location.
Vnet name = vnetOne
Address space = 10.1.0.0/16
Resource Group = RG
Location = Australia East
Subnet name = SubnetOne
Address range = 10.1.0.0/24
GatewaySubnet = 10.1.1.0/24
Virtual network gateway name = VnetOneGateway
Gateway type = VPN
VPN type = Route-based
SKU = vpnGw1
Public IPAddress=13.75.198.231
VnetOneGateway=13.75.192.172(13.75.198.231)
Connection(VnetOneGatewayToVnetTwoGateway)=52.232.102.16
Vnet name = VnetTwo
Address space = 10.6.0.0/16
Resource Group = RG
Location = EuropeWest
Subnet name = SubnetTWo
Address range = 10.6.0.0/24
GatewaySubnet = 10.6.1.0/24
Virtual network gateway name = VnetTwoGateway
Gateway type = VPN
VPN type = Route-based
SKU = VpnGw1
Public IP Address=104.40.194.26
VMTwo: 51.145.142.190
VMTWo=13.75.193.47 and 10.1.0.4
VnetTwoGateway=52.232.102.16(40.115.46.34)
Connection (VnetTwoGatewayToVnetOneGateway) =13.75.192.172
Question 1. I created vnet's with defined Address spaces and then created subnet.Inside subnet I have created VM's which has two ip's one is from taken Subnet Address space and other ---is it assigned randomly?
Question 2. What is difference between GatewaySubnet and VirtualNetwork Gateway.Means their use.I have seen lot of videos but no one has explained the logical aspect of it.A diagramtic representation will help a lot to understand this.I have only understanding that Virtual Network gateway creates tunnel for interaction between the vnet's using shared key,then what's the role of gateway Subnet?
Question 3. We have to create the public IP Address and we map it with Virtual Network Gateway.Once the Virtual Network Gateway is created there is IP Address assigned to these gateways
VnetOneGateway=13.75.192.172(13.75.198.231)
VnetTwoGateway=52.232.102.16(40.115.46.34)
which is different from Mapped Public IP Address
Public IPAddress=13.75.198.231(Created for mapping Virtual Network Gateway)
Public IP Address=104.40.194.26.Not able to understand the logic in this scenario.What does the Virtual Network IP Address does and what does the Public Address IP does which is mapped to Virtual Network Gateway?
Question 4. Can I get the diagrammatic representation of all the IP's interacting with each other.May be I am missing something thats why I am not able to get the logical connection in this.
Any shared link will also be a great help.
Thanks in Advance!!

As I see what you want is to get a connection between vnets. So I suggest the Vnet Peering, it's just a simple way to set up.
Question 1: If you have a VM with two IPs, all the IPs will be assigned be the subnet in order, for example, the one is 10.0.0.4 and the other is 10.0.0.5. You can get more details about Virtual Network Peering here.
Question 2: IPs in GatewaySubnet is used to transmit the flow from one network to another as Network Routing does. And the Virtual Network Gateway is a tool that used to create the VPN, also as you say:
Virtual Network gateway creates a tunnel for interaction between the
vnets using a shared key.
Question 3: All the Public IPs are used to connect our logic network to the Internet no matter what they are mapped. The Virtual Network IP Addresses are assigned to the devices, let them have an address in Vnet. And the Public Address IP which is mapped to Virtual Network Gateway just makes the Virtual Network Gateway can connect the Internet.
You can get more details about Public IPs here.
Question 4: This question is too difficult to list particularly, you can get what you want from the link here.

Related

Azure NSG Private IP Congfiguration (WhiteList)Vnet to Vnet communication

I have situation where I want to open my Vnet(lets say Vnet1) for other Vnets (which has private IP range defined ) , I am thinking to use NSG rules and allow private IP ranges of other Vnets (lets say Vnet2 , Vnet3) to this entry point Subnet(in Vnet1) which host my API gateway .
I have two questions :
I assume it should be feasible using private IP addresses and allowing them using NSG (of Vnet 1/Subnet 1) ? I am not looking for peering/s2s vpn of Vnet as both belongs to separate teams and Vnet2/Vnet3 just wanted to access APis of Vnet1 using Api gateway.
Is there any security issues which we foresee , I assume it safe to expose since these are private IPs and can not be accesses from internet .
Please let me know opinion on feasibility and security .
Thanks
Xslguy
To help others who might find the same scenario, just extract the useful information in the comment and write my answer.
An Azure VNet is a logical isolation of Azure cloud dedication to your subscription. VNet peering allows traffic between two VNets is routed through Microsoft's private network only. If the VNETs haven't peered, vnet1 will not connect to resources in vnet2 by using private IP but using the public IP of the resources in vnet2. In this case, we need to restrict the source public IP for the inbound rules in the NSG attached to the subnet. With VNet peering, you also could restrict the access from one subnet to another subnet by using source private IP for the inbound rules in the NSG attached to the subnet.
From Security rules:
If you specify an address for an Azure resource, specify the private
IP address assigned to the resource. Network security groups are
processed after Azure translates a public IP address to a private IP
address for inbound traffic, and before Azure translates a private IP
address to a public IP address for outbound traffic.

Azure Gateway VPN IP different from actual Public IP

I have a Virtual Network Gateway setup on my Azure subscription, and a number of VMs which connect to it.
The VN Gateway created a Public IP automatically, and has it listed in the 'Overview' screen.
However going onto any website to check my IP (e.g. whatsmyip.org) gives me an entirely different Public IP. Anyone know why this is?
My configuration of the Virtual Network Gateway is very basic with mostly defaults and the VpnGw1 SKU.
The public IP assigned to the virtual network gateway is a public IP to let you connect Azure VPN gateway from your on-premises network or the Internet.
However, by default, there is a default route to make that Azure VM can continue to accept and respond to requests from the Internet directly. If VM has been assigned a public IP address to the NIC, the outbound traffic from VM will use this IP address. If the VM does not have a public IP address, Azure translates the private source IP address of the outbound flow to a public source IP address. This public IP address is not configurable, cannot be reserved, and does not count against the subscription's public IP resource limit. Read Outbound connections scenario overview.
So the outbound public IP of Azure VM is different than the virtual network gateway public IP.

Azure VNET peering v/s NSG exception

I am new to azure and trying to understand the concept behind VNet peering
I Have two VM First in East US and another in East Asia
By the design of AZURE, i should not be able to access any data between these VM as AZURE does not allow communication between two different VNET and to allow the communication, one may use VNET Peering !!, Correct ?
But when i add a firewall exception from VM 1 to VM 2 i am able to access the data OR when i create a VNET Peering the same happens, Can someone please share me the difference of both and what is the requirement of VNET Peering when the same can be achieved by adding firewall exception
By default when you configure a peering it has full access between vnet's. You can use nsg (network security group) to block specific traffic.
A peering connection means that you are going to have connection between vnet's from private ip, for example vnet-a 10.0.0.0/16 can only access vnet-b 192.168.0.0/16 if it has a peering connection, because those ip's (address space) are privates. When you say firewall exception, you probably configured your private ip in your nsg, it is correct, you must specify your private ip to have access from internet, not your public ip, it is how Azure has designed nsg rules. For a example, your VM's public ip is 201.200.200.15, and private ip is 10.0.0.4, in order to allow this VM to be accesible from internet, you must put your private ip 10.0.0.4 in your nsg rules, not your public ip.
From Azure portal, go to both VM blades and check public and private IP, without a peering connection you won't be able to connect each other using private IP, but using public IP you can without peering.

Queries related to utilization, distribution and pricing of IP addresses on Azure

I have queries related to utilization, distribution and pricing of IP addresses on Azure.
Taking an example, 10.0.0.0/27. It says, 10.0.0.0 - 10.0.0.31 (32 addresses).
After expanding I found as..
CIDR Range: 10.0.0.0/27
Netmask: 255.255.255.224
Wildcard Bits: 0.0.0.31
First IP: 10.0.0.0
Last IP: 10.0.0.31
Total Host: 32
I assigned 10.0.0.0/27 for both VNet and Subnet on Azure Portal.
After creating the virtual network, I see available address 27.
1) No virtual machine created yet, then why the available addresses are 27?
2) What is the IP range for 27 available addresses?
While creating Gateway Subnet, I see errors like...
The specified address space overlaps with subnet 'Subnet1' which has a range of '10.0.0.0/27'.
Your subnet is not contained within the address space for this virtual network: 10.0.0.0/27.
3) How to calculate and decide the available gateway subnet address space for a virtual network?
4) For using gateway subnet, is it mandatory or recommended to add another subnet before or after creating gateway subnet?
5) Why address space is required for creating a gateway subnet? Is gateway subnet not a fixed or static IP address for creating connection?
6) In case of virtual network, 10.0.0.0/27, is pricing done on the basis of utilized IP addresses only?
7) In case of virtual network, 10.0.0.0/27, if there are some un-utilized IP addresses, are they blocked to me or my subscription or un-utilized IP addresses can be used by someone else on his azure portal?
I sincerely request to clarify all seven queries.
Q1-Q3:
Read Azure VNet FAQ, Azure reserves 5 IP addresses within each subnet. These are x.x.x.0-x.x.x.3 and the last address of the subnet. So you have 27 available addresses for the address range 10.0.0.0/27. It's address range 10.0.0.4 - 10.0.0.30
Q4: It's not mandatory for creating Gateway subnet order, you only need to calculate the CIDR Range for each subnet including in your current virtual network address range.
Q5: If you need to configure a virtual network gateway. The gateway subnet contains the IP addresses that the virtual network gateway services use. All gateway subnets must be named GatewaySubnet to work properly. Read here. If you don't need a VPN gateway, you don't need to create Gateway subnet in this VNet.
Q6-Q7: Have a look at Azure VNet pricing and VPN gateway pricing.
Azure Virtual Network is free of charge. Every subscription is allowed
to create up to 50 virtual networks across all regions.
Public IP addresses, and reserved IP addresses used on services inside
a virtual network, are charged.
Network appliances such as VPN Gateway and Application Gateway that
are run inside a virtual network are also charged.
For the un-utilized IP addresses, It looks like unassigned private IP address in your on-premise network. They can continue to be assigned to the resources when you deployed some resources in the VNet or subnet.
For more details, you can read this blog: Understanding CIDR Notation when designing Azure Virtual Networks and Subnets
Azure reserves 5 IP addresses within each subnet. These are x.x.x.0-x.x.x.3 and the last address of the subnet.
x.x.x.0 and the last address of the subnet is reserved for protocol conformance.
x.x.x.1-x.x.x.3 is reserved in each subnet for Azure services.
Address space is the super set of subnets. So, your Address space needs to be bigger and should be able to accommodate the IPs which you are defining for the Subnets.
Basic Subnetting would help.
It is not recommended to deploy your workloads on Gateway subnet. So you need other subnets to deploy your workloads.
Gateways does have a Private IP address which it gets from the Gateway subnet. As I mentioned in Point 2, Address space is the super set of subnets.
Only Public IPs are charged. Private IP which you define in Azure VNET is not charged.
Since it is Private IP address, you can create another 10.0.0.0/27 VNET in the same region. VNET provides a isolation and the address which you define is isolated to that VNET.

How to add a gateway subnet to Vnet that contains VMs on Azure

My existing Vnet has a default subnet: 10.0.1.0/24
And I have a VM in it with IP address: 10.0.1.8
Now I want to add a gateway subnet so that I can connect web app to it, and the web app should be able to use the VM's private IP to access it.
But when I try to add a gateway subnet, I can't specify 10.0.1.0/24 because it overlaps with the default. I can't specify 10.0.0.0/24 either because the VM is not within this range.
How do I do it, then?
You cannot add a gateway subnet that uses the same address space (10.0.1.0/24) as VNet.
If you original subnet has a smaller address space (ie: /26, /28) then you can add a gateway subnet using that format.
If you original subnet is using the whole address space (ie: /24) then a work around will be to add a new address space to the VNet and add new subnets on that address to the VNet splitting them up correctly.

Resources