Questions tagged [hosts-file]

The hosts file is a computer file used in an operating system to map hostnames to IP addresses. The hosts file is a plain text file and is conventionally named hosts.

The hosts file is one of several system facilities that assists in addressing network nodes in a computer network. It is a common part of an operating system's Internet Protocol (IP) implementation, and serves the function of translating human-friendly hostnames into numeric protocol addresses, called IP addresses, that identify and locate a host in an IP network.

In some operating systems, the hosts file's content is used preferentially to other methods, such as the Domain Name System (DNS), but many systems implement name service switches (e.g., nsswitch.conf for Linux and Unix) to provide customization. Unlike the DNS, the hosts file is under the direct control of the local computer's administrator.

More see at Wikipedia

148 questions
2
votes
3 answers

Getting hosts file location in Java

How can I get the location of the hosts file when using my application on different platforms?
Arjan
  • 1,950
  • 2
  • 16
  • 21
2
votes
3 answers

XCOPY hosts file on vista from a batch file

I need a command to replace the hosts file on my machine. Seems pretty straight forward but I cannot get the command to work with xcopy. Any obvious flaws in the command? luaexec -w -f "XCOPY" "%ScriptPath%/ModifiedHosts/vista/hosts"…
Joe
  • 409
  • 2
  • 9
  • 19
2
votes
1 answer

hosts file on windows azure website

I have a ASP.NET website in windows azure that uses a web reference. I use azure as my QA environment and on QA, the site should connect to the QA web reference. On my previous QA environment, I used hosts file entry to point the web reference…
Arbi
  • 53
  • 4
2
votes
1 answer

Windows hosts file and IIS binding question

I'm building a few SharePoint sites, and I want to make use of zones so I may set security different in the various zones. My workstation has a local SharePoint, and I use it for development. My workstation has a static IP, and is connected to the…
bmw0128
  • 13,470
  • 24
  • 68
  • 116
2
votes
1 answer

How to Map an IP to hostname in python without writing in hosts file

I am using windows 7 and python 2.7 I created local https server with redirect url to server as its IP address. I created cert file for https using openssl. Then I mapped my local system IP(172.16.17.84) to myapp.nobies.in in hosts file of…
imp
  • 1,967
  • 2
  • 28
  • 40
2
votes
2 answers

Blocking all of tumblr from hosts file

I am trying to block tumblr, and all it's pages, using my hosts file. Usually I would just add an entry like 127.0.0.1 tumblr.com to my file, but tumblr has websites in the format " sitename.tumblr.com" I have tried 127.0.0.1…
Rich Williams
  • 1,593
  • 2
  • 11
  • 9
2
votes
3 answers

How to replace a string in the host file using batch?

I'm trying to write a batch file to find and replace an IP address in the hosts file. I did a bit of research and found this, but it doesn't seem to work. I get the final echo of "Done." but it doesn't work. @echo off REM Set a variable for the…
2
votes
1 answer

How to overwrite read-only files in privileged locations on MacOS?

I'm writing an app that needs to overwrite a read-only file. Specifically the /etc/hosts file. To do that I need to ask for permission from the user to get root access and thereby permission to overwrite the hosts file. I have searched all over the…
Tokke
  • 302
  • 2
  • 13
2
votes
2 answers

Using awk to search backwards by line, and append result to next the line

I am trying to generate a temporary hosts file, which is based on a DNS log provided by dnsmasq. I have got it mostly working, however I am having a problem with CNAMEs. I will show what I have achieved so far. There are 3 types of responses in the…
Matthew
  • 63
  • 1
  • 7
2
votes
1 answer

How can I setup a development environment to use subdomains in the Azure emulator like on localhost(IIS) using hosts file?

I have this working in an MVC project on IIS by adjusting the hosts file. When running an Azure project, I can see some ports getting remapped, not sure what thats doing or how I can set up subdomains, is it also done in the hosts file?
Mark Redman
  • 24,079
  • 20
  • 92
  • 147
1
vote
2 answers

Hosts File (Kinda) Doesn't Work

Im having some trouble with my host file.. If I change the IP for a domain it and flush the DNS I still get the old site, but if I set the IP to 000.000.000.000 I get an error, like I should. This is my current hosts file: # # Host Database # #…
Tim S
  • 25
  • 4
1
vote
1 answer

app.localhost is still resolved by curl as 127.0.0.1 though overriden in /etc/hosts on Amazon Linux 2

Is there a config to change the behaviour of the name resolver of Amazon Linux 2 to not ignore entry about localhost subdomains ? i.e currently it does : docker run -it amazonlinux:2023 /bin/bash -c "echo '172.4.0.2 app.localhost' >> /etc/hosts ;…
allan.simon
  • 3,886
  • 6
  • 35
  • 60
1
vote
0 answers

Powershell script doesn't use the updated IP address in the hosts file when Invoke Invoke-RestMethod

I have a Powershell script that runs on an array of IP addresses, for each one, it adds the entry to the hosts file: add-host $hostsFilePath $ipAddress $domainName using these methods: add-host and remove-host methods then I run: Invoke-RestMethod…
RoG
  • 411
  • 4
  • 20
1
vote
0 answers

where does localhost name get resolved on windows?

clearly localhost name on windows is resolving on same place other than hosts file: line 127.0.0.1 localhost has a # on the beginning so it will be ignored on lines above, it's said that localhost gets resolved within DNS itself I've set a custom…
1
vote
1 answer

Hosts file working for custom subdomains but not custom domains

I am developing a multi tenant app and need to modify my etc/hosts file to test the different URLs tenants might use. Some will use a sub domain like tenant1.mysite.com and others will use entirely their own URL like tenant2.com (to mask the fact…
David
  • 141
  • 6