Adding IP address to host file on windows image

I’ve been trying to figure out how to map a DNS name to an unlisted publicly hosted server for running integrated SDK tests against. Instead of getting the desired result, I get some strange result with a URL that seems to be somehow related bitcoin mining when searched on google.

The log goes something like this and I can’t quite figure out what’s going on. The fact the IP address shows up appended to another URL when attempting to ping is strange. Initially I thought it required a space or line feed but that doesn’t appear to help.

Add test server host name

0s

Run ECHO %NEWLINE%^1.2.3.4 example.org>>%WINDIR%\System32\drivers\etc\hosts

debug dns name to make sure ip is assigned

3s

Run ping example.org

Pinging stratum-na.rplant.xyz1.2.3.4 [127.0.0.1] with 32 bytes of data:

Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Hi @mrking,

Glad to see you in Github Community Forum!

This is due to 1.2.3.4 example.org is added behind stratum-na.rplant.xyz while not in a new line.
The default shell for windows hosted runner is pwsh, so please use below command instead:

echo "`n1.2.3.4 example.org">>C:\Windows\System32\drivers\etc\hosts   #add to new line

Please check my workflow for your refernce.

Thanks

1 Like

@weide-zhou

Thanks so much! I had been using CMD, but this seems to have worked! Really appreciate taking the time to even setup a working example.