Instância da AWS não acessa o servidor de metadados com IP

3

minha instância de VM amazon (tipo c4.large, data center do Windows Server 2016) está na eu-central-1. Preciso obter metadados (principalmente para verificar se meu software está sendo executado em uma instância da AWS) e tento extrair isso do link .

Nem o wget nem o tracert podem acessar esse IP.

Eu posso navegar em qualquer site http desta VM.

C:\Users\Administrator>curl --verbose 169.254.169.254/latest/meta-data/
* timeout on name lookup is not supported
*   Trying 169.254.169.254...
* TCP_NODELAY set
* connect to 169.254.169.254 port 80 failed: Timed out
* Failed to connect to 169.254.169.254 port 80: Timed out
* Closing connection 0
curl: (7) Failed to connect to 169.254.169.254 port 80: Timed out

google.com funciona:

C:\Users\Administrator>curl --verbose www.google.com
* Rebuilt URL to: www.google.com/
* timeout on name lookup is not supported
*   Trying 172.217.16.196...
* TCP_NODELAY set
* Connected to www.google.com (172.217.16.196) port 80 (#0)
> GET / HTTP/1.1
> Host: www.google.com
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 302 Found
< Cache-Control: private
< Content-Type: text/html; charset=UTF-8
< Referrer-Policy: no-referrer
< Location: http://www.google.de/?gfe_rd=cr&ei=9pvwWJD5G8jb8Aemn6iABA
< Content-Length: 258
< Date: Fri, 14 Apr 2017 09:52:54 GMT
<
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.de/?gfe_rd=cr&amp;ei=9pvwWJD5G8jb8Aemn6iABA">here</A>.
</BODY></HTML>
* Curl_http_done: called premature == 0
* Connection #0 to host www.google.com left intact
    
por Paul 14.04.2017 / 10:18

1 resposta

1

No meu caso, esse problema foi causado por uma rota de rede inválida (especificamente, um NextHop incorreto). Aqui está a minha implementação de patch, inspirada pelo comentário @ gonzales-gokhan acima:

$destinationPrefix = '169.254.169.254/32'
$defaultNetIPConfig = @(Get-NetIPConfiguration | Sort-Object -Property 'InterfaceIndex')[0]
try {
  if (@(Get-NetRoute -DestinationPrefix $destinationPrefix -PolicyStore 'ActiveStore').Length) {
    Remove-NetRoute -DestinationPrefix $destinationPrefix -PolicyStore 'ActiveStore' -Confirm:$false -ErrorAction SilentlyContinue
    Write-Host 'network route for instance metadata removed from ActiveStore'
  }
  if (@(Get-NetRoute -DestinationPrefix $destinationPrefix -PolicyStore 'PersistentStore').Length) {
    Remove-NetRoute -DestinationPrefix $destinationPrefix -PolicyStore 'PersistentStore' -Confirm:$false -ErrorAction SilentlyContinue
    Write-Host 'network route for instance metadata removed from PersistentStore'
  }
  New-NetRoute -DestinationPrefix $destinationPrefix -InterfaceIndex $defaultNetIPConfig.InterfaceIndex -NextHop $defaultNetIPConfig.IPv4DefaultGateway.NextHop -RouteMetric 1 -ErrorAction Stop
  Write-Host 'network route for instance metadata added.'
}
catch {
  Write-Host ('failed to add network route for instance metadata. {0}' -f $_.Exception.Message)
}
    
por 17.10.2018 / 08:36