Click to See Complete Forum and Search --> : Hostname and resolv.conf


NVETHIS
07-14-2003, 05:25 PM
I'm running RH 9 and have a question about my hostname. It's currently being set by my cable provider because I have eth0 connected to the cable modem and set to dhcp. Well, I want my hostname to be computerxpress.d2g.com and it's kuda.spotsy.va.us.blablabla set by the cable company. I saw a script in /sbin called dhclient-script which contains:
#!/bin/bash
# Network Interface Configuration System
# Parts Copyright (c) 2002 Red Hat, Inc. all rights reserved.
#
# Based on:
# dhclient-script for Linux. Dan Halbert, March, 1997.
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.

# Notes:

# 0. This script is based on the netbsd script supplied with dhcp-970306.

# 1. ifconfig down apparently deletes all relevant routes and flushes
# the arp cache, so this doesn't need to be done explicitly.

# 2. The alias address handling here has not been tested AT ALL.
# I'm just going by the doc of modern Linux ip aliasing, which uses
# notations like eth0:0, eth0:1, for each alias.

# 3. I have to calculate the network address, and calculate the broadcast
# address if it is not supplied. This might be much more easily done
# by the dhclient C code, and passed on.

function make_resolv_conf() {
if [ -n "$new_domain_name" ] || [ -n "$new_domain_name_servers" ]; then
echo '; generated by /sbin/dhclient-script' > /etc/resolv.conf
if [ -n "$new_domain_name" ]; then
echo search $new_domain_name >> /etc/resolv.conf
fi
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf
done
fi
}
That's not all of it, but the first part, which seems to be setting my /etc/resolv.conf automatically, even when I change it myself to use the search computerxpress.d2g.com and nameserver 10.10.10254 (which is my DNS). Can someone help me fix this problem.

I want the hostname to be computerxpress.d2g.com and the /etc/resolv.conf to use my DNS (computerxpress.d2g.com, 10.10.10254) as the DNS. Thanks.

cowanrl
07-14-2003, 07:46 PM
In the file /etc/sysconfig/network-scripts/ifcfg-eth0, add the line:

PEERDNS=no

That will keep the dhcp client from using the information it gets from the dhcp server. Here's the code from /etc/sysconfig/network-scripts/ifup that checks the argument.


if [ "${PEERDNS}" = "no" ]; then
# Do not update/replace resolv.conf.
PUMPARGS="${PUMPARGS} -d"
DHCPCDARGS="${DHCPCDARGS} -R"
fi


Also, if you look farther down in the dhclient-script script, you'll see:


if [ "${PEERDNS}" != "no" ]; then
make_resolv_conf
fi


If you set PEERDNS=no, it skips the snippet of code you showed.

You can set your hostname by using a HOSTNAME= line in the /etc/sysconfig/network file and set your domain name in resolv.conf as usual.

If your hostname.domainname won't be resolvable in a DNS server anywhere, be sure to make an entry in /etc/hosts for it.