无法理解为什么运行在Windows Server 2016上的我的停靠容器不能访问其主机的AWS实例元数据端点。在Linux上,我在为容器的主机提取元数据时没有遇到这些问题,但是我是一个Windows,不知道为什么这不起作用。我一直在寻找答案,但却找不到答案。
货柜可上网(8.8.8.8)
PS C:\> invoke-webrequest -uri "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
invoke-webrequest : Unable to connect to the remote server
At line:1 char:1
+ invoke-webrequest -uri "http://169.254.169.254/latest/meta-data/iam/s ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand发布于 2021-04-15 15:16:16
即使路由器不应该路由本地链接地址窗口,如果你给它提供良好的静音路由。只是一些网络规则..。不是RFC违规行为。
解决方案来自:https://docs.aws.amazon.com/AmazonECS/latest/developerguide/windows_任务_IAM_roles.html
# Fetch the default gateway IP of container (bridge to host)
$gateway = (Get-NetRoute | Where { $_.DestinationPrefix -eq '0.0.0.0/0' } | Sort-Object RouteMetric | Select NextHop).NextHop
# Fetch the container internal IP interface index
$ifIndex = (Get-NetAdapter -InterfaceDescription "Hyper-V Virtual Ethernet*" | Sort-Object | Select ifIndex).ifIndex
# Create a new route similar to "169.254.169.254 255.255.255.255 172.30.42.1 172.30.42.82 5256"
New-NetRoute -DestinationPrefix 169.254.169.254/32 -InterfaceIndex $ifIndex -NextHop $gatewayhttps://serverfault.com/questions/1011591
复制相似问题