[comp.unix.wizards] Getting 4.2bsd to work with subnets

d9015t@colman.newcastle.ac.uk (J.P.O'Broin) (02/22/91)

We have recently been given a 2nd hand WhiteChappel UNIX machine (MG-1)
(a British UNIX machine - company now out of business). 
This machine runs 4.2nix, a 4.2bsd copy, and I am trying to link it up
to the Ethernet. We run a class B network (ie. xxx.yyy.zzz.station id), 
and hence we're subnetted. 
I understand that 4.2bsd doesn't understand subnets (and hence there is
no obvious way of setting netmask using ifconfig), but our network is
fairly static, and we want to link to a specific gatway. Can I setup 
the machine for this.

We have tried to do this by setting up /etc/hosts to know about the gateway,
and whilst the machine transmits correctly to the ethernet (well, it shows up
on etherfind on our SUN's as expected), it doesn't seem to understand what
is coming back to it, and hence won't connect. Is this because it doesn't
understand the returning Ethernet address of the (subnetted) machine we
are trying to talk to?

Any help greatfully received.
Jason.
(email : J.P.O'Broin@uk.ac.durham - drop the ' if it causes problems)

rbj@uunet.UU.NET (Root Boy Jim) (02/26/91)

In article <1991Feb22.115215.26645@newcastle.ac.uk> d9015t@colman.newcastle.ac.uk (J.P.O'Broin) writes:
>This machine runs 4.2nix, a 4.2bsd copy, and I am trying to link it up
>to the Ethernet. We run a class B network (ie. xxx.yyy.zzz.station id), 
>and hence we're subnetted. 
>I understand that 4.2bsd doesn't understand subnets (and hence there is
>no obvious way of setting netmask using ifconfig), but our network is
>fairly static, and we want to link to a specific gatway. Can I setup 
>the machine for this.

I had to do this once. The solution is to pretend that all
non-Class-A addresses (and you really only care about one,
localhost 127.0.0.1) are Class C addresses.

You need to modify netinet/in.c. In it you will find routines which
(staticly) rip apart (or build) addresses based on their class.

Get a copy of the 4.2 source file from someone (I don't have it, but
it's freely redistributable), and disassemble the routines that seem to
use these macros. Then patch them to do the right thing.

Here is an excerpt from the Tahoe distribution. The 4.2 code
will not have the loop looking for subnets at the bottom.

My changes are conditional on the symbol FAKESUBNET.

/*
 * Return the network number from an internet address.
 */
u_long
in_netof(in)
        struct in_addr in;
{
        register u_long i = ntohl(in.s_addr);
        register u_long net;
        register struct in_ifaddr *ia;

        if (IN_CLASSA(i))
                net = i & IN_CLASSA_NET;
#ifndef FAKESUBNET				/*FAKESUBNET*/
        else if (IN_CLASSB(i))
                net = i & IN_CLASSB_NET;
        else if (IN_CLASSC(i))
                net = i & IN_CLASSC_NET;
        else
                return (0);
#else						/*FAKESUBNET*/
	else					/*FAKESUBNET*/
                net = i & IN_CLASSC_NET;	/*FAKESUBNET*/
#endif						/*FAKESUBNET*/

        /*
         * Check whether network is a subnet;
         * if so, return subnet number.
         */
        for (ia = in_ifaddr; ia; ia = ia->ia_next)
                if (net == ia->ia_net)
                        return (i & ia->ia_subnetmask);
        return (net);
}


-- 
		[rbj@uunet 1] stty sane
		unknown mode: sane