I need to know, how can I add many URLs to the windows hosts file? - windows

I want to block DNS requests in my computer such as login.live.com, fs.windows.com, …, etc.
Basically, I'll change the settings
But I want to know How I add many URLs to the windows hosts file.
(I have many URLs to block, about 1000 URLs in text file)

The hosts file contains hostnames, not URLs.
Run Notepad As Administrator and edit C:\Windows\System32\Drivers\etc\hosts
Each line you add should be an IP address (e.g. a dummy one or 127.0.0.1 foor the loopback IP), followed by whitespace (space(s), tab(s)), followed by a hostname.
This will indeed prevent lookups in DNS for A records.
But are you sure this is how you want to do it?
There may be better methods, like using a filtering proxy for example.

Related

API equivalent to etc/hosts?

Is there a Windows (or Windows Device Driver) API that's equivalent to editing the etc/hosts file, i.e. to override or change the hostname-to-IPaddress mapping?
I'd want for a scenario where DNS might not exist on a LAN, or where the hosts in question aren't known to DNS, but where I know the host name and the IP addresses.
If not, then I take it that editing etc/hosts programmatically is the only way to do this?
How often or how soon does an edit to etc/hosts take effect -- i.e. if I edit it then will my next network connection request to a given host name use the new IP address, or is a stale value cached somewhere?
Windows has the file %WINDIR%\System32\drivers\etc\hosts which is exactly equivalent to the *nix /etc/hosts file.

I changed hosts file but can't see effects

I have to reach the wordpress platform installed by a certain hosting service, so I can build a new website (that will replace the old one), on a certain IP address. I changed my hosts file under their instructions. I put in it the IP address that they had given me and the website domain (separated by a single space). The hosts file hasn't any extension and it's in the right location (System32/drivers/etc - I'm on Windows 8). I cleaned browser and local DNS cache but nothing change: if I put in the browser the url they had given me (www.domain.com/?hostingname) I see the old website, not the wordpress platform. I tried to ping the domain and it returns a different IP address. What can I do? Thanks everyone in advance.
Ok, I solved. It's important to edit the hosts file with Windows Notepad and not with Notepad++

Hosts file - Alternative host when unavailable?

In the windows hosts file, is it possible to have a site with multiple redirect hosts with different priorities, in case one is down?
No. The hosts file is a simple flat file containing domain and IP address pairs only. The lookup service checks the host file first for a matching domain name and if one is found it uses the IP address specific in the file. There are no additional checks or balancing done during this lookup and no additional parameters are supported in the host definitions.

Is there a way to simulate DNS Hijacking for testing purposes?

I'm working on an application that connects to URLs, and it responds differently depending on whether or not an address resolves in DNS. I need to find a way to simulate DNS Hijacking so that I can test that my application handles it correctly.
Anybody know a way to do that?
Set up a DNS Server on a second pc and use this as your referenced DNS. Then you can shutdown it for sometime or modify the answers to try your handling behavior. If you dont have a second machine you can also set it up in a virtual machine.
Just add the "hijacked" hosts into your hosts file. In Linux, this should be in /etc/hosts; in Windows, %SYSTEMDIR%\drivers\etc\hosts..
The entries are in the format ip.addr.ess.here hostname1 hostname2 (there should already be entries for localhost, so add others to match your taste)
When you're done, remove (or comment out) from the hosts file again.

How do I create a subdomain on windows?

I just want to add a couple subdomains to my computers FQDN so that I can have some Vitrual Servers (apache.)
Any ideas?
Note: I need to add the aliases to my machine, like a.foo.com and b.foo.com. I don't think apache makes those aliases.
Alternative: I decided that instead of trying to add stuff to my domain name (since then I'd have to edit the dns server) I would configure virtual hosts for a separate port. That way it's all up to my computer. Thanks for the help nonetheless!
If this is on a Windows domain: go into the DNS management tool on the DC, and add host entries (CN records, not A records) pointing the desired names to the original computer name.
If you're doing this all on one (non-server) box: edit the hosts file, and point the names to the right IP address.

Resources