[BACK]Return to netstart CVS log [TXT][DIR] Up to [local] / src / etc

Annotation of src/etc/netstart, Revision 1.9

1.1       deraadt     1: #!/bin/sh -
                      2: #
1.9     ! deraadt     3: #      $OpenBSD: netstart,v 1.8 1996/06/18 15:30:02 deraadt Exp $
1.1       deraadt     4:
                      5: # set these to "NO" to turn them off.  otherwise, they're used as flags
                      6: routed_flags=-q
1.3       deraadt     7: mrouted_flags=NO       # for 'normal' use: mrouted_flags=""
1.1       deraadt     8: rarpd_flags=NO         # for 'normal' use: rarpd_flags="-a"
                      9: bootparamd_flags=NO    # for 'normal' use: bootparamd_flags=""
                     10: rbootd_flags=NO                # for 'normal' use: rbootd_flags=""
                     11: sendmail_flags=NO      # for 'normal' use: sendmail_flags="-bd -q30m"
                     12: named_flags=NO         # for 'normal' use: named_flags=""
                     13: timed_flags=
                     14:
                     15: # set the following to "YES" to turn them on
                     16: rwhod=NO
                     17: nfs_server=NO
                     18: nfs_client=NO
                     19: gated=NO
                     20: kerberos_server=NO
                     21: amd=NO
1.4       dm         22: ipfilter=NO
1.1       deraadt    23:
                     24: # miscellaneous other flags
                     25: # only used if the appropriate server is marked YES above
                     26: gated_flags=
                     27: amd_dir=/amd                   # AMD's mount directory
                     28: amd_master=/etc/amd/master     # AMD 'master' map
1.4       dm         29: ipfilter_rules=/etc/ipf.rules  # Rules for IP packet filtering
                     30: ipmon_flags=-s                 # To disable logging, use ipmon_flags=NO
1.1       deraadt    31:
                     32: # /etc/myname contains my symbolic name
                     33: #
                     34: hostname=`cat /etc/myname`
                     35: hostname $hostname
                     36: if [ -f /etc/defaultdomain ]; then
                     37:        domainname `cat /etc/defaultdomain`
1.4       dm         38: fi
                     39:
                     40: # Configure the IP filter before configuring network interfaces
                     41: #
                     42: if [ X"${ipfilter}" = X"YES" -a -f "${ipfilter_rules}" ]; then
                     43:        echo 'configuring IP filter'
                     44:        ipf -Fa -f ${ipfilter_rules} -E
                     45: else
                     46:        ipfilter=NO
1.1       deraadt    47: fi
                     48:
                     49: # configure all of the interfaces which we know about.
                     50: # do this by reading /etc/hostname.* files, where * is the name
                     51: # of a given interface.
                     52: #
                     53: # these files are formatted like the following, but with no # at the
                     54: # beginning of the line
                     55: #
                     56: # addr_family hostname netmask broadcast_addr options
                     57: # dest dest_addr
                     58: #
                     59: # addr_family is the address family of the interface, generally inet
                     60: # hostname is the host name that belongs to the interface, in /etc/hosts.
                     61: # netmask is the network mask for the interface.
                     62: # broadcast_addr is the broadcast address for the interface
                     63: # options are misc. options to ifconfig for the interface.
                     64: #
                     65: # dest is simply the string "dest" (no quotes, though) if the interface
                     66: # has a "destination" (i.e. it's a point-to-point link, like SLIP).
                     67: # dest_addr is the hostname of the other end of the link, in /etc/hosts
                     68: #
                     69: # the only required contents of the file are the addr_family field
                     70: # and the hostname.
                     71:
                     72: (
                     73:     tmp="$IFS"
                     74:     IFS="$IFS."
                     75:     set -- `echo /etc/hostname*`
                     76:     IFS=$tmp
                     77:     unset tmp
                     78:
                     79:     while [ $# -ge 2 ] ; do
                     80:         shift            # get rid of "hostname"
                     81:         (
                     82:             read af name mask bcaddr extras
                     83:             read dt dtaddr
                     84:
                     85:             if [ ! -n "$name" ]; then
                     86:                 echo "/etc/hostname.$1: invalid network configuration file"
                     87:                 exit
                     88:             fi
                     89:
                     90:            cmd="ifconfig $1 $af $name "
                     91:            if [ "${dt}" = "dest" ]; then cmd="$cmd $dtaddr"; fi
                     92:            if [ -n "$mask" ]; then cmd="$cmd netmask $mask"; fi
                     93:            if [ -n "$bcaddr" -a "X$bcaddr" != "XNONE" ]; then
                     94:                cmd="$cmd broadcast $bcaddr";
                     95:            fi
                     96:            cmd="$cmd $extras"
                     97:
                     98:            $cmd
                     99:         ) < /etc/hostname.$1
                    100:         shift
                    101:     done
                    102: )
                    103:
                    104: # set the address for the loopback interface
                    105: ifconfig lo0 inet localhost
                    106:
                    107: # use loopback, not the wire
                    108: route add $hostname localhost
1.8       deraadt   109: route add -net 127 127.0.0.1 -reject
1.6       tholo     110:
                    111: # default multicast route
1.9     ! deraadt   112: route add -net 224.0.0.0 -interface $hostname
1.1       deraadt   113:
                    114: # /etc/mygate, if it exists, contains the name of my gateway host
                    115: # that name must be in /etc/hosts.
                    116: if [ -f /etc/mygate ]; then
                    117:        route add default `cat /etc/mygate`
1.2       deraadt   118: fi
                    119:
                    120: # /etc/ifaliases, if it exists, contains the names of additional IP
                    121: # addresses for each interface. It is formatted as a series of lines
                    122: # that contain
1.7       deraadt   123: #      interface address netmask
1.2       deraadt   124: if [ -f /etc/ifaliases ]; then
                    125: (
1.7       deraadt   126:        # delete comments and blank lines
                    127:        set -- `sed -e 's/#.*$//' /etc/ifaliases | grep -v '^$'`
1.2       deraadt   128:
1.7       deraadt   129:        while [ $# -ge 3 ] ; do
                    130:                ifconfig $1 inet alias $2 netmask $3
                    131:                route add $2 localhost
                    132:                shift 3
1.2       deraadt   133:        done
                    134: )
1.1       deraadt   135: fi