Linux hosts include file

Linux hosts include file

NAME

hosts - static table lookup for hostnames

SYNOPSIS

DESCRIPTION

This manual page describes the format of the /etc/hosts file. This file is a simple text file that associates IP addresses with hostnames, one line per IP address. For each host a single line should be present with the following information: IP_address canonical_hostname [aliases. ] Fields of the entry are separated by any number of blanks and/or tab characters. Text from a "#" character until the end of the line is a comment, and is ignored. Host names may contain only alphanumeric characters, minus signs ("-"), and periods ("."). They must begin with an alphabetic character and end with an alphanumeric character. Optional aliases provide for name changes, alternate spellings, shorter hostnames, or generic hostnames (for example, localhost). The Berkeley Internet Name Domain (BIND) Server implements the Internet name server for UNIX systems. It augments or replaces the /etc/hosts file or hostname lookup, and frees a host from relying on /etc/hosts being up to date and complete. In modern systems, even though the host table has been superseded by DNS, it is still widely used for: bootstrapping Most systems have a small host table containing the name and address information for important hosts on the local network. This is useful when DNS is not running, for example during system bootup. NIS Sites that use NIS use the host table as input to the NIS host database. Even though NIS can be used with DNS, most NIS sites still use the host table with an entry for all local hosts as a backup. isolated nodes Very small sites that are isolated from the network use the host table instead of DNS. If the local information rarely changes, and the network is not connected to the Internet, DNS offers little advantage.

FILES

NOTES

Modifications to this file normally take effect immediately, except in cases where the file is cached by applications. Historical notes RFC 952 gave the original format for the host table, though it has since changed. Before the advent of DNS, the host table was the only way of resolving hostnames on the fledgling Internet. Indeed, this file could be created from the official host data base maintained at the Network Information Control Center (NIC), though local changes were often required to bring it up to date regarding unofficial aliases and/or unknown hosts. The NIC no longer maintains the hosts.txt files, though looking around at the time of writing (circa 2000), there are historical hosts.txt files on the WWW. I just found three, from 92, 94, and 95.

EXAMPLE

127.0.0.1 localhost 192.168.1.10 foo.mydomain.org foo 192.168.1.13 bar.mydomain.org bar 146.82.138.7 master.debian.org master 209.237.226.90 www.opensource.org

SEE ALSO

hostname(1), resolver(3), resolver(5), hostname(7), named(8) Internet RFC 952

Источник

Читайте также:  Windows efi partition linux

DESCRIPTION

This manual page describes the format of the /etc/hosts file. This file is a simple text file that associates IP addresses with hostnames, one line per IP address. For each host a single line should be present with the following information:

IP_address canonical_hostname [aliases. ]

The IP address can conform to either IPv4 or IPv6. Fields of the entry are separated by any number of blanks and/or tab characters. Text from a «#» character until the end of the line is a comment, and is ignored. Host names may contain only alphanumeric characters, minus signs («-«), and periods («.»). They must begin with an alphabetic character and end with an alphanumeric character. Optional aliases provide for name changes, alternate spellings, shorter hostnames, or generic hostnames (for example, localhost). If required, a host may have two separate entries in this file; one for each version of the Internet Protocol (IPv4 and IPv6).

The Berkeley Internet Name Domain (BIND) Server implements the Internet name server for UNIX systems. It augments or replaces the /etc/hosts file or hostname lookup, and frees a host from relying on /etc/hosts being up to date and complete.

In modern systems, even though the host table has been superseded by DNS, it is still widely used for:

bootstrapping Most systems have a small host table containing the name and address information for important hosts on the local network. This is useful when DNS is not running, for example during system bootup. NIS Sites that use NIS use the host table as input to the NIS host database. Even though NIS can be used with DNS, most NIS sites still use the host table with an entry for all local hosts as a backup. isolated nodes Very small sites that are isolated from the network use the host table instead of DNS. If the local information rarely changes, and the network is not connected to the Internet, DNS offers little advantage.

Читайте также:  Kali linux tor proxy

FILES

NOTES

Modifications to this file normally take effect immediately, except in cases where the file is cached by applications.

Historical notes

RFC 952 gave the original format for the host table, though it has since changed.

Before the advent of DNS, the host table was the only way of resolving hostnames on the fledgling Internet. Indeed, this file could be created from the official host data base maintained at the Network Information Control Center (NIC), though local changes were often required to bring it up to date regarding unofficial aliases and/or unknown hosts. The NIC no longer maintains the hosts.txt files, though looking around at the time of writing (circa 2000), there are historical hosts.txt files on the WWW. I just found three, from 92, 94, and 95.

EXAMPLES

# The following lines are desirable for IPv4 capable hosts 127.0.0.1 localhost # 127.0.1.1 is often used for the FQDN of the machine 127.0.1.1 thishost.example.org thishost 192.168.1.10 foo.example.org foo 192.168.1.13 bar.example.org bar 146.82.138.7 master.debian.org master 209.237.226.90 www.opensource.org # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters

SEE ALSO

Package name: core/man-pages Version: 6.04-1 Upstream: https://www.kernel.org/doc/man-pages/ Licenses: GPL, custom Manuals: /listing/core/man-pages/ Table of contents

Powered by archmanweb, using mandoc for the conversion of manual pages.

The website is available under the terms of the GPL-3.0 license, except for the contents of the manual pages, which have their own license specified in the corresponding Arch Linux package.

Источник

Is there a way to ‘include’ a separate file in /etc/hosts?

Is there any way to ‘include’ another file within the /etc/hosts file? Particularly I want to include a non-protected ( -rw-rw-rw ) file so I can easily edit it in something like TextMate without having to issue sudo vi /etc/hosts I’m on OS X, but as far as I know, this should be relevant in other *nix OSs.

2 Answers 2

I do not believe there is any way to include other files into a hosts file.

Would it be possible to make /etc/hosts group-writable by a group that only includes you (and any other users who need to edit it)?

Keep a hosts.base file and then write a simple script to build a complete, combined hosts file with that hosts.base file and the other files you want to include. You can cron it or execute on demand.

This is how I do it for local development. I keep a separate file for each project in a specific location, and run a script that combines the base with the project files.

Читайте также:  Mini linux для сервера

You must log in to answer this question.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.17.43535

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

How to Edit Hosts File on Linux Mint 21

Host file of Linux mint primarily maps the IP address with the domain names of the system thus making it useful for various purposes which include blocking a website and accessing any computer remotely. If you are unaware of how to edit a host file in your Linux Mint 21 and want to use it for multiple purposes, then read this guide.

What Is the Purpose of Hosts File in Linux Mint 21

Host file as mentioned above contains the IP addresses and hostname of the Linux system, but there are multiple uses of host file and those are:

  • Blocking any websites
  • Remotely accessing any Alias
  • Blocking advertisers and trackers
  • Testing an application
  • Adding or blocking specific networks

How to Edit the Hosts File in Linux Mint 21

The process of editing the host file of Linux Mint 21 is quite easy; open the host file on your Linux Mint 21 by using any terminal-based text editor, for example, nano:

Now edit the host file by entering the data like IP addresses and host names for the connections you either want to block or access.

How to Block a Website through Hosts File

When it comes to security or parental control hosts file plays a crucial role as it can be used to block unwanted websites. The process of blocking a website is mentioned below:

For instance, if you want to block YouTube then use:

Next save the file and open the website on the browser of Linux Mint to see if the site is blocked or not:

Conclusion

Host files in an operating system generally contain the IP address and the domain name of that system, there are multiple uses of a host file which can be achieved by editing it and it can be done by stating its path with nano command.

About the author

Aaliyan Javaid

I am an electrical engineer and a technical blogger. My keen interest in embedded systems has led me to write and share my knowledge about them.

Источник

Оцените статью
Adblock
detector