App Service Linux container amid conversations.
Published Aug 28 2023 11:25 PM 2,094 Views
Microsoft

What's communicating with what? What are the various IP addresses involved when App Service Linux container talks to a remote resource (e.g., Databases)? From the remote end of the connection, would I see a private IP or Public IP as the Linux Container source address?

Let's explore!

 

Given -

  1. A VNet Integrated App Service Linux app.
  2. Remote Azure resource (VM in this case; Private IP 10.1.0.4, public IP obfuscated) to connect to.

 

Open an SSH session from Azure Portal to App Service Linux app container.

 

Case #1

Ping public IP (obfuscated) from app container.

Network packets captured at app container.

Result -

 

VinodRawat_0-1693288407445.png

 

Simultaneous network packet capture at the remote Azure resource (VM).

Result -

VinodRawat_1-1693288407453.png

The IP address obfuscated with indigo colour (screenshot above) is an outbound IP address for the App Service Webspace.

Note: An App Service app runs in an App Service plan, and App Service plans are deployed into one of the deployment units in the Azure infrastructure (internally called a webspace). Each deployment unit is assigned a set of virtual IP addresses, which includes one public inbound IP address and a set of outbound IP addresses.

Inbound/Outbound IP addresses - Azure App Service | Microsoft Learn

 

Case #2

Ping VM Private IP 10.1.0.4 from app container.

When pinging from App container, packets have been captured on the remote resource (VM). This is shown in screenshot below. You may notice that the destination is the Private IP of the VM, and the Source (app container) shows up having another private IP 10.0.0.126.

 

VinodRawat_2-1693288407454.png

 

Observations and explanation -

  1. What is this Source IP 169.254.254.0/24 range?

If you check the network interfaces (e.g., ifconfig command), you will notice an interface starting with 'vnet' as shown below. This interface is assigned an IP from this range (container specific network).

 

VinodRawat_3-1693288407455.png

 

2. Why does the simultaneous packet capture (Case #1) on remote Azure resource show Source as a public IP (obfuscated in indigo color)?

This public IP is an outbound IP address for App Service app. By default, routable (public) traffic will be routed via one of the outbound IP addresses for App Service. This outbound IP becomes the 'From' address for any remote resource that's communicating with App service.

 

3. When App service communicates with the Private IP (in contrast to Public IP) of the remote resource, what is this another App service private IP 10.0.0.126 that shows up in trace (Case #2)?

The Source is the Private IP that got assigned to the VNet interface as result of VNet integration. You can confirm it from the following page for your app -

https://<yoursite>.scm.azurewebsites.net/newui/env

 

You can also check it by doing an SSH to container and printing variable value as shown in screenshot below.

 

VinodRawat_4-1693288407457.png

 

 

How do I apply this knowledge? Where does this all help us in practical scenarios?

Well, now at this point, I hope you are comfortable understanding the different IP addresses involved here.

This information may help you, for example, troubleshooting TCP channel/SSL connectivity. The screenshot below depicts a successful TCP and SSL handshake between App Service Linux container and MySQL Database (it could be any other remote resource as well that requires SSL).

 

VinodRawat_5-1693288407459.png

 

While connecting to a DB, the handshakes above were captured from Azure Portal SSH session on Linux App Service app container using following command (to stop capturing, press Ctrl + C) -

tcpdump -i any -s0 -w handshakes.pcap

 

VinodRawat_6-1693288407461.png

 

As another example, this might also help you investigate when app container is dealing with misconfigured DNS settings.

Showing below a typical DNS query from app container to Azure DNS attempting to resolve 'A' record.

 

(The Azure DNS Virtual Server IP address is 168.63.129.16

https://learn.microsoft.com/en-us/azure/machine-learning/how-to-custom-dns?view=azureml-api-2&tabs=a...)

 

VinodRawat_7-1693288407462.png

 

Reply from Azure DNS shows it failed to resolve 'A' record as only CNAME type is returned -

 

VinodRawat_8-1693288407464.png

 

After fixing configuration, the type 'A' record is resolved, and the IP address is returned by Azure DNS -

 

VinodRawat_9-1693288407464.png

 

The scenarios above were randomly taken to demonstrate how we can apply this knowledge to practical usage. You may apply it to a broader spectrum of scenarios as you see fit. Thanks for reading.

3 Comments
Co-Authors
Version history
Last update:
‎Aug 29 2023 07:29 AM
Updated by: