Aidan Finn, IT Pro 2024年08月28日
Why Are There So Many Default Routes In Azure?
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文探讨了 Azure 子网中出现大量默认路由的原因,以及这些路由是如何被处理的。文章解释了 Azure 如何处理 RFC-1918 私有地址、RFC-6598 运营商级 NAT 地址以及 Microsoft 自有地址范围的流量。作者还分析了 Azure 如何根据用户定义路由 (UDR) 调整默认路由行为。

🤔 Azure 子网中默认路由的出现并非偶然,而是 Azure 网络架构和安全策略的体现。由于 Azure 的网络是软件定义的,路由是由 Azure NIC/网络结构来执行的,当数据包离开虚拟机时,Azure NIC 会根据预设规则决定下一个跳点。

🛡️ Azure 采取“默认安全”的策略,默认情况下会丢弃所有指向 RFC-1918 私有地址范围 (10.0.0.0/8、172.16.0.0/12、192.168.0.0/16) 的流量,因为这些地址通常用于私有网络,除非用户明确配置了路由规则。

📡 针对 RFC-6598 运营商级 NAT 地址范围 (100.64.0.0/10),Azure 默认会丢弃流量,因为这些地址专用于运营商级 NAT,用于连接客户设备到运营商核心路由器。

🔒 对于一些 Microsoft 自有地址范围,例如 20.35.252.0/22、104.146.0.0/17、104.147.0.0/16 等,Azure 默认也会丢弃流量,这可能是为了保护 Microsoft 在线服务免受攻击,例如防止黑客利用 Azure 虚拟机发起攻击。

🚀 当用户在子网中添加用户定义路由 (UDR) 时,Azure 的默认路由行为会发生变化。如果 UDR 的前缀为 0.0.0.0/0,并且下一跳指向虚拟设备,则所有默认路由都会被丢弃,因为 Azure 认为用户已经配置了防火墙来保护网络。

💡 Azure 的默认路由策略旨在提供安全性和可控性,用户可以通过配置 UDR 来调整路由规则,以满足特定的网络需求。

Have you wondered why an Azure subnet with no route table has so many default routes? What the heck is 25.176.0.0/13? Or What is 198.18.0.0/15? And why are they routing to None?

The Scenario

You have deployed a virtual machine. The virtual machine is connected to a subnet with no Route Table. You open the NIC of the VM and view Effective Routes. You expect to see a few routes for the non-RFC1918 ranges (10.0.0.0/8, 172.16.0.0/12, etc) and “quad zero” (0.0.0.0/0) but instead you find this:

What in the nelly is all that? I know I was pretty freaked out when I first saw it some time ago. Here are the weird addresses in text, excluding quad zero and the virtual network prefix:

10.0.0.0/8172.16.0.0/12192.168.0.0/16100.64.0.0/10104.146.0.0/17104.147.0.0/16127.0.0.0/8157.59.0.0/16198.18.0.0/1520.35.252.0/2223.103.0.0/1825.148.0.0/1525.150.0.0/1625.152.0.0/1425.156.0.0/1625.159.0.0/1625.176.0.0/1325.184.0.0/1425.4.0.0/1440.108.0.0/1740.109.0.0/16

Next Hop = None

The first thing that you might notice is the next hop which is sent to None.

Remember that there is no “router” by default in Azure. The network is software-defined so routing is enacted by the Azure NIC/the fabric. When a packet is leaving the VM (and everything, including “serverless”, is a VM in the end unless it is physical) the Azure NIC figures out the next hop/route.

When traffic hits a NIC, the best route is selected. If that route has a next hop set to None then the traffic is dropped like it disappeared into a black hole. We can use this feature as a form of “firewall – we don’t want the traffic so “Abracadabra – make it go away”.

A Microsoft page (and some googling) gives us some more clues.

RFC-1918 Private Addresses

We know these well-known addresses, even if we don’t necessarily know the RFC number:

These addresses are intended to be used privately. But why is traffic to them dropped? If your network doesn’t have a deliberate route to other address spaces then there is no reason to enable routing to them. So Azure takes a “secure by default” stance and drops the traffic.

Remember that if you do use a subset of one of those spaces in your VNet or peered VNets, then the default routes for those prefixes will be selected ahead of the more general routes that dropping the traffic.

RFC-6598 Carrier Grade NAT

The subnet, 100.64.0.0/10, is defined as being used for carrier-grade NAT. This block of addresses is specifically meant to be used by Internet service providers (or ISPs) that implement carrier-grade NAT, to connect their customer-premises equipment (CPE) to their core routers. Therefore we want nothing to do with it – so drop traffic to there.

Microsoft Prefixes

20.35.252.0/22 is registered in Redmond, Washington, the location of Microsoft HQ. Other prefixes in 20.235 are used by Exchange Online for the US Government. That might give us a clue … maybe Microsoft is firewalling sensitive online prefixes from Azure? It’s possible someone could hack a tenant, fire up lots of machines to act as bots and then attack sensitive online services that Microsoft operates. This kind of “route to None” approach would protect those prefixes unless someone took the time to override the routes.

104.146.0.0/17 is a block that is owned by Microsoft with a location registered as Boydton, Virginia, the home of the East US region. I do not know why it is dropped by default. The zone that resolves names is hosted on Azure Public DNS. It appears to be used by Office 365, maybe with sharepoint.com.

104.147.0.0/16 is also owned by Microsoft which is also in Boydton, Virginia. This prefix is even more mysterious.

Doing a google search for 157.59.0.0/16 on the Microsoft.com domain results in the fabled “google whack”: a single result with no adverts. That links to a whitepaper on Microsoft.com which is written in Russian. The single mention translates to “Redirecting MPI messages of the MyApp.exe application to the cluster subnet with addresses 157.59.x.x/255.255.0.0.” . This address is also in Redmond.

23.103.0.0/18 has more clues in the public domain. This prefix appears to be split and used by different parts of Exchange Online, both public and US Government.

The following block is odd:

They are all registered to Microsoft in London and I can find nothing about them. But … I have a sneaky tin (aluminum) foil suspicion that I know what they are for.

40.108.0.0/17 and 40.109.0.0/16 both appear to be used by SharePoint Online and OneDrive.

Other Special Purpose Subnets

RFC-5735 specifies some prefixes so they are pretty well documented.

127.0.0.0/8 is the loopback address. The RFC says “addresses within the entire 127.0.0.0/8 block do not legitimately appear on any network anywhere” so it makes sense to drop this traffic.

198.18.0.0/15 “has been allocated for use in benchmark tests of network interconnect devices … Packets with source addresses from this range are not
meant to be forwarded across the Internet”.

Adding User-Defined Routes (UDRs)

Something interesting happens if you start to play with User-Defined Routes. Add a table to the subnet. Now add a UDR:

When you check Effective Routes, the default route to 0.0.0.0/0 is deactivated (as expected) and the UDR takes over. All the other routes are still in place.

If you modify that UDR just a little, something different happens:

All the mysterious default routes are dropped. My guess is that the Microsoft logic is “This is a managed network – the customer put in a firewall and that will block the bad stuff”.

The magic appears only to happen if you use the prefix 0.0.0.0/0 – try a different prefix and all the default routes re-appear.

The post Why Are There So Many Default Routes In Azure? first appeared on Aidan Finn, IT Pro.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Azure 网络 路由 安全 默认路由 UDR
相关文章