resolv.conf changing over time 

Newsgroups:  gmane.linux.debian.user
Date:        Wed, 24 May 2006 17:54:04 +0200
> My crabby ISP is so screwed up, that I need 4 or more seconds to resolve
> google.com, and many time I would get "domain name not found" right in
> the middling while I'm looking my yahoo email. It's no use complaining
> to my ISP. I just installed the DNS cache server.
>
> The problem is it won't be long before my etc/resolv.conf, which points
> to my own DNS cache server, get changed. How can I solve that? Is there
> any hooks like ipup(?) for dial up?

You might want to look at the "resolvconf" package.

George Borisov

resolv.conf changing over time 

> The problem is it won't be long before my etc/resolv.conf, which points
> to my own DNS cache server, get changed. How can I solve that? Is there
> any hooks like ipup(?) for dial up?

if you use pump for a dhcp client, there are a couple of ways to tell it not to update the DNS resolver configuration (add '-d' in the init script, or even better put 'device eth0 { nodns }' in pump.conf)

if you don't use pump, you can either look for a similar feature in your dhcp client or simply 'apt-get install pump' (it will replace your current client)

Joris

resolv.conf changing over time 

> if you use pump for a dhcp client, there are a couple of ways to tell it
> not to update the DNS resolver configuration (add '-d' in the init
> script, or even better put 'device eth0 { nodns }' in pump.conf)

And if you are using dhclient you can add the following line to your /etc/dhclient.conf

supersede domain-name-servers 127.0.0.1;

"man dhclient.conf" for more details

Ken Wahl

dhclient local customizations 

dhclient-script provides the enter and exit hooks for local customizations to to override the default behaviour of the client in creating a /etc/resolv.conf file.

After all processing has completed, /etc/dhclient-script checks for the presence of the /etc/dhclient-exit-hooks script, which if present is invoked using the '.' command.

set domain name 

Newsgroups:  gmane.linux.debian.user
Date:        Fri, 06 Oct 2006 18:16:28 +0100
> > Also, eveytime I change resolv.conf it gets changed back to something
> > else...
>
> I think he means that his resolv.conf gets overwritten by the information
> provided by the dhcp server as discussed here (with solution):
>
> http://forums.debian.net/viewtopic.php?t=7239[]

in short, he probably needs in /etc/dhclient.conf

prepend domain-name-servers 127.0.0.1;

and perhaps also

supersede domain-name "mydomain.tld";

they should already be in there commented out, just needs to uncomment and put in correct data.

Richard Lyons

cmd:dhcpcd 

Info from slackware 

AUTHORS
      v.<1.3
      Yoichi Hariguchi <yoichi@fore.com>
      v.1.3
      Sergei Viznyuk <sv@phystech.com>

Usage 

dhcpcd -k
ifconfig eth0 down
dhcpcd

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
131.162.160.0   *               255.255.248.0   U     0      0        0 eth0
loopback        *               255.0.0.0       U     0      0        0 lo
default         vlan-160.acadia 0.0.0.0         UG    0      0        0 eth0

Usage explanation 

All info about DHCP setting 
/etc/dhcpc/dhcpcd-eth0.info
Stop the DHCP lease 
dhcpcd -k              # in /sbin
Stop the eth0 card 
ifconfig eth0 down
start the DHCP client daemon & 
dhcpcd
Renew lease 

?

Manual configure eth0 
ifconfig eth0 131.162.131.132 broadcast 131.162.167.255 netmask 255.255.248.0
Show route table 
route          # in /sbin
Add route table 
route add default gw 131.162.128.1 netmask 0.0.0.0 metric 1
route add -net 131.162.160.0  netmask '255.255.248.0' dev eth0
route add -net default gw 131.162.160.1 netmask '0.0.0.0' dev eth0

dpkg:dhcpcd 

dhcpcd 

dhcpcd - a wrapper for the DHCP client daemon.

In Debian, the DHCP client daemon binary is called dhcpcd-bin and it is invoked via a wrapper called dhcpcd. Dhcpcd is normally invoked by ifup(8) but ifup only allows the setting of a limited number of dhcpcd command line flags. The dhcpcd wrapper reads extra flags from /etc/dhcpc/config and then invokes dhcpcd-bin(8) It also adds the hostname as an argument to the command line, unless it is already set by ifup or /etc/dhcpc/config or SET_HOSTNAME is configured. In that case there is no point in sending the old hostname with the DHCP request when it will be overridden by a new name supplied by the DHCP server.

