Subject: IP over IP broken?
To: None <>
From: Rick Byers <>
List: current-users
Date: 05/19/1999 01:10:00
Hi, I'm trying to setup a IP over IP tunnel using the ipip device.  I'm
having problem that I believe to be related to the "toggling of the last
bit of the IP address" as mentioned in the BUGS section of ipip(4).

I'm trying to establish a tunnel between two local networks connected to
the internet behind a NetBSD-1.4 box doing NAT. 

Here is a picture of my network:   My PC (NetBSD-current)
     |    Gateway machine, NetBSD-1.4 running NAT     
 Rogers@Home network
     |     Gateway machine, NetBSD-1.4 running NAT
     |     Destination machine.

I would like to be able to establish connections FROM to  So, on my gateway machine ( I did:

ifconfig ipip0 netmask 0xffffffff up
route add -net 192.168.78

and the mirror image on the other gateway machine.
ifconfig -a and netstat -nr output look good.  However, if I try to ping
from to my packets go off into never-never
land.  It appears as if the gateway machine is actually trying to send the
packets to (intead of .29). 

wormhole:/usr/home/rick# tcpdump -s 128 -e -vv -n proto 4
tcpdump: listening on le0
21:34:44.173209 2:7:1:16:7:2f 0:e0:29:16:68:1d 0800 118: > > icmp: echo request (ttl 254,
id 11407) (ttl 254, id 30335)

This looked good to me, until I checked the MAC addresses:

arp -n -a
? ( at 00:e0:14:bd:b7:08         
? ( at 02:07:01:16:07:2f permanent
? ( at 00:e0:29:16:68:1d
? ( at 00:4f:4c:04:99:22

The encapsulated packet is supposed to be going to (and that
is what's in the IP dst), but the link level header is directing it to the
ethernet address of!! (no, that's not my gateway,

I expect this is a problem in ipip_compute_route()
(sys/netinet/ip_ipip.c).  Specifically:

         * Toggle the last bit on the address so our interface won't
         * match.
         * XXX What we want here is a flag to exclude picking routes
         * XXX with this interface.
        ((struct sockaddr_in *)&ro->ro_dst)->sin_addr.s_addr =
            htonl(ntohl(sc->sc_dst.s_addr) ^ 1);


         * Now change it back, or else ip_ouput() will just drop
         * the route and find the one for the ipip interface.
        ((struct sockaddr_in *)&ro->ro_dst)->sin_addr = sc->sc_dst;

So I expect either the toggling actually changes sc->sc_dst (so that it
never gets undone), or the rtalloc() command leaves something around.  I
looked at it for a while, but it's getting late and I wasn't able to make
any progress.

I have the exact same problem if I use the gre driver instead of the ipip
driver.  Which one should I be using anyway?

Any ideas on how to fix this problem (in NetBSD-1.4)?


Rick Byers                       University of Waterloo, Computer Science