ALINK="#FF0000">

(?) Simple DNS solution with Red Hat 9

From - E J -

Answered By: Faber Fedor, Kapil Hari Paranjape, Jim Dennis

[root@localhost sbin]# ./ifconfig eth0 address
192.168.1.103
address: Unknown host
ifconfig: `--help' gives usage information.
[root@localhost sbin]#

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?

I have checked some books - this does not seem to be as simple as editing /etc/host.conf

(!) [Faber] Okay, so? You mis-typed a command. I do it all the time.
(!) [Thomas] Hopefully though, Faber doesn't mis-type too often while as "root"
(!) [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?
(!) [JimD] I'm going out on a limb here to guess that this was supposed to be rendered as:
[root@localhost sbin]# ./ifconfig eth0 address 192.168.1.103
address: Unknown host
ifconfig: `--help' gives usage information.
[root@localhost sbin]#
... cut and pasted from a root shell session.
You wanted to type:
[root@localhost sbin]# ./ifconfig eth0 192.168.1.103
... 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.
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.
The problem with your command was that the word "address" was parsed as the name of a host. The ifconfig command then tried to resolve that name into an IP address (presumably via your /etc/hosts file, then DNS --- though that depends on the settings in your nsswitch.conf)
Here's a couple of other examples of ifconfig commands:
# 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
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.
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.

(?) 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?

(!) [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.
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 some interface) in order to resolve names into IP addresses. That would create a chicken & 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.
(That line of reasoning should alert you to the fact that their was something wrong with your premise --- that your conclusion was dubious).
You almost certainly don't want to play with your /etc/host.conf
However, it could be as simple (in this case) as editing /etc/hosts
If you'd put an entry "192.168.1.103 address" as a line in your etc host file then your command would have almost worked. It would complain about extra arguments --- the lookup/resolution of the hostname "address" would have succeeded (assuming you have a normal /etc/nsswitch.conf).
If you put more reasonable address/name pairs in /etc/hosts 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.
/etc/nsswitch.conf 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 /etc/nsswitch.conf and dynamically load /lib/libnss* modules as listed.
Such run-time linkage uses the dlopen() 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 dlopen() 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 dlopen() Obviously this would be true of the NSS modules since any program that uses any of these name services it has to read /etc/nsswitch.conf to determine which libraries to load (NSS == "name services selection" or "name services subsystem" or something like that).
dlopen() (run-time dynamic linking) is also used by PAM, for PERL and Python binary modules, Apache 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.
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.
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).
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).
My point is that you don't need to run a network name service. Most of the NSS linked programs check local config files /etc/hosts, /etc/passwd, /etc/groups, /etc/services, etc. first. They then check with other services as listed in the /etc/nsswitch.conf. /etc/host.conf is still used, but its usage is somewhat superceded by /etc/nsswitch.conf.
(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).


Copyright © 2003
Copying license http://www.linuxgazette.net/copying.html
Published in Issue 95 of Linux Gazette, October 2003
HTML script maintained by Heather Stern of Starshine Technical Services, http://www.starshine.org/


[ Table Of Contents ][ Answer Guy Current Index ] greetings   Meet the Gang   1   2   3   4   5   6   7   8 [ Index of Past Answers ]