Version: 1:2.0.3-1

dhcpcd-bin 

dhcpcd     [-dknoprBCDHNRSTY]     [-t <timeout>]    [-c <ExecFilePath>]
     [-h <hostname>]        [-i <vendorClassID>]        [-I <clientID>]
     [-l <leasetime>]  [-s [ipaddr]]  [-F none|ptr|both] [-G [gateway]]
     [-w <windowsize>]          [-L <ConfigDir>]          [-e <etcDir>]
     [-m <routeMetric>] [interface]

It gets the host information (IP address, netmask, broadcast address, etc.) from a DHCP server and configures the network interface of the machine on which it is running. It also tries to renew the lease time according to RFC2131.

V: dhcpcd 2.0, 20 July 2005

dhcpcd.exe 

/etc/dhcpc/dhcpcd.exe
       script  file,  which dhcpcd will try to execute whenever it con-
       figures or brings down the interface.  The  path  to  this  exe-
       cutable  script  can  be changed with -c  <ExecFilePath> option.
       Dhcpcd passes 3 parameters to dhcpcd.exe script:
dhcpcd.exe <HostInfoFilePath> <up|down|new> [-d]
       The first parameter <HostInfoFilePath> is path to dhcpcd-<inter-
       face>.info  file. The word <interface> is actually replaced with
       interface name dhcpcd is attached to, e.g.  "eth0".  The  second
       parameter  values  <up|down|new>  mean  the  interface  has been
       brought up with the same IP address as before  ("up"),  or  with
       the  new  IP  address ("new"), or the interface has been brought
       down ("down"). Parameter -d is passed in a case dhcpcd has  been
       started with -d debug flag.

documented on: 2006.07.22

dpkg:dhcp-client 

Basic Info 

Info 

DHCP Client

Description 

This is a split off from the dhcp package and contains the DHCP client tools.

Tag: interface::commandline, network::configuration, protocol::dhcp, protocol::ip, role::sw:client, use::configuring

Releases 

This is the DHCP client from version 2 of the Internet Software Consortium DHCP package. For more information visit the ISC web site at http://www.isc.org.

The full list of Slackware /etc/rc.d/rc.inet1 file 

Not use the default DHCP setting 
head -5 /etc/dhcpc/dhcpcd-eth0.info

and put it into /etc/rc.d/rc.inet1, then set

DHCP="no"            # Use DHCP ("yes" or "no")

The will achieve the same result of a serious Q&A of command 'netconfig'.

Use the default DHCP setting 

set

DHCP="yes"
File source 
Example: File rc.inet1
#! /bin/sh
# rc.inet1      This shell script boots up the base INET system.

HOSTNAME=`cat /etc/HOSTNAME`

# Attach the loopback device.
/sbin/ifconfig lo 127.0.0.1
/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo

# IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the
# eth0 interface.

# Edit these values to set up a static IP address:
IPADDR="131.162.131.132"        # REPLACE with YOUR IP address!
NETMASK="255.255.248.0" # REPLACE with YOUR netmask!
NETWORK="131.162.128.0" # REPLACE with YOUR network address!
BROADCAST="131.162.135.255"     # REPLACE with YOUR broadcast address, if you
                        # have one. If not, leave blank and edit below.
GATEWAY="131.162.128.1" # REPLACE with YOUR gateway address!

# To use DHCP instead of a static IP, set this value to "yes":
DHCP="yes"            # Use DHCP ("yes" or "no")

# OK, time to set up the interface:
if [ "$DHCP" = "yes" ]; then # use DHCP to set everything up:
  echo "Attempting to configure eth0 by contacting a DHCP server..."
  /sbin/dhcpcd
elif [ ! "$IPADDR" = "127.0.0.1" ]; then # set up IP statically:
  # Set up the ethernet card:
  echo "Configuring eth0 as ${IPADDR}..."
  /sbin/ifconfig eth0 ${IPADDR} broadcast ${BROADCAST} netmask ${NETMASK}

  # If that didn't succeed, give the system administrator some hints:
  if [ ! $? = 0 ]; then
    cat << EOF
