Windows Batch: How to add Host-Entries?

I would do it this way, so you won’t end up with duplicate entries if the script is run multiple times. @echo off SET NEWLINE=^& echo. FIND /C /I “ns1.intranet.de” %WINDIR%\system32\drivers\etc\hosts IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^62.116.159.4 ns1.intranet.de>>%WINDIR%\System32\drivers\etc\hosts FIND /C /I “ns2.intranet.de” %WINDIR%\system32\drivers\etc\hosts IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^217.160.113.37 ns2.intranet.de>>%WINDIR%\System32\drivers\etc\hosts FIND /C /I “ns3.intranet.de” %WINDIR%\system32\drivers\etc\hosts … Read more

How to add more than one machine to the trusted hosts list using winrm

I prefer to work with the PSDrive WSMan:\. Get TrustedHosts Get-Item WSMan:\localhost\Client\TrustedHosts Set TrustedHosts provide a single, comma-separated, string of computer names Set-Item WSMan:\localhost\Client\TrustedHosts -Value ‘machineA,machineB’ or (dangerous) a wild-card Set-Item WSMan:\localhost\Client\TrustedHosts -Value ‘*’ to append to the list, the -Concatenate parameter can be used Set-Item WSMan:\localhost\Client\TrustedHosts -Value ‘machineC’ -Concatenate

Set cURL to use local virtual hosts

Actually, curl has an option explicitly for this: –resolve Instead of curl -H ‘Host: yada.com’ http://127.0.0.1/something use curl –resolve ‘yada.com:80:127.0.0.1′ http://yada.com/something What’s the difference, you ask? Among others, this works with HTTPS. Assuming your local server has a certificate for yada.com, the first example above will fail because the yada.com certificate doesn’t match the 127.0.0.1 … Read more

Why does Microsoft Edge open some local websites, but not others, where the domain name is routed to 127.0.0.1 in hosts file

Your network can block loopback as a security measure in Windows 10. Open a command prompt as administrator, and run this to exempt Edge from a loopback: CheckNetIsolation LoopbackExempt -a -n=”Microsoft.MicrosoftEdge_8wekyb3d8bbwe” (Microsoft.MicrosoftEdge_8wekyb3d8bbwe is the identifier for the Edge app) There’s a blog post here giving more detail: https://blogs.msdn.microsoft.com/msgulfcommunity/2015/07/01/how-to-debug-localhost-on-microsoft-edge/

Wildcards in a Windows hosts file

Acrylic DNS Proxy (free, open source) does the job. It creates a proxy DNS server (on your own computer) with its own hosts file. The hosts file accepts wildcards. Download from the offical website http://mayakron.altervista.org/support/browse.php?path=Acrylic&name=Home Configuring Acrylic DNS Proxy To configure Acrylic DNS Proxy, install it from the above link then go to: Start Programs … Read more

How to update /etc/hosts file in Docker image during “docker build”

With a more recent version of docker, this could be done with docker-compose and its extra_hosts directive Add hostname mappings. Use the same values as the docker run client –add-host parameter (which should already be available for docker 1.8). extra_hosts: – “somehost:162.242.195.82” – “otherhost:50.31.209.229” In short: modify /etc/hosts of your container when running it, instead … Read more