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

Annotation of src/etc/netstart, Revision 1.44

1.1       deraadt     1: #!/bin/sh -
                      2: #
1.44    ! deraadt     3: #      $OpenBSD: netstart,v 1.43 1998/09/18 18:42:10 deraadt Exp $
1.1       deraadt     4:
                      5: # /etc/myname contains my symbolic name
                      6: #
                      7: hostname=`cat /etc/myname`
                      8: hostname $hostname
                      9: if [ -f /etc/defaultdomain ]; then
                     10:        domainname `cat /etc/defaultdomain`
1.4       dm         11: fi
1.30      deraadt    12:
                     13: # pick up option configuration
                     14: . /etc/rc.conf
1.4       dm         15:
                     16: # Configure the IP filter before configuring network interfaces
                     17: if [ X"${ipfilter}" = X"YES" -a -f "${ipfilter_rules}" ]; then
                     18:        echo 'configuring IP filter'
                     19:        ipf -Fa -f ${ipfilter_rules} -E
                     20: else
                     21:        ipfilter=NO
1.1       deraadt    22: fi
1.17      kstailey   23:
1.24      kstailey   24: # set the address for the loopback interface
                     25: ifconfig lo0 inet localhost
1.1       deraadt    26:
1.24      kstailey   27: # use loopback, not the wire
1.38      deraadt    28: route -n add -host $hostname localhost
                     29: route -n add -net 127 127.0.0.1 -reject
1.24      kstailey   30:
                     31: # configure all of the non-loopback interfaces which we know about.
1.1       deraadt    32: # do this by reading /etc/hostname.* files, where * is the name
                     33: # of a given interface.
                     34: #
                     35: # these files are formatted like the following, but with no # at the
                     36: # beginning of the line
                     37: #
                     38: # addr_family hostname netmask broadcast_addr options
                     39: # dest dest_addr
                     40: #
1.42      marc       41: # OR
                     42: #
                     43: # dhcp
                     44: #
1.1       deraadt    45: # addr_family is the address family of the interface, generally inet
                     46: # hostname is the host name that belongs to the interface, in /etc/hosts.
                     47: # netmask is the network mask for the interface.
                     48: # broadcast_addr is the broadcast address for the interface
                     49: # options are misc. options to ifconfig for the interface.
                     50: #
                     51: # dest is simply the string "dest" (no quotes, though) if the interface
                     52: # has a "destination" (i.e. it's a point-to-point link, like SLIP).
                     53: # dest_addr is the hostname of the other end of the link, in /etc/hosts
                     54: #
1.42      marc       55: # dhcp is simply the string "dhcp" (no quotes, though) if the interface
                     56: # is to be configured using DHCP.  See dhclient(8) and dhclient.conf(5)
                     57: # for details.
                     58: #
1.1       deraadt    59: # the only required contents of the file are the addr_family field
                     60: # and the hostname.
                     61:
1.42      marc       62: (
1.1       deraadt    63:     tmp="$IFS"
                     64:     IFS="$IFS."
                     65:     set -- `echo /etc/hostname*`
                     66:     IFS=$tmp
                     67:     unset tmp
                     68:
                     69:     while [ $# -ge 2 ] ; do
                     70:         shift            # get rid of "hostname"
                     71:         (
                     72:             read af name mask bcaddr extras
1.31      deraadt    73:             read dt dtaddr
1.1       deraadt    74:
1.42      marc       75:            # check to see if device should be configure by dhcp
                     76:            if [ "$af" = "dhcp" ]; then
1.43      deraadt    77:                ifconfig $1 $extras down
1.42      marc       78:                cmd="/sbin/dhclient $1";
                     79:            else
                     80:                if [ ! -n "$name" ]; then
                     81:                    echo "/etc/hostname.$1: invalid network configuration file"
                     82:                    exit
                     83:                fi
                     84:
                     85:                cmd="ifconfig $1 $af $name "
                     86:                if [ "${dt}" = "dest" ]; then cmd="$cmd $dtaddr"; fi
                     87:                if [ -n "$mask" ]; then cmd="$cmd netmask $mask"; fi
                     88:                if [ -n "$bcaddr" -a "X$bcaddr" != "XNONE" ]; then
                     89:                    cmd="$cmd broadcast $bcaddr";
                     90:                fi
                     91:                cmd="$cmd $extras";
1.1       deraadt    92:            fi
                     93:
                     94:            $cmd
                     95:         ) < /etc/hostname.$1
                     96:         shift
                     97:     done
1.42      marc       98: )
1.1       deraadt    99:
1.14      deraadt   100: # /etc/mygate, if it exists, contains the name of my gateway host
                    101: # that name must be in /etc/hosts.
1.42      marc      102: if [ -f /etc/mygate ]; then
1.38      deraadt   103:        route -n add -host default `cat /etc/mygate`
1.40      downsj    104:
                    105:        # default multicast route for hosts with a gateway
                    106:        route -n add -net 224.0.0.0 -interface default
1.42      marc      107: else
1.40      downsj    108:        # default multicast route
                    109:        route -n add -net 224.0.0.0 -interface $hostname
1.14      deraadt   110: fi
1.44    ! deraadt   111:
        !           112: # Configure NAT after configuring network interfaces
        !           113: if [ "${ipnat}" = "YES" -a "${ipfilter}" = "YES" -a -f "${ipnat_rules}" ]; then
        !           114:        echo 'configuring NAT'
        !           115:        ipnat -CF -f ${ipnat_rules}
        !           116: else
        !           117:        ipnat=NO
        !           118: fi
        !           119: