*BSD News Article 99208


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!news-peer.sprintlink.net!news.sprintlink.net!Sprint!vixen.cso.uiuc.edu!saluki-news.it.siu.edu!port199.aixdialin.siu.edu!jimd
From: Jim Dutton <jimd@port199.aixdialin.siu.edu>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Hostname for box w/ part time internet connection
Date: Tue, 8 Jul 1997 02:53:28 +0000
Organization: Southern Illinois University - Carbondale
Lines: 66
Message-ID: <Pine.NEB.3.92.970708023122.256A-100000@port199.aixdialin.siu.edu>
References: <33B462A3.C9A68B9C@auburn.campus.mci.net>   <5pknen$l9c$1@the-fly.zip.com.au> <38gqp5.rqd.ln@shift.utell.net>
Reply-To: jimd@slip106.termserv.siu.edu
NNTP-Posting-Host: port199.aixdialin.siu.edu
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
In-Reply-To: <38gqp5.rqd.ln@shift.utell.net>
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:44087

On Mon, 7 Jul 1997, Brian Somers wrote:

> Date: Mon, 7 Jul 1997 11:26:11 +0100
> From: Brian Somers <brian@shift.utell.net>
> Reply-To: brian@awfulhak.org, brian@utell.co.uk
> Cc: brian@FreeBSD.org
> Newsgroups: comp.unix.bsd.freebsd.misc
> Subject: Re: Hostname for box w/ part time internet connection
>
> In article <5pknen$l9c$1@the-fly.zip.com.au>,
> 	sue@zip.com.au (Sue Blake) writes:
> > Anthony Jenkins (ajenkins@auburn.campus.mci.net) wrote:
> >> What do I set as the host name for my machine, which occasionally
> >> dials-up a connection to the internet?  Do I use the domain name of my
> >> ISP, or would that be naughty?  I have a single PC running FreeBSD
> >> (Win95 on another partition), no network (though I soon hope to delve
[...]
>
> With a "dynamic" IP number, you have to get creative.  You have to
> think of a machine name (the most tricky bit).  Think of a name that's
> not likely to be used in the real world - say ending in .lan.  Once
[...]

With the PPP IP-UP script, one does not need to be creative, inventive, or
even illegal, assuming that the ISP has defined hostnames for their
dynamically assigned IP addresses.

The following sample IP-UP script, which is designed for "our" particular
network, requires only two statements to set the proper HOSTNAME. Tres
simple.

The Sendmail stuff I did to stop any previously running Sendmail
and restart it so it would pick up the change in HOSTNAME. The SYSLOG
(logger) commands are not needed, but are nice to record what has
happened.

For situations where the hostname generation algorithm is not so simple,
just do a non-interactive NSLOOKUP on the assigned IP address, parse out
the "Name:" value, and then set the HOSTNAME. (or use some other DNS query
tool that is easier/better)

This method avoids all ambiguity and automatically sets the local HOSTNAME
to the proper value.


--- Sample /etc/ppp/ip-up script ---

#!/bin/sh
# echo "arg #4 = $4"
port=`echo $4 | sed 's/131.230.[0-9]*.//'`
`/bin/hostname port$port.aixdialin.siu.edu`
`/usr/bin/logger PPP connection as port$port.aixdialin.siu.edu`

if [ -f /var/run/sendmail.pid ]; then
   sendmail_pid=`cat /var/run/sendmail.pid | sed '/sendmail/d'`
#    echo "old sendmail.pid = $sendmail_pid"
   `kill $sendmail_pid`
fi


`/usr/sbin/sendmail -bd -q1h`
sendmail_pid=`ps -ax|grep sendmail | sed '/grep sendmail/d' | sed 's/\?.*$//'`
`/usr/bin/logger Sendmail started [$sendmail_pid]`
exit