Subject: aha! another pppd question
To: NetBSD/mac68k Mailing List <port-mac68k@NetBSD.ORG>
From: SamMaEl <rimsky@teleport.com>
List: port-mac68k
Date: 02/28/1998 21:53:26
	Ok, I think I know what is wrong with the ppp connection I have
been trying to get. I was visiting a friend today and we tried dialing up
my machine like 6 or 7 times and got the connection as before, were able
to ping, got the ip address and were still able to get our name from the
name server. BUT, I got home and turned on my monitor and it hit me...
well, first off I was using proxyarp for 192.168.2.1, which there is no
device associated with the 192.168.2 network so that is a justifiable
error, but I also got the IPFilter initialization, with pass all (like it
should) and logging disabled (I haven't gotten to compile another kernel
yet with logging enabled.), and IPFilter complains about already being
initialized. pppd is executing the ip-up script! Is there any way I can
KEEP it from doing this??

	Or, just as good... I guess I could think of a way to make it not
execute the ipfilter stuff if it is going to be run as a server. Here is
the ipfilter related part of the script. It is the one Bob Nestor gave me
to help get ipnat going ;-) So, maybe I should blame him ;-)


if checkyesno ipfilter; then
   host=`hostname`

   subnet=`/usr/sbin/nslookup $host | /usr/bin/tail -n 2 | /usr/bin/grep
Address | /usr/bin/awk '{print $2}'` # this on same line as above

   class_octet=`echo ${subnet} | /usr/bin/awk -F. '{print $1}'`

   if [ ${class_octet} -lt 128 ]; then
       sz=24
   elif [ ${class_octet} -le 192 ]; then
       sz=16
   elif [ ${class_octet} -le 224 ]; then
       sz=8
   else
       #  Illegal Class D network, but what the hell
       sz=1
   fi

   /sbin/ipf -E
   /usr/sbin/ipnat -F
   /usr/sbin/ipnat -C
   /sbin/ipf -E
   rm -f /tmp/${1}
   echo "map $1 $subnet/${sz} -> $4/32 portmap tcp/udp 10000:65000" >/tmp/${1}
   echo "map $1 $subnet/${sz} -> $4/32" >>/tmp/${1}
   /usr/sbin/ipnat -f /tmp/${1}
fi 


	Basically, it is extracting the IP address of the host, to
determine the 'sz' variable, then it is mapping the packets recieved from
ppp0 ( $1 which is the ppp client) at the IP address/netmask bits to
another IP address and sending it to /tmp/ppp0, where ipnat then uses
/tmp/ppp0 to startup from.

	Is there a way to get around starting ipnat from the ip-up script?
Because it is ip-up that is causing the funky pppd behavior. I will try it
later tonight when I can use the other phone line with my laptop and see
if it works (for now I will just do a gross hack, like renaming the ip-up
script in the script which I use to startup the pppd server, then rename
it to ip-up after the pppd server is started up. It should work, but is
there any better way to do this? Any help appreciated, thanks!

	Now, if I could just figure out what's wrong with my dialup
shell... I'm going to try using dtrcts on the modem line. I figured out
how to reset the settings on my modem and save the configuration at least!
;-) at&w... then atz will reset it to the default setting (which I just
have it as at&f1)

	Thanks in advance, especially to Bill for being so patient ;-)
	
	Ryan

-----
HELO... my name is rewt... you have SIGKILLed my father... prepare to vi!