Questions tagged [hosts]

A `hosts` file is used to map hostnames to IP addresses on a TCP/IP-enabled computer.

A hosts file is used to map hostnames to IP addresses on a TCP/IP-enabled computer. On Unix and Unix-like operating systems (Linux, OSX, FreeBSD, NetBSD, et al), the file is located at /etc/hosts. In Microsoft Windows, the file may be located in different places depending on the version of the operating system. In Plan 9 from Bell Labs it is located at /lib/ndb/hosts

On most systems, the behaviour of /etc/hosts depends on configuration within the /etc/nsswitch.conf file.

841 questions
25
votes
4 answers

IP Address to Hostname in Java?

My hosts file (C:\WINDOWS\system32\drivers\etc\hosts) has a bunch of IP Address to host name mappings: # Switches 192.168.200.254 sw-con-ctrl 192.168.201.253 sw-con-ctrl-2 192.168.201.254 sw-con-ctrl-1 # 192.168.188.1 …
mainstringargs
  • 13,563
  • 35
  • 109
  • 174
24
votes
2 answers

How to edit hosts file via CMD?

Hello I'd like to block some websites directly from the command prompt. echo like this: 0.0.0.0 websitename.com How can I do this? (OS: Windows 7)
omnix
  • 1,839
  • 7
  • 23
  • 34
21
votes
1 answer

What is the meaning of mounting /dev/sda1 to /etc/hosts in Docker container

I run a simple docker container with sudo docker run -it ubuntu:latest /bin/bash When I examine mounted file system, with: df -h, one Filesystem Size Used Avail Use% Mounted on overlay 63G 4.3G 56G 8% / tmpfs 64M 0…
antonpuz
  • 3,256
  • 4
  • 25
  • 48
21
votes
5 answers

Why is my hosts file entry being ignored by the browser?

I mapped a website with the IP of www.facebook.com to load Facebook when I request a different url (let's say www.x.lk) particular site. It worked well. But when I tried to map the inverse, which should load www.x.lk when I ask for Facebook, it…
Kalana Shalitha
  • 231
  • 1
  • 2
  • 5
21
votes
2 answers

Resolve one hostname to another, using hosts file

I know how to resolve a hostname to an IP address using my hosts file eg 1.2.3.4 example.com but is it possible to resolve a hostname to another example.com example1.com with a hosts file? Reason being, Im testing a new site, hosting uses…
stephen mc
  • 751
  • 2
  • 12
  • 22
20
votes
2 answers

How do I redirect a URL to another URL in the hosts file, rather than redirecting an IP to a URL?

How do I redirect a URL to another URL in the hosts file, rather than redirecting an IP to a URL?
chad
  • 203
  • 1
  • 2
  • 4
19
votes
3 answers

How to resolve hostname to an ip address in node js

I need to resolve hostname defined in hosts file to its corresponding IP address. For example my host file look like this - "/etc/hosts" 127.0.0.1 ggns2dss81 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 192.168.253.8…
Abhilash Kant
  • 358
  • 1
  • 2
  • 10
19
votes
2 answers

proxy_pass does not resolve DNS using /etc/hosts

In nginx the proxy_pass directive is not resolving DNS using the /etc/hosts file. Any way to enable this possibility (maybe by leveraging Lua as a last resort)?
Mark
  • 67,098
  • 47
  • 117
  • 162
19
votes
4 answers

Can /etc/hosts config reverse resolution?

As we all known, we can add 'ip host' item in /etc/hosts to mock a DNS's name resolution, now comes the question, can I use /etc/hosts to do inverse resolution, form ip to hostname? Or is there any other handy way to do this? Thanks!
小武哥
  • 446
  • 1
  • 5
  • 14
19
votes
4 answers

Unable to create virtual directory

I am working on a website which authenticates with Facebook, so that the user can sign in through his/her Facebook profile. I've seen similar questions like this one, but none that covers exactly my issue. To test this Facebook authentication…
Mathias Lykkegaard Lorenzen
  • 15,031
  • 23
  • 100
  • 187
17
votes
3 answers

Fix "invalid host header" in Angular

I have an app in Angular v4 which have to change the scss dependong of the url of access. For example: if link in the browser is "example.com" then the app have background-color: black if the link is"example2.com" then the background-color: red I…
Sergio Mendez
  • 1,311
  • 8
  • 33
  • 56
16
votes
2 answers

How are 127.0.0.1, 0.0.0.0 and localhost different?

I don't understand the difference between these terms and how they are connected. I looked at a hosts file on my computer and could see that 127.0.0.1 and localhost are connected but not sure how and I don't know where 0.0.0.0 fits into all…
j obe
  • 1,759
  • 4
  • 15
  • 23
15
votes
4 answers

Emulate hosts file on non-rooted Android

Is there a way to emulate the behaviour of a hosts file on non-rooted Android? I need to test a website on Android. I get to the website via IP address but it seems to redirect to a URL that is not available from the phone. So is there a way to…
anotheruser1488182
  • 315
  • 1
  • 3
  • 9
14
votes
3 answers

How to create subdomain in Laravel dynamically?

In my Windows/System32/drivers/etc/hosts, I have this: 127.0.0.1 localhost 127.0.0.1 site.dev 127.0.0.1 *.site.dev In my xampp/apache/conf/extra/httpd-vhost, I have this: DocumentRoot "C:/xampp_7/htdocs/" …
Vahn Marty
  • 1,428
  • 3
  • 14
  • 28
14
votes
3 answers

sed: replace ip in hosts file, using hostname as pattern

I'm learning about sed but it is very difficult to me understand it. I have adsl with dynamic ip so and i want to put current ip on hosts file. This following script just tells me the current wan ip address and no more: IP=$(dig +short…
sergius
  • 165
  • 1
  • 1
  • 11
1
2
3
55 56