Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Jan 1998 14:18:09 -0500
From:      Aaron Jeremias Luz <aaron@homenet>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   iijppp dynamic ip suggestions
Message-ID:  <19980111141809.28521@homenet>

next in thread | raw e-mail | index | archive | help
I use iijppp at home to give a small network of machines access to
the Internet.  My provider assigns me a dynamic IP address, and my
local network is a simple TCP/IP 10base2 ethernet.  I run named
with authority for my private domain and a forwarders list pointing
to my ISP's nameservers.

I've had two problems with iijppp.  First, TCP FIN and RST packets
would cause a dial-up.  A one line hack fixed this, and could be
made more general.  Second, the initial packets sent out over the
modem would come back (if they came back at all) with the make-believe
IP address given to "set ifaddr".  An uglier hack fixed this by
aliasing (masquerading) only after the link had gone up and setting
up an IP alias (second address) for the tunnel device.

Of course, the initial packets are important since I run named and
not every connection with the Internet starts with a (remote) name
lookup.  I hope you will find my modifications interesting.  However,
let me be the first to admit they are the result of a quick, ugly
hacking session -- but perhaps they can inspire better solutions.

I have attached a diff against the directory /usr/src/usr.sbin/ppp
of 2.2.5-RELEASE.  (Sorry this is not a more current version, but
the changes are so minimal you can commit them by hand.)  I have also
included necessary parts of ppp.conf, ppp.linkup, and ppp.linkdown.

Aaron Luz
aaron@csh.rit.edu

diff -c ../ppp/ip.c ./ip.c
*** ../ppp/ip.c	Sat Jan 10 10:41:55 1998
--- ./ip.c	Sun Jan 11 10:15:37 1998
***************
*** 172,177 ****
--- 172,183 ----
  	      case IPPROTO_TCP:
  		cproto = P_TCP;
  		th = (struct tcphdr *) ptop;
+ 
+ 		/* XXX Hack: never allow TCP with FIN or RST flags set to */
+ 		/*     cause a dialup.					  */
+ 		if (direction == FL_DIAL && (th->th_flags & (TH_FIN | TH_RST)))
+ 			return (A_DENY);
+ 
  		sport = ntohs(th->th_sport);
  		dport = ntohs(th->th_dport);
  		estab = (th->th_flags & TH_ACK);
***************
*** 471,476 ****
--- 477,485 ----
      if (queue->top) {
        bp = Dequeue(queue);
        if (bp) {
+ 	if (mode & MODE_ALIAS) {
+ 	  VarPacketAliasOut(MBUF_CTOP(bp), MAX_MRU);
+ 	}
  	cnt = plength(bp);
  	SendPppFrame(bp);
  	RestartIdleTimer();
diff -c ../ppp/main.c ./main.c
*** ../ppp/main.c	Sat Jan 10 17:21:17 1998
--- ./main.c	Sun Jan 11 10:22:02 1998
***************
*** 311,316 ****
--- 311,317 ----
  {
    if (VarTerm) {
      fprintf(VarTerm, "User Process PPP. Written by Toshiharu OHNO.\n");
+     fprintf(VarTerm, "WARNING: hacked version.\n");
      fflush(VarTerm);
    }
  }
***************
*** 982,988 ****
  	      VarPacketAliasIn(rbuff, sizeof rbuff);
  	      n = ntohs(((struct ip *) rbuff)->ip_len);
  	    }
! 	    bp = mballoc(n, MB_IPIN);
  	    bcopy(rbuff, MBUF_CTOP(bp), n);
  	    IpInput(bp);
  	    LogPrintf(LogDEBUG, "Looped back packet addressed to myself\n");
--- 983,990 ----
  	      VarPacketAliasIn(rbuff, sizeof rbuff);
  	      n = ntohs(((struct ip *) rbuff)->ip_len);
  	    }
! 	    /* XXX MAX_MRU was n, wasteful but makes aliasing easier. */
! 	    bp = mballoc(MAX_MRU, MB_IPIN);
  	    bcopy(rbuff, MBUF_CTOP(bp), n);
  	    IpInput(bp);
  	    LogPrintf(LogDEBUG, "Looped back packet addressed to myself\n");
***************
*** 999,1008 ****
        if (LcpFsm.state <= ST_CLOSED && (mode & MODE_AUTO)) {
  	pri = PacketCheck(rbuff, n, FL_DIAL);
  	if (pri >= 0) {
- 	  if (mode & MODE_ALIAS) {
- 	    VarPacketAliasOut(rbuff, sizeof rbuff);
- 	    n = ntohs(((struct ip *) rbuff)->ip_len);
- 	  }
  	  IpEnqueue(pri, rbuff, n);
  	  dial_up = TRUE;	/* XXX */
  	}
--- 1001,1006 ----
***************
*** 1010,1019 ****
        }
        pri = PacketCheck(rbuff, n, FL_OUT);
        if (pri >= 0) {
- 	if (mode & MODE_ALIAS) {
- 	  VarPacketAliasOut(rbuff, sizeof rbuff);
- 	  n = ntohs(((struct ip *) rbuff)->ip_len);
- 	}
  	IpEnqueue(pri, rbuff, n);
        }
      }
--- 1008,1013 ----

from /etc/ppp/ppp.conf
myisp:
 set phone ...
 set login ...
 load fake-route

fake-route:
 set ifaddr 10.0.0.1/0 10.0.0.2/0
 delete ALL
 add 0 0 10.0.0.2
 set openmode active

/etc/ppp/ppp.linkup
myisp:
 delete ALL
 add 0 0 HISADDR
 shell ifconfig tun0 10.0.0.1 HISADDR alias

/etc/ppp/ppp.linkdown
myisp:
 shell ifconfig tun0 10.0.0.1 delete
 load fake-route



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