Your ethernet card was not initialized properly.  Here are some reasons why this
may have happened, and the solutions:
1. Your kernel does not contain support for your card.  Including all the
   network drivers in a Linux kernel can make it too large to even boot, and
   sometimes including extra drivers can cause system hangs.  To support your
   ethernet, either edit /etc/rc.d/rc.modules to load the support at boottime,
   or compile and install a kernel that contains support.
EOF
  fi

  # Older kernel versions need this to set up the eth0 routing table:
  KVERSION=`uname -r | cut -f 1,2 -d .`
  if [ "$KVERSION" = "1.0" -o "$KVERSION" = "1.1" \
   -o "$KVERSION" = "1.2" -o "$KVERSION" = "2.0" -o "$KVERSION" = "" ]; then
    /sbin/route add -net ${NETWORK} netmask ${NETMASK} eth0
  fi

  # If there is a gateway defined, then set it up:
  if [ ! "$GATEWAY" = "" ]; then
    /sbin/route add default gw ${GATEWAY} netmask 0.0.0.0 metric 1
  fi
fi

# End of rc.inet1

Other dhcp server/client 

cmd:pump 

Usage 

Acquire Lease 
pump
Acquire Info 
% pump -s
Device eth0
        IP: 192.168.2.12
        Netmask: 255.255.255.0
        Broadcast: 192.168.2.255
        Network: 192.168.2.0
        Boot server 192.168.2.1
        Next server 0.0.0.0
        Gateway: 192.168.2.1
        Gateways: 192.168.2.1
        Hostname: cxmr.dyndns.org
        Domain: no-domain-set.bellcanada
        Nameservers: 192.168.2.1 192.168.2.1
        Renewal time: Tue Oct 31 22:44:11 2006
        Expiration time: Wed Nov  1 00:14:11 2006
% pump -i eth0 --status
Device eth0
        IP: 192.168.2.12
        Netmask: 255.255.255.0
        Broadcast: 192.168.2.255
        Network: 192.168.2.0
        Boot server 192.168.2.1
        Next server 0.0.0.0
        Gateway: 192.168.2.1
        Gateways: 192.168.2.1
        Hostname: cxmr.dyndns.org
        Domain: no-domain-set.bellcanada
        Nameservers: 192.168.2.1 192.168.2.1
        Renewal time: Tue Oct 31 22:44:11 2006
        Expiration time: Wed Nov  1 00:14:11 2006
$ pump
pump: must be run as root

Help 

NAME
      pump - configure network interface via BOOTP or DHCP protocol
DESCRIPTION
      pump  is a daemon that manages network interfaces that are controlled
       by either the DHCP or BOOTP protocol.
Once pump is managing an interface, you can run  pump  to  query  the
status of that interface.  For example,
/sbin/pump -i eth0 --status
will print the current status of device eth0.
COMMAND-LINE OPTIONS
      switch   long option           description
      -h       --hostname=hostname   Hostname to request
      -i       --interface=iface     Interface to configure (normally eth0)
      -k       --kill                Kill daemon (and disable all interfaces)
      -r       --release             Release interface
      -R       --renew               Force immediate lease renewal
      -s       --status              Display interface status
      -?       --help                Show this help message
               --usage               Display brief usage message
LOGGING
      Pump  logs  a  good  deal of information to syslog, much of it at the
      DEBUG level. If you're having trouble, it's a good idea  to  turn  up
      syslog's logging level.

cmd:dhclient 

Renew lease 
killall dhclient
# -- otherwise there would be multi-instances of dhclient which will
     cause trouble. (two lease in /var/state/dhcp/dhclient.leases)
ifconfig eth0 down
dhclient

or,

dhclient eth0
ifconfig
Acquire Info for RH8.0 
$ cat /var/lib/dhcp/dhclient.leases
lease {
  interface "eth0";
  fixed-address 192.168.0.255;
  option subnet-mask 255.255.255.0;
  option time-offset -18000;
  option routers 192.168.0.1;
  option dhcp-lease-time 21600;
  option dhcp-message-type 5;
  option domain-name-servers 192.168.0.1;
  option dhcp-server-identifier 192.168.0.100;
  option nis-domain "domain.org";
  option domain-name "domain.org";
  renew 5 2002/12/13 06:44:25;
  rebind 5 2002/12/13 09:07:10;
  expire 5 2002/12/13 09:52:10;
}
Acquire Info for RH6.2 
cat /var/state/dhcp/dhclient.leases

documented on: 2000.10.15 Sun 00:41:40

DHCP problem?? 

Newsgroups: comp.os.linux.misc,comp.os.linux.redhat,linux.redhat.misc

> - Can anyone tell me where is the DHCP configuration file? I tried to look
> for /etc/dhcpc and /etc/dhcpcd

Are you using dhcpcd or pump or something else? There isn't really any DHCP configuration file, as that would defeat the whole point of DHCP, which is that you don't have to go configure every machine! The way DHCP works is basically that the client shouts onto the Ethernet:

Help!  I need an address!
  And the server replies:  How about this one?
Sure, that one sounds good.  May I have it?
  Here you go, and here's the other stuff that goes with it.

As you can see, there isn't much configuring that _could_ be done on the client side. If you just want more verbose logging, you can use "dhcpcd -d", which produces debugging output. If you're using pump, I don't know, but the man page should be able to tell you.

JDW

DHCP problem?? 

$ grep DHCP_HOSTNAME /etc/sysconfig/network-scripts/ifup
    if [ -n "${DHCP_HOSTNAME}" ]; then
       PUMPARGS="-h ${DHCP_HOSTNAME}"
       DHCPCDARGS="-h ${DHCP_HOSTNAME}"

change pump to dhcpcd 

Rh7.2 

/etc/sysconfig/network-scripts/ifup in Rh7.2 will default load dhcpcd first. Pump is used only when dhcpcd is not installed.

Rh6.2 

Newsgroups: comp.os.linux.misc
> tell me how to switch PUMP to DHCPCD?

It's as simple as un-installing pump and installing dhcpcd. The ifup script will try both.

Tony Lill

Rh6.2 

Take a look at the book "Linux Firewalls" by Robert L. Ziegler, New Riders, page 425 - 432. He gives a good description of switching from pump to dhcpcd.

I just switched to dhcpcd myself from pump because I'm using an internet firewall with web services (Apache, wu-ftp, etc, etc) with a dynamic IP (rather than static) IP address. As a consequence I need dhcpcd to run the firewall script again any time the ip address changes.

Some things to consider:

  1. "pump" is used in Redhat 6.0 and beyond. "dhcpcd" was used in pre-6.0.

  2. dhcpcd is included in the Redhat distribution even though it's not used, (ie: an RPM).

  3. To install I would first manually create /etc/dhcpc, then install. Next I would place any scripts for dhcpcd to run in /etc/dhcpc/dhcpcd-eth0.exe, (this is not an executable, it is a bash script you create from scratch! Replace "eth0" with whatever your interface is, though I never had any luck with "ppp0".

  4. Now type /sbin/dhcpcd and you will get an ip address assigned. Type "/sbin/dhcpcd -k" to shut down dhcpcd. It will leave your eth0 down, so when done you have to do "ifup eth0".

  5. Apparently the current version of dhcpcd doesn't run the /etc/dhcpc/dhcpcd-eth0.exe bash script if the new IP address assignment is the same as the old IP address. Older versions of dhcpcd ran the script even when the IP didn't change.

  6. In Redhat 6.0 (and possibly other versions) where pump is used you may want to modify /sbin/ifup to use dhcpcd rather than pump, for example

    if [ -n "$PUMP" ]; then
        echo -n "Determining IP information for $DEVICE..."
        if /sbin/dhcpcd; then
            /etc/rc.d/init.d/myfirewallbashscript
        else
            echo "failed."
            exit 1
        fi
    else ...

Tom

Rh6.2 

Rh6.2 

rpm -e pump
rpm -q pump
psbn pump
rpm -ivv dhcpcd-1.3.18pl3-1.i386.rpm
rpm -qil dhcpcd
dhcpcd
ifconfig
head -5 /etc/dhcpc/dhcpcd-eth0.info
cat /etc/resolv.conf

AOK.

DHCP/Static Network Configuaration 

netconfig 
$ type netconfig
netconfig is /usr/sbin/netconfig
$ file /usr/sbin/netconfig
/usr/sbin/netconfig: ELF 32-bit LSB executable, Intel 80386, version 1, dynamically linked (uses shared libs), stripped

Netconfig will ask a series of questions of network configuration(no card).

history:netconf 

netconf is actually a symbolic link to linuxconf, which limits linuxconf for only network configuaration task (card & env).

$ type netconf
netconf is /sbin/netconf
$ ls /sbin/netconf
lrwxrwxrwx    1 root     root  /sbin/netconf -> linuxconf*