*BSD News Article 96654


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!howland.erols.net!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!newsfeed.nacamar.de!fu-berlin.de!irz401!orion.sax.de!uriah.heep!news
From: j@uriah.heep.sax.de (J Wunsch)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: User PPP
Date: 1 Jun 1997 09:52:37 GMT
Organization: Private BSD site, Dresden
Lines: 84
Message-ID: <5mrgp5$40h@uriah.heep.sax.de>
References: <Pine.BSI.3.95.970519184616.5906A-100000@gold.interlog.com>
  <5lrpgk$l8u@ui-gate.utell.co.uk> <EAHuFC.xy@sphynx.fdn.fr>
  <86g1vgfj10.fsf@bitbox.follo.net> <EAL93r.BH@sphynx.fdn.fr>
  <86yb97tiis.fsf@bitbox.follo.net>
Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch)
NNTP-Posting-Host: localhost.heep.sax.de
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Newsreader: knews 0.9.6
X-Phone: +49-351-2012 669
X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F  93 21 E0 7D F9 12 D6 4E
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:42002

Eivind Eklund <perhaps@yes.no> wrote:

> I've worked with netmasks from 22 to 29 bits - 8 addresses, 64
> addresses, 256 addresses, 1024 addresses.  They exists, and just about
> everything support it.  A lot of things don't support non-continuous
> netmasks, though - FreeBSD included.

Non-conti*g*uous, btw.  FreeBSD supports non-contiguous netmasks.

First, let's create an interface with a weird netmask:

uriah # ifconfig vx0 192.168.1.1 netmask 0xffffff0f

Install a rejected default route, so `route get' will output something
useful below.

uriah # route -n add 0.0.0.0 127.0.0.1 -reject
add net 0.0.0.0: gateway 127.0.0.1

This is clearly a case for the default route:

uriah # route -n get 192.168.2.1
   route to: 192.168.2.1
destination: default
       mask: default
    gateway: 127.0.0.1
  interface: lo0
      flags: <UP,GATEWAY,REJECT,DONE,STATIC,PRCLONING>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
   49152     49152         0         0         0         0     16384         0 

...correct.  Now, all hosts with 192.168.1.X are in our network if
(X & 0x0f) == 1.  .17 should be there:

uriah # route -n get 192.168.1.17
   route to: 192.168.1.17
destination: 192.168.1.1
       mask: 255.255.255.15
  interface: vx0
      flags: <UP,DONE,CLONING>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0         0         0         0      1500       -67 

...as well as .33:

uriah # route -n get 192.168.1.33
   route to: 192.168.1.33
destination: 192.168.1.1
       mask: 255.255.255.15
  interface: vx0
      flags: <UP,DONE,CLONING>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0         0         0         0      1500       -83 

...but .34 is another network ((34 & 0x0f) == 2):

uriah # route -n get 192.168.1.34
   route to: 192.168.1.34
destination: default
       mask: default
    gateway: 127.0.0.1
  interface: lo0
      flags: <UP,GATEWAY,REJECT,DONE,STATIC,PRCLONING>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
   49152     49152         0         0         0         0     16384         0 

As you can see, it works well.  Of course, the netstat -r output looks a
little funny now:

uriah # netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags     Refs     Use     Netif Expire
default            127.0.0.1          UGRSc       0        0       lo0
127.0.0.1          127.0.0.1          UH          6     5313       lo0
192.168.1.1&0xffffff0f link#1             UC          0        0 

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)