old-www/LDP/LG/issue95/tag/5.html

296 lines
12 KiB
HTML

<!--startcut ==============================================-->
<!-- *** BEGIN HTML header *** -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD>
<META NAME="generator" CONTENT="lgazmail v1.4G.k">
<TITLE>The Answer Gang 95: Simple DNS solution with Red Hat 9</TITLE>
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
ALINK="#FF0000">
<!-- *** END HTML header *** -->
<!--endcut ==============================================-->
<!-- begin 5 -->
<H3 align="left"><img src="../../gx/dennis/qbubble.gif"
height="50" width="60" alt="(?) " border="0"
>Simple DNS solution with Red Hat 9</H3>
<p><strong>From - E J -
</strong></p>
<p></strong></p>
<p align="right"><strong>Answered By: Faber Fedor, Kapil Hari Paranjape, Jim Dennis
</strong></p>
<pre><strong>[root@localhost sbin]# ./ifconfig eth0 address
192.168.1.103
address: Unknown host
ifconfig: `--help' gives usage information.
[root@localhost sbin]#
</strong></pre>
<P><STRONG>
Please note I believe I need a DNS server (solution)
for my home <A HREF="http://www.redhat.com/">Red Hat</A> Network. Is there a simple DNS
solution I can establish?
</STRONG></P>
<P><STRONG>
I have checked some books - this does not seem to be
as simple as editing <TT>/etc/host.conf</TT>
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Faber]
Okay, so? You mis-typed a command. I do it all the time.
</blockQuote>
<font color="#660000"><blockquote><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas] Hopefully though, Faber doesn't mis-type too often while as "root"
</blockquote></font>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Faber]
What are you attempting to do? What is "address"? Is it supposed to be
an actual (IP) address? Is it an enviromant variable? What?
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [JimD]
I'm going out on a limb here to guess that this was supposed
to be rendered as:
</blockQuote>
<blockquote><pre>[root@localhost sbin]# ./ifconfig eth0 address 192.168.1.103
address: Unknown host
ifconfig: `--help' gives usage information.
[root@localhost sbin]#
</pre></blockquote>
<blockQuote>
... cut and pasted from a root shell session.
</blockQuote>
<blockQuote>
You wanted to type:
</blockQuote>
<blockquote><pre>[root@localhost sbin]# ./ifconfig eth0 192.168.1.103
</pre></blockquote>
<blockQuote>
... which would seet your eth0 address to 192.168.1.103
That would also implicitly set the netmask to 255.255.255.0 and
the broadcast address to 192.168.1.255. That netmask is the
default for the traditional "Class C" network address blocks
(all of 192.*.*.* among many others). The broadcast address is
then calculated by masking off the high order bit using the netmask
then setting that many bits to "on" (1). Then replacing the bits
at the end original addresses with the broadcast.
</blockQuote>
<blockQuote>
In other words you can often just specify the address without spelling
out the other settings. You only have to specify the others when
you're network isn't following the "Classical" parameters and defaults.
</blockQuote>
<blockQuote>
The problem with your command was that the word "address" was parsed
as the <EM>name</EM> of a host. The ifconfig command then tried to resolve
that name into an IP address (presumably via your <TT>/etc/hosts</TT> file,
then DNS --- though that depends on the settings in your nsswitch.conf)
</blockQuote>
<blockQuote>
Here's a couple of other examples of ifconfig commands:
</blockQuote>
<blockquote><pre># ifconfig eth1 10.0.1.10 netmask 255.255.255.0 broadcast 10.0.1.255 up
# ifconfig eth2 123.45.67.8 netmask 255.255.255.224 broadcast 123.45.67.31
</pre></blockquote>
<blockQuote>
Notice that the address is the one argument that is not prefixed by
a literal/keyword or label. It's usually the first argument, though
it might work even if you don't follow that convention.
</blockQuote>
<blockQuote>
Notice in my last example that we're using a smaller netmask, like
the kind you might get from an ISP that was only giving you a block
of 30 IP addresses. Long ago I wrote and article on "subnetting and
routing" which is still one of the most popular article in LG/TAG
history. I've been told it's used for some college TCP/IP fundamentals
classes.
</blockQuote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
Please note I believe I need a DNS server (solution)
for my home Red Hat Network. Is there a simple DNS
solution I can establish?
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [JimD]
Perhaps you will need a DNS or other directory service (NIS or LDAP).
However, in this case you just needed to look at the error and read
the usage section of the --help and/or man page a little more
carefully.
</blockQuote>
<blockQuote>
It also helps to think about the problem your trying to solve.
You're trying to configure a network interface. DNS and other
directory services need to use that interface (or <EM>some</EM> interface)
in order to resolve names into IP addresses. That would create a
chicken &amp; egg problem if the ifconfig command truly depended on
the name resolution. It would be unreasonable to assume that everyone
has to run a network directory services daemon on localhost --- and
you'd still need it to ifconfig the lo (localhost/loopback) interface.
</blockQuote>
<blockQuote>
(That line of reasoning should alert you to the fact that their
was something wrong with your premise --- that your conclusion was
dubious).
</blockQuote>
<blockQuote>
You almost certainly don't want to play with your <TT>/etc/host.conf</TT>
</blockQuote>
<blockQuote>
However, it could be as simple (in this case) as editing
/etc/hosts
</blockQuote>
<blockQuote>
If you'd put an entry "192.168.1.103 address" as a line in
your etc host file then your command would have <EM>almost</EM> worked.
It would complain about extra arguments --- the lookup/resolution
of the <EM>hostname</EM> "address" would have succeeded (assuming you have
a normal <TT>/etc/nsswitch.conf</TT>).
</blockQuote>
<blockQuote>
If you put more reasonable address/name pairs in <TT>/etc/hosts</TT> and you
securely distribute those (rsync -e ssh) to your other machines
--- you have a working system of host name resolution without DNS
NIS or LDAP.
</blockQuote>
<blockQuote>
<TT>/etc/nsswitch.conf</TT> defines the list of services and methods used by
glibc (C library) functions to resolve names (hostnames, network
names, netgroup, user, group, and service) into numbers (IP addresses,
lists of hosts, UIDs, GIDs, and TCP/UDP port numbers). Almost all of
the programs on your system are dynamically linked against glibc
(a.k.a. just libc). glibc implements resolvers that read
<TT>/etc/nsswitch.conf</TT> and dynamically load <TT>/lib/libnss*</TT> modules as listed.
</blockQuote>
<blockQuote>
Such run-time linkage uses the <TT> dlopen()</TT> interface. There are two
types of dynamic linking in Linux. Link/compile time, such as the
way that almost all programs are linked to libc and many programs are
linked to libm (the C math functions library). These are listed by
the ldd (ld dump --- ld is a non-intuitive mnemonic for "linker").
Run-time linking is done via the <TT> dlopen()</TT> interface. Any time a
program must read a configuration file, command line option or
environment setting, or any other run-time source of information
to determine which modules to load --- it uses <TT> dlopen()</TT> Obviously
this would be true of the NSS modules since any program that uses
any of these name services it has to read <TT>/etc/nsswitch.conf</TT>
to determine which libraries to load (NSS == "name services selection"
or "name services subsystem" or something like that).
</blockQuote>
<blockQuote>
<TT>dlopen()</TT> (run-time dynamic linking) is also used by PAM, for PERL and
Python binary modules, <A HREF="http://www.apache.org/">Apache</A> modules, and XFree86 version 4 and later.
You can think of these as being a way to implement some object oriented
features in normal C programs. The primary uses of these modules are
to extend and/or modularize the functionality of a base binary program.
</blockQuote>
<blockQuote>
Thus you can get a custom authentication module (say one of those
little electronic credit card PIN tokens) and drop it into your system;
add one configuration line and all of the PAM linked programs have been
extended to use this module. All without recompiling anything.
</blockQuote>
<blockQuote>
As another example you can install XFree86, as compiled by your
distribution vendor, and you can install a driver module for your
video card from some third party (perhaps even the manufacturer of
the card).
</blockQuote>
<blockQuote>
I realize I've delved deeply under the hood here --- into details
that you won't understand at first reading (and probably don't
care about).
</blockQuote>
<blockQuote>
My point is that you don't need to run a <EM>network</EM> name service.
Most of the NSS linked programs check local config files <TT>/etc/hosts</TT>,
<TT>/etc/passwd</TT>, <TT>/etc/groups</TT>, <TT>/etc/services</TT>, etc. first. They then check
with other services as listed in the <TT>/etc/nsswitch.conf.</TT> <TT>/etc/host.conf</TT>
is still used, but its usage is somewhat superceded by <TT>/etc/nsswitch.conf.</TT>
</blockQuote>
<blockQuote>
(I'd love to see a good explanation of why we have both nsswitch.conf
and host.conf on modern systems --- something at a higher level than
their respective man pages).
</blockQuote>
<!-- end 5 -->
<!-- *** BEGIN copyright *** -->
<hr>
<CENTER><SMALL><STRONG>
<h5>
<br>Copyright &copy; 2003
<br>Copying license <A HREF="">http://www.linuxgazette.com/copying.html</A>
<BR>Published in Issue 95 of <i>Linux Gazette</i>, October 2003</H5>
</STRONG></SMALL></CENTER>
<!-- *** END copyright *** -->
<SMALL><CENTER><H6 ALIGN="center">HTML script maintained by
<A HREF="mailto:star@starshine.org">Heather Stern</a> of
Starshine Technical Services,
<A HREF="http://www.starshine.org/">http://www.starshine.org/</A>
</H6></SMALL></CENTER>
<HR>
<!--startcut ======================================================= -->
<P> <hr>
<!-- begin tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::-->
<p align="center">
<table width="100%" border="0"><tr>
<td align="right" valign="center"
><IMG ALT="" SRC="../../gx/navbar/left.jpg"
WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="middle" border="0"
><A HREF="../index.html"
><IMG SRC="../../gx/navbar/toc.jpg" align="middle"
ALT="[ Table Of Contents ]" border="0"></A
><A HREF="../lg_answer.html"
><IMG SRC="../../gx/dennis/answertoc.jpg" align="middle"
ALT="[ Answer Guy Current Index ]" border="0"></A></td>
<td align="center" valign="center"><A HREF="../lg_answer.html#greeting"><img align="middle"
src="../../gx/dennis/smily.gif" alt="greetings" border="0"></A> &nbsp;
<A HREF="../../tag/bios.html">Meet&nbsp;the&nbsp;Gang</A> &nbsp;
<A HREF="1.html">1</A> &nbsp;
<A HREF="2.html">2</A> &nbsp;
<A HREF="3.html">3</A> &nbsp;
<A HREF="4.html">4</A> &nbsp;
<A HREF="5.html">5</A> &nbsp;
<A HREF="6.html">6</A> &nbsp;
<A HREF="7.html">7</A> &nbsp;
<A HREF="8.html">8</A>
</td>
<td align="left" valign="center"><A HREF="../../tag/kb.html"
><IMG SRC="../../gx/dennis/answerpast.jpg" align="middle"
ALT="[ Index of Past Answers ]" border="0"></A
><IMG ALT="" SRC="../../gx/navbar/right.jpg" align="middle"
WIDTH="14" HEIGHT="45" BORDER="0"></td></tr></table>
</p>
<!-- end tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::::-->
<!--endcut ========================================================= -->
<P> <hr>
<!--startcut ======================================================= -->
<CENTER>
<!-- *** BEGIN navbar *** -->
<!-- *** END navbar *** -->
</CENTER>
</p>
<!--endcut ========================================================= -->
<!--startcut ======================================================= -->
</BODY></HTML>
<!--endcut ========================================================= -->