⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hosts.html

📁 lfs3.1 从源代码构建linux。html版本。
💻 HTML
字号:
<HTML><HEAD><TITLE>Creating the /etc/hosts file</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.63"><LINKREL="HOME"TITLE="Linux From Scratch"HREF="../index.html"><LINKREL="UP"TITLE="Creating system boot scripts"HREF="../chapter07/chapter07.html"><LINKREL="PREVIOUS"TITLE="Creating the /etc/sysconfig/network file"HREF="../chapter07/network.html"><LINKREL="NEXT"TITLE="Creating the ethnet script"HREF="../chapter07/ethnet.html"></HEAD><BODYCLASS="sect1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">Linux From Scratch: Version 3.1</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="../chapter07/network.html">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 7. Creating system boot scripts</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="../chapter07/ethnet.html">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="sect1"><H1CLASS="sect1"><ANAME="ch07-hosts">7.18. Creating the /etc/hosts file</A></H1><P>If a network card is to be configured, you have to decide on theIP-address, FQDN and possible aliases for use in the /etc/hosts file. Anexample is:</P><P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><FONTCOLOR="#000000"><PRECLASS="screen">&#60;my-IP&#62; myhost.mydomain.org aliases</PRE></FONT></TD></TR></TABLE></P><P>You should made sure that the IP-address is in the private networkIP-address range. Valid ranges are:</P><P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><FONTCOLOR="#000000"><PRECLASS="screen">	Class Networks	A     10.0.0.0	B     172.16.0.0 through 172.31.0.0	C     192.168.0.0 through 192.168.255.0</PRE></FONT></TD></TR></TABLE></P><P>A valid IP address could be 192.168.1.1. A valid FQDN for this IP couldbe www.linuxfromscratch.org</P><P>If you aren't going to use a network card, you still need to come up with a FQDN. This is necessary for programs like Sendmail to operate correctly (in fact; Sendmail won't run when it can't determine the FQDN).</P><P>If a network card is not going to be configured, a new file<TTCLASS="filename">/etc/hosts</TT> is created by running:</P><P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><FONTCOLOR="#000000"><PRECLASS="screen"><TTCLASS="userinput"><B>cat &#62; /etc/hosts &#60;&#60; "EOF"</B></TT># Begin /etc/hosts (no network card version)127.0.0.1 www.mydomain.com &#60;value of HOSTNAME&#62; localhost# End /etc/hosts (no network card version)<TTCLASS="userinput"><B>EOF</B></TT></PRE></FONT></TD></TR></TABLE></P><P>If a network card is to be configured, a new file<TTCLASS="filename">/etc/hosts</TT> is created by running:</P><P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><FONTCOLOR="#000000"><PRECLASS="screen"><TTCLASS="userinput"><B>cat &#62; /etc/hosts &#60;&#60; "EOF"</B></TT># Begin /etc/hosts (network card version)127.0.0.1 localhost.localdomain localhost192.168.1.1 www.mydomain.org &#60;value of HOSTNAME&#62;# End /etc/hosts (network card version)<TTCLASS="userinput"><B>EOF</B></TT></PRE></FONT></TD></TR></TABLE></P><P>Of course, the 192.168.1.1 and www.mydomain.org have to be changedto your liking (or requirements if assigned an IP-address by a network/systemadministrator and this machine is planned to be connected to that network).</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="../chapter07/network.html">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="../index.html">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="../chapter07/ethnet.html">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Creating the /etc/sysconfig/network file</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="../chapter07/chapter07.html">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Creating the ethnet script</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -