Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Jul 2000 00:36:03 -0700
From:      "Crist J. Clark" <cristjc@earthlink.net>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Having ppp(8) Set Hostname
Message-ID:  <20000714003600.A1363@pool0117.cvx34-bradley.dialup.e>
In-Reply-To: <20000711002558.D182@dialin-client.earthlink.net>; from cristjc@earthlink.net on Tue, Jul 11, 2000 at 12:25:58AM -0700
References:  <20000711002558.D182@dialin-client.earthlink.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jul 11, 2000 at 12:25:58AM -0700, Crist J. Clark wrote:
> My mail forwarding recently stopped working unless my PC has a valid
> hostname. I am trying to get ppp(8) to set the hostname
> automatically... but it turning out to be a lot harder than I
> thought. I am trying to get it done in a ppp.linkup,
> 
>   EarthLink:
>     shell /root/sethostfromip MYADDR
>     !bg /usr/sbin/sendmail -q
>     !bg su cjc -c /usr/local/bin/fetchmail
> 
> The script 'sethostfromip' does a reverse-lookup of MYADDR and tries
> to set the hostname accordingly (yeah, a quick program would probably
> be better, but I'm lazy),
> 
>   if [ expr $1 : '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' > /dev/null 2>&1 ]; then
>       IP=$1
>   else
>       IP=`ifconfig tun0 | awk '/inet/ { print $2 }'`
>   fi
> 
>   HOSTNAME=`nslookup $IP | awk '/^Name:/ { print $2 }'`
>   hostname $HOSTNAME
> 
> However, the nslookup keeps failing and neither the sendmail or
> fetchmail runs very reliably. Here the stderr output from the
> sethostfromip when I wake up the PPP connection right now,
> 
>   *** Can't find server name for address 207.217.126.81: Timed out
>   *** Can't find server name for address 207.217.77.82: Timed out
>   *** Default servers are not available
> 
> Here is the ppp.log showing those actually being run,
> 
>   Jul 11 00:22:31 <daemon.info> dialin-client ppp[58]: tun0: Command: EarthLink: shell /root/sethostfromip MYADDR 
>   Jul 11 00:23:03 <daemon.info> dialin-client ppp[58]: tun0: Command: EarthLink: !bg /usr/sbin/sendmail -q 
>   Jul 11 00:23:03 <daemon.info> dialin-client ppp[58]: tun0: Command: EarthLink: !bg su cjc -c /usr/local/bin/fetchmail 
> 
> Others must be setting new hostname when they do a dialup, right? How
> do you do it? I'm suprised it's not an option built into ppp... Or is
> it and I have not managed to find it?

I've done some more looking at this and it seems that the ppp.linkup
script is actually being run before the link is complete. Here is what
a tcpdump(8) looks like,

  00:18:55.765853 209.179.250.213.1639 > 207.217.126.81.domain:  6515+ PTR? 213.250.179.209.in-addr.arpa. (46)
  00:19:00.775350 209.179.250.213.1640 > 207.217.77.82.domain:  6515+ PTR? 213.250.179.209.in-addr.arpa. (46)
  00:19:05.785292 209.179.250.213.1641 > 207.217.126.81.domain:  6515+ PTR? 213.250.179.209.in-addr.arpa. (46)
  00:19:10.795591 209.179.250.213.1642 > 207.217.77.82.domain:  6515+ PTR? 213.250.179.209.in-addr.arpa. (46)
  00:19:15.805435 209.179.250.213.1643 > 207.217.126.81.domain:  6515+ PTR? 213.250.179.209.in-addr.arpa. (46)
  00:19:25.815606 209.179.250.213.1644 > 207.217.77.82.domain:  6515+ PTR? 213.250.179.209.in-addr.arpa. (46)
  00:19:35.825756 209.179.250.213.1645 > 207.217.126.81.domain:  6515+ PTR? 213.250.179.209.in-addr.arpa. (46)
  00:19:55.836085 209.179.250.213.1646 > 207.217.77.82.domain:  6515+ PTR? 213.250.179.209.in-addr.arpa. (46)
  00:20:16.366541 207.217.126.81.domain > 209.179.250.213.1639:  6515* 1/3/3 PTR pool0 (232)
  00:20:16.366686 209.179.250.213 > 207.217.126.81: icmp: 209.179.250.213 udp port 1639 unreachable
  00:20:16.426587 207.217.126.81.domain > 209.179.250.213.1641:  6515 1/3/3 PTR pool0 (232)
  00:20:16.426706 209.179.250.213 > 207.217.126.81: icmp: 209.179.250.213 udp port 1641 unreachable
  00:20:16.470379 209.179.250.213.1647 > 207.217.126.81.domain:  43982+ A? dialup-client.earthlink.net. (45)
  00:20:16.476011 207.217.77.82.domain > 209.179.250.213.1640:  6515* 1/3/3 PTR pool0 (232)
  00:20:16.476126 209.179.250.213 > 207.217.77.82: icmp: 209.179.250.213 udp port 1640 unreachable
  00:20:16.516512 207.217.126.81.domain > 209.179.250.213.1643:  6515 1/3/3 PTR pool0 (232)
  00:20:16.516637 209.179.250.213 > 207.217.126.81: icmp: 209.179.250.213 udp port 1643 unreachable
  00:20:16.546356 207.217.126.81.domain > 209.179.250.213.1645:  6515 1/3/3 PTR pool0 (232)
  00:20:16.546469 209.179.250.213 > 207.217.126.81: icmp: 209.179.250.213 udp port 1645 unreachable
  00:20:16.576366 207.217.77.82.domain > 209.179.250.213.1642:  6515 1/3/3 PTR pool0 (232)
  00:20:16.576473 209.179.250.213 > 207.217.77.82: icmp: 209.179.250.213 udp port 1642 unreachable
  00:20:16.606677 207.217.77.82.domain > 209.179.250.213.1644:  6515 1/3/3 PTR pool0 (232)
  00:20:16.606825 209.179.250.213 > 207.217.77.82: icmp: 209.179.250.213 udp port 1644 unreachable
  00:20:16.628886 207.217.77.82.domain > 209.179.250.213.1646:  6515 1/3/3 PTR pool0 (232)
  00:20:16.629022 209.179.250.213 > 207.217.77.82: icmp: 209.179.250.213 udp port 1646 unreachable
  00:20:16.686542 207.217.126.81.domain > 209.179.250.213.1647:  43982 NXDomain* 0/1/0 (108)
  00:20:16.688578 209.179.250.213.1648 > 207.217.126.81.domain:  43983+ A? dialup-client.earthlink.net.earthlink.net. (59)
  00:20:16.866846 207.217.126.81.domain > 209.179.250.213.1648:  43983 NXDomain* 0/1/0 (122)
  00:20:16.954405 209.179.250.213.1649 > 207.217.126.81.domain:  43984+ PTR? 213.250.179.209.in-addr.arpa. (46)
  00:20:17.136458 207.217.126.81.domain > 209.179.250.213.1649:  43984 1/3/3 PTR pool0 (232)

What you see is the reverse-lookups of the name servers seemingly
falling on deaf ears. Then about 20s after the last one goes out, all
of the replies come back... and this machine responds with port
unreachable messages. Then we see the sendmail DNS queries start to
work in the middle of all of the replies. But what has changed so it
does?

If we look at the ppp.log,

  Jul 14 00:18:55 <daemon.info> dialin-client ppp[58]: tun0: IPCP: deflink: State change Ack-Sent --> Opened 
  Jul 14 00:18:55 <daemon.info> dialin-client ppp[58]: tun0: IPCP: deflink: LayerUp. 
  Jul 14 00:18:55 <daemon.info> dialin-client ppp[58]: tun0: IPCP: myaddr 209.179.250.213 hisaddr = 207.217.148.27 
  Jul 14 00:18:55 <daemon.info> dialin-client ppp[58]: tun0: Command: EarthLink: shell /root/sethostbyip MYADDR 
  Jul 14 00:20:15 <daemon.info> dialin-client ppp[58]: tun0: Command: EarthLink: !bg /usr/sbin/sendmail -q 
  Jul 14 00:20:15 <daemon.info> dialin-client ppp[58]: tun0: Command: EarthLink: !bg su cjc -c /usr/local/bin/fetchmail 
  Jul 14 00:20:15 <daemon.info> dialin-client ppp[58]: tun0: CCP: deflink: RecvConfigReq(3) state = Ack-Rcvd 
  Jul 14 00:20:15 <daemon.info> dialin-client ppp[58]: tun0: CCP:  STAC[5]  
  Jul 14 00:20:15 <daemon.info> dialin-client ppp[58]: tun0: CCP: deflink: SendConfigRej(3) state = Ack-Rcvd 
  .
  .
  .
  Jul 14 00:20:16 <daemon.info> dialin-client ppp[58]: tun0: CCP: deflink: RecvConfigReq(12) state = Ack-Rcvd 
  Jul 14 00:20:16 <daemon.info> dialin-client ppp[58]: tun0: CCP:  STAC[5]  
  Jul 14 00:20:16 <daemon.info> dialin-client ppp[58]: tun0: CCP: deflink: SendConfigRej(12) state = Ack-Rcvd 
  Jul 14 00:20:16 <daemon.info> dialin-client ppp[58]: tun0: CCP:  STAC[5]  
  Jul 14 00:20:16 <daemon.info> dialin-client ppp[58]: tun0: CCP: deflink: RecvTerminateAck(12), dropped (expected 19) 

We see that after the ppp.linkup script is run, more work on the
connection is done by ppp! The linkup is being done before the link is
up!? The other jobs are done in the background and it looks like ppp
wins the race condition and gets the link finished before the
background programs run. I don't really know enough about the gory
details of PPP to know what that all means.

Perhaps I should add that I have filters,

   set filter in 0 deny ! 0/0 MYADDR 
   set filter in 1 permit tcp estab
   set filter in 2 permit udp src eq 53
   set filter in 3 permit icmp

But they should not be messing things up if they are properly setup by
the time ppp.linkup is called.

Anyone have a clue for me? I think what I am going to have to do is
have linkup call a script that sleeps a few second before running the
commands I want... But that seems like an ugly way to do it. Should
this be a PR?
-- 
Crist J. Clark                           cjclark@alum.mit.edu


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000714003600.A1363>