selfboot / AnnotatedShadowSocks

Annotated shadowsocks(python version)
Other
3 stars 1 forks source link

System file hosts and resolv.conf #35

Open selfboot opened 7 years ago

selfboot commented 7 years ago

/etc/resolv.conf

resolv.conf is the name of a computer file used in various operating systems to configure the system's Domain Name System (DNS) resolver. The file is a plain-text file usually created by the network administrator or by applications that manage the configuration tasks of the system.

The file resolv.conf typically contains directives that specify the default search domains; used for completing a given query name to a fully qualified domain name when no domain suffix is supplied. It also contains a list of IP addresses of nameservers available for resolution. An example file is:

search example.com local.lan
nameserver 127.0.0.1
nameserver 172.16.1.254
nameserver 172.16.2.254
nameserver 192.168.137.2

/etc/hosts

Almost every operating system that communicates via TCP/IP, has a file called the HOSTS file. This file allows you to create mappings between domain names and IP addresses. On most operating system the default configuration is that any mappings contained in the Hosts file overrides any information that would be retrieved from a DNS server. In fact, if there is a mapping for a domain name in a hosts file, then your computer will not even bother querying the DNS servers that are authoritative for that domain, but instead read the IP address directly from the HOSTS file.

It is also important to note that when you add entries to your HOSTS file they automatically start working. There is no need to reboot or enter another command to start using the entries in the HOSTS file.

The hosts file contains lines of text consisting of an IP address in the first text field followed by one or more host names. Each field is separated by white space (blanks or tabulation characters). Comment lines may be included; they are indicated by a hash character (#) in the first position of such lines. Entirely blank lines in the file are ignored. For example, a typical hosts file may contain the following:

# This is an example of the hosts file

127.0.0.1  localhost loopback
::1        localhost

There are a variety reasons as to why you would want to use a HOSTS file

  1. Network Testing - I manage a large Internet Data center and many times we need to set up test machines or set up development servers for our customers applications.
  2. Potentially Increase Browsing Speed - By adding IP address mappings to sites you use a lot into your HOSTS file you can potentially increase the speed of your browsing. This is because your computer no longer has to ask a DNS server for the IP address and wait to receive it's response, but instead can quickly query a local file.
  3. Block Spyware/Ad Networks - By adding large lists of known ad network and Spyware sites into your hosts file and mapping the domain names to the 127.0.0.1, you will block these sites from being able to be reached.
  4. Bypass the firewall. Some domains are blocked by the Great Fire Wall, but not the ip, so we can use the hosts file to access these domains.

Ref
What is the use of /etc/hosts?
The /etc/hosts file
The Hosts File and what it can do for you