Questions tagged [hosts-file]

Hosts file is an OS file to map hostnames to IP addresses.

Hosts file is an operating system file that maps hostnames to IP addresses. It is a plain text file. In modern operating systems, the hosts file remains an alternative name resolution mechanism, configurable often as part of facilities such as the Name Service Switch as either the primary method or as a fallback method.

150 questions
35
votes
10 answers

Point multiple IP addresses to a single host name

In Windows System, there is this file at C:\WINDOWS\system32\drivers\etc\hosts. This file allows us to default a specific IP address to a host name. The issue now is whether I can set multiple IP addresses to a host name. For example, can I do…
Graviton
  • 2,775
  • 12
  • 41
  • 62
31
votes
4 answers

How do I add IPv6 address into System32\drivers\etc\hosts?

There is already by default, and it works (Win 7): ::1 localhost This also works (testing with ping): ::1 hosta But when I'm trying to add something non-loopback, it doesn't resolve: fe80::215:afff:fec6:ea64 realhost So…
Evgenyt
  • 733
  • 1
  • 7
  • 10
16
votes
2 answers

Is it possible to have round-robin DNS with /etc/hosts file?

Is it possible to have round-robin DNS with the follwing configuration in /etc/hosts? 192.168.4.10 shaakunthala.local 192.168.4.20 shaakunthala.local I'm on Linux.
Shaakunthala
  • 181
  • 1
  • 1
  • 7
10
votes
2 answers

Map IP to another IP

Assume the following scenario, if I have a local machine (A) the requests another machine (B) using B's internal IP without regard the ports. But A and B are not on the same network, however, B has a public IP. what I want to do is when requesting…
Yahia
  • 305
  • 1
  • 3
  • 8
10
votes
2 answers

Cannot write to /etc/hosts file from Dockerfile with RUN

I am making a docker image using a pretty simple Dockerfile. Inside the Dockerfile I have this command: RUN printf "192.92.13.243 www.hahaha.com \n" >> /etc/hosts The command itself seems to be OK, since creation of the image does not halt at this…
dlyk1988
  • 1,644
  • 4
  • 24
  • 36
10
votes
5 answers

Should 127.0.0.1 and ::1 both be included in /etc/hosts file?

I am new to unmanaged VPS servers and in addition IPv6. Is it necessary to include 127.0.0.1 AND ::1 for localhost in /etc/hosts files for IPv6 enabled servers, or is ::1 alone enough?
filmoreha
  • 221
  • 1
  • 3
  • 7
9
votes
1 answer

Nslookup not using hosts file

So I've set public IP on the hosts file for a certain public IP address, but it picks up private ip from nowhere or from DNS. Content of windows hosts file C:\Windows\System32\drivers\etc\Hosts 210.210.210.10 my.domain.com …
9
votes
6 answers

dnsmasq reading /etc/hosts, but not using it

I've done a default install of dnsmasq. When I run dig, it seems to be using dnsmasq (127.0.0.1), but the results don't include the hostnames included in /etc/hosts. /etc/hosts: 192.168.1.13 sun in a terminal: $ dig sun ; <<>> DiG 9.6-ESV-R4 <<>>…
Zach Dwiel
  • 91
  • 1
  • 1
  • 3
8
votes
2 answers

Why not assign the hostname to the loopback address in /etc/hosts?

So I understand that the hostname should (at least in Debian systems) be set in /etc/hostname. To get the FQDN (through hostname -f) the system finds the IP from the hostname through /etc/hosts and then returns the first entry in the line. So if the…
gitaarik
  • 431
  • 1
  • 5
  • 12
8
votes
3 answers

How do I re-map a hostname to another?

How can I re-map one hostname to another, similar to how one would re-map a hostname to an IP in /etc/hosts? For instance, how could I map oneheckofalongdomainname.com to a.com on my local machine? Adding an entry into /etc/hosts won't work as it…
Phillip B Oldham
  • 1,016
  • 5
  • 15
  • 24
7
votes
3 answers

Is it safe to add additional 127.0.0.1 entries to /etc/hosts?

I want to add this entry: 127.0.0.1 api.localhost To test the api of my web app. However, the hosts file says: ## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this…
user42235
6
votes
1 answer

Are there certain specific host file entries that Windows 2008 will ignore for security purposes?

While troubleshooting a network timeout/connectivity WinHTTP issue, I temporarily added a host file entry for: 127.0.0.1 ctldl.windowsupdate.com (The server has no internet connection and the firewall was causing some extended timeouts -- I wanted…
Mike B
  • 11,570
  • 42
  • 106
  • 165
6
votes
2 answers

how to modify /etc/hosts from shell scripts?

I need to change some hosts entries - for example, there's a desire to update hosts to have active.vm host match the IP of currently booted VM (with some testing appliance). Guest software within VM reports machine's address back to host, and I need…
kagali-san
  • 1,921
  • 5
  • 17
  • 20
5
votes
2 answers

Modifying /etc/hosts to easily access a domain name (or ip address) for amazon EC2 instance

I previously added into my local(Mac OS x 10.6) /etc/hosts file my server's public ip something like this: 123.123.123.123 myServer to allow me to ssh to myServer without having to remember the ip address of the server and worked fine (using shh…
venix
  • 51
  • 1
  • 1
  • 3
5
votes
2 answers

Alternative to HOSTS file for virtual hosts?

I am running Windows 7, Apache 2.28 is my version of Apache, localhost and virtual hosts run well. Only one issue - what's the best alternative to using the HOSTS file? I tried DNSKong, but not sure if that's the best idea... isn't that a…
1
2 3
9 10