22

Is there a way to determine the outgoing IP address of a Website (not a webrole)?

I've done a reverse looking up *.azurewebsites.net which returns one address, however when I manually check it (by having the webapplication visit a webserver i control), it shows a completely different IP.

What is the right way of doing this?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Richie Lai
  • 502
  • 1
  • 6
  • 16
  • 1
    What is it you are trying to achieve? Because of the lightweight nature of azure websites it might be preferable not to rely on information that can change like the current IP. – Simon Opelt Jan 30 '14 at 08:36
  • 1
    I have a website that calls an external REST interface that I would like to lockdown by IP. I've already got auth and ssl on it, but I want this layer of protection since we are dealing with highly sensitive data. – Richie Lai Jan 30 '14 at 19:53

4 Answers4

30

Azure website can use a random IP just out of 4 IP addresses per scale unit.

For a list of IP addresses per scale unit and instructions about how to determine your site's scale unit, take a look here.

UPDATE: seems that all the scale unit's 4 IP addresses can now be found in the new Azure portal and the forum post will no longer be updated.

From July 20th, 2015 onwards, this post will no longer be updated with IP addresses. Instead this information can now be found in a web app's properties using the new portal (portal.azure.com).

To find the outbound IP addresses:

  1. Browse to the details of your specific web app using the new portal at portal.azure.com.

  2. Towards the top of the details for your web app, there is a link for "All settings". Click the link.

  3. Clicking "All settings" will open up a list of web app information that you can drill into further. The specific information to drill into is "Properties". Click on the "Properties" selection.

  4. Within the "Properties" UX, there is a textbox showing the set of Outbound IP Addresses. Using the icon to the side of the "Outbound IP Addresses" textbox you can select all of the addresses. Pressing Ctrl+C will then copy the addresses to the clipboard.

Community
  • 1
  • 1
jtmnt
  • 746
  • 7
  • 12
  • 7
    Are these "Outbound IP Addresses" static? – Jorik Jan 13 '16 at 12:38
  • What scripting or API call can be made to get that without clicking through GUI menus? – Snowy Mar 30 '16 at 16:37
  • 1
    You can also find the IP addresses from https://resources.azure.com (https://resources.azure.com/subscriptions/YOUR-SUBSCRIPTION-GUID/providers/Microsoft.Web/sites) – jtmnt Mar 31 '16 at 10:25
6

You can get the "OUTBOUND IP ADDRESSES" property via PowerShell. Here is the command:

(Get-AzureRmResource -ResourceGroupName inhabit-adminservices -ResourceType Microsoft.Web/sites -ResourceName YOUR_RESOURCE_NAME).Properties.OutboundIpAddresses -Split ","

Where YOUR_RESOURCE_NAME is the name of Resource group.

Evgeniy
  • 564
  • 5
  • 14
1

It seems Azure websites will randomly use any of the datacenter's IP addresses for outbound traffic. You can download a list of ip addresses here : http://msdn.microsoft.com/en-us/library/dn175718.aspx

Alternatively use a combination of an Azure cloud service and an Azure VPN. The VPN will ensure you get a static ip address for all outbound traffic. It's a shame they didn't forsee this for their websites service.

Dermot
  • 324
  • 2
  • 6
  • 1
    As long as you don't delete the deployment of a cloud service, it's IP won't change. No need for a VPN imho. – ckonig Dec 21 '14 at 20:40
-1
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
    if (Request["check"] == "1")
    {
        Response.Clear();
        Response.Write(HttpContext.Current.Request.UserHostAddress);
    }
    else { 
        Response.Write("Your IP: " + HttpContext.Current.Request.UserHostAddress + "<br />") ;
        Response.Write("Server Outbound IP: " + GetOutBoundAddress()) ;
    }
}

public string GetOutBoundAddress()
{
    System.Net.WebClient wc = new System.Net.WebClient();

    try
    {
        return wc.DownloadString(Request.Url + "?check=1");
    }
    catch (Exception)
    {
        return "not found";
    }
}