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

134 questions
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
  • 272
  • 1
  • 12
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
  • 22,537
  • 19
  • 88
  • 134
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
  • 27
  • 4
1
vote
1 answer

Windows - Private hosts file for a certain environment

I've an application running on a dev server and connecting to a dev-db hosting an oracle instance. Now i'm deploying the on a prod/prod-db machine Since the dev-db url is hardcoded inside the java code, the just-copied binaries still points to…
Gabriele B
  • 2,446
  • 21
  • 39
1
vote
1 answer

Domain forwarding or masking on local machine only?

I'm sad to have to ask this question, but I'm not even sure of what to call what I'm trying to do, so Google isn't much help. I'm doing some work on a company website from outside the company's network. Some of the assets on the site are loaded from…
Fo.
  • 3,455
  • 6
  • 22
  • 38
1
vote
1 answer

How to set up custom hostnames and ports for servers (eg node.js) running in WSL 2

(I've provided a simple working solution in response) I recently moved from macOS to WSL 2. I have two node servers running within WSL 2 (Ubuntu distro). Each must be accessible through a custom hostname for development vs production purposes. I've…
MoMo
  • 1,483
  • 1
  • 15
  • 35
1
vote
1 answer

How to change the URL from “localhost” to something else, on a local system using Flask?

On a Windows machine, there's a system running on the local FLask server, but while the application is running on localhost. While the Default I would expect the URL to be like this based on the directory structure: http://localhost/swagger But The…
1
vote
2 answers

Can I edit the hosts file to see the new website and still access the old one?

I'm developing a new website that will have the same domain name as the current old one, but a different host. The new one doesn't have DNS nameservers pointed to it yet, but I edited the hosts file on my computer to be able to access it. Is there a…
Jojo
  • 25
  • 3
1
vote
1 answer

Application taking a while to listen for incoming connections

I have an application which uses the hosts file to block certain websites. The websites can't connect because of the hosts file, so that works great, however, my program is supposed to raise an event when a website is blocked. I'm using this…
1
vote
1 answer

Setting Up WordPress MS Locally with Port 8888 with XAMPP

I have installed XAMPP and edited the httpd.conf file because my port 80 is busy. So I have the following: Listen 0.0.0.0:8888 Servername localhost:8888 Everything works fine until I try to install WordPress 3.0.5 MS because it will not accept…
user621663
  • 11
  • 3
1
vote
1 answer

How can I create dynamic virtual hosting like *.example.com?

Where * is different for each client like apple.example.com, pearl.example.com. These all should be routed to the same IP and same directory. How to modify the hosts file and the httpd config? More detailed example:
Hey.There
  • 15
  • 5
1
vote
0 answers

Changing Selenium node's hosts file?

As of right now I have 3 different nodes all pointing to the same staging environment, but I wan't to run a few separate tests on a different environment. Is there any way that I could change a node's hosts file on the fly before and after each…
JJ17
  • 13
  • 5
1
vote
1 answer

How to get /etc/hosts entries in puppet?

The types host and augeas can only set certain values in /etc/hosts. facter does not support hosts query. Now I'm considering 1)writing a ruby function, using Resolv library 2)writing a ruby function, and actually read /etc/hosts file Any better…
can.
  • 1,798
  • 7
  • 26
  • 38
1 2 3
8 9