Building a Class Network

The examples below refer to comp243f03 network.
* Building the servers:

  (1) Enable remote administration using rsh: add each other's name in
      /root/.rhosts. E.g.,

      nee root

  (2) Create directory structure. E.g., on nee:

      /usr/classnet/home                -- home directories
                   /home/root/bin-admin -- admin tools, e.g., do_all_machines
                                           (see below) 
                             /pkgs      -- packages
                             /surge     -- surge files
      /playpen                          -- extra disk space

  (3) Export directories by adding entries in /etc/exports, e.g., in nee:

/usr/classnet -maproot=0 foghorn100 taz10 brain10 daffy100 bugs100 stone30 speedy30 pepe100 ophelia20 porky20
/playpen -maproot=0 foghorn100 taz10 brain10 daffy100 bugs100 stone30 speedy30 pepe100 ophelia20 porky20

      Make sure the line 

      nfs_server_enable="YES"

      is present in /etc/rc.conf.

  (4) The server should mount each other, e.g., in nee, create mount points
      (i.e., directories)

      /net/nee100/classnet
      /net/nee100/playpen
  
      and add the following lines to /etc/mount.local

/sbin/mount -t nfs -o rw foghorn100:/usr/classnet /net/foghorn100/classnet &
/sbin/mount -t nfs -o rw foghorn100:/playpen /net/foghorn100/playpen & 

  (5) Add routing rules for each subnetwork. Since the routing rules must
      be reloaded after each reboot, add then to /etc/rc.local, e.g., in nee:

# static routing for class net
route add -net 192.168.10.0 192.168.100.5
route add -net 192.168.20.0 192.168.100.36
route add -net 192.168.30.0 192.168.100.37

      where the final IP corresponds to the subnetwork router.

* Building a subnetwork
  
  (0) Configure the physical topology and then the network
      interface. You can find out the names of the interfaces
      and their speed using ifconfig -a (e.g. xl0, fxp0).
      Configure the ip address and network mask in /etc/rc.conf.
      For example, attaching pepe (last byte 36) to 192.168.20.0/24
      requires
      
      ifconfig_fxp0="inet 192.168.20.36 netmask 255.255.255.0"
      
      In addition, configure the default router and the hostname,
      also in /etc/rc.conf.

  (1) Add server(s) to /root/.rhosts:

      nee root
      foghorn root

      This enables remote administration from these two hosts.
      Test with "rsh marina100 hostname". IMPORTANT: all the hosts
      names in .rhosts must be resolvable using /etc/hosts (otherwise,
      rsh command to this host will hang while the host tries to
      contact unreachable DNS servers).

  (2) Add DNS resolution for local names in /etc/hosts. This
      includes the servers:

      192.168.100.47 nee100.cs.unc.edu nee100

      and hosts in the subnetworks:

      192.168.10.134 lorenzo10.cs.unc.edu lorenzo10

  (3) Add firewall rules to enable local traffic in
      /etc/rc.firewall (create a new section, e.g., classnet):
      
      add pass ip from 192.168.10.0/24 to any

      and change the default firewall configuration in
      /etc/rc.conf (firewall_type="classnet")

  (4) Enable local routing by adding gateway_enable="yes" in
      /etc/rc.conf for the local router (e.g., daffy100). 

  (5) Enable routing from the server to the hosts in the private
      network. For example, enable routing in nee (see 4),
      add a routing rule in /etc/rc.local of the form:

      route add -net 192.168.100.0 192.168.100.5

      (route local network through daffy100) 

      Note that daffy-5 does not need routing rules, since it only
      has to get packet to 192.168.10 and 192.168.100, and those
      are directly attached networks.  

      You can always check the static routing rules using netstat -r.

  (6) Enable NFS: in each NFS client, add mount commands in
      /etc/mount.local, e.g., (in brain10)

      /sbin/mount -t nfs -o rw nee100:/usr/classnet /net/nee100/classnet &

      (make sure the mount point directory exists), and add
      each NFS client to /etc/exports in the file servers, e.g.,
      in nee add
 
      /usr/classnet -maproot=1 brain10

      (restart the daemon with kill -SIGHUP `cat /var/run/mountd.pid`
       -- in bash, only -HUP in other shells) 
 
  (7) Install extra delays for each local network. This requires a
      a kernel with the dummnynet, and the following entries /etc/rc.local,
      (in daffy100)

# Artifical RTTs for 192.168.10.0/24
sysctl -w net.inet.ip.dummynet.hash_size=256
ipfw pipe 1 config delay 0ms mask all
ipfw add 10 pipe 1 ip from 192.168.10.0/24 to any out
sysctl -w net.inet.ip.dummynet.delay_cdf_p1=20
sysctl -w net.inet.ip.dummynet.delay_cdf_p2=200

      This is only needed in the routers/apache servers in the example
      shown above.

* Remote administration:

  (1) Our script is "do_all_machines" particularly useful for maintaining
      groups of machine. Copy the it from /usr/dirt/bin (don't forget
      to also copy dirt.pl and update the path in do_all_machine). Examples:

  ./do_all_machines -n -t -M all_192.168.list -cmd "rsh MACHINE hostname" 
  
  (use -n to avoid NFS check and -t to continue after the task fails in
   on of the machines).

  ./do_all_machines -n -t -M all_192.168.list -cmd "rsh MACHINE 'shutdown -r now &'" 

  ./do_all_machines -n -t -M all_192.168.list -cmd "rcp mount.local root@MACHINE:/etc"

* Apache and SURGE:

  (1) Install apache using pkg_add, e.g., 

pkg_add /net/nee100/classnet/home/root/pkgs/apache-1.3.24_7.tgz

      and copy SURGE files into /usr/local/www/data

tar -zxf /net/nee100/classnet/home/root/surge/surge_data.tar.gz

   (2) Install surge, e.g.,

cp -R /net/nee100/classnet/home/root/surge/generator /usr/local/surge
chmod 777 /usr/local/surge
 
       (don't forget chmod!)


Félix Hernández-Campos
Last modified: Sun Sep 28 20:13:37 Eastern Daylight Time 2003