#!/bin/sh - # # $OpenBSD: netstart,v 1.43 1998/09/18 18:42:10 deraadt Exp $ # /etc/myname contains my symbolic name # hostname=`cat /etc/myname` hostname $hostname if [ -f /etc/defaultdomain ]; then domainname `cat /etc/defaultdomain` fi # pick up option configuration . /etc/rc.conf # Configure the IP filter before configuring network interfaces # if [ X"${ipfilter}" = X"YES" -a -f "${ipfilter_rules}" ]; then echo 'configuring IP filter' ipf -Fa -f ${ipfilter_rules} -E else ipfilter=NO fi # Configure NAT before configuring network interfaces # if [ "${ipnat}" = "YES" -a "${ipfilter}" = "YES" -a -f "${ipnat_rules}" ]; then echo 'configuring NAT' ipnat -CF -f ${ipnat_rules} else ipnat=NO fi # set the address for the loopback interface ifconfig lo0 inet localhost # use loopback, not the wire route -n add -host $hostname localhost route -n add -net 127 127.0.0.1 -reject # configure all of the non-loopback interfaces which we know about. # do this by reading /etc/hostname.* files, where * is the name # of a given interface. # # these files are formatted like the following, but with no # at the # beginning of the line # # addr_family hostname netmask broadcast_addr options # dest dest_addr # # OR # # dhcp # # addr_family is the address family of the interface, generally inet # hostname is the host name that belongs to the interface, in /etc/hosts. # netmask is the network mask for the interface. # broadcast_addr is the broadcast address for the interface # options are misc. options to ifconfig for the interface. # # dest is simply the string "dest" (no quotes, though) if the interface # has a "destination" (i.e. it's a point-to-point link, like SLIP). # dest_addr is the hostname of the other end of the link, in /etc/hosts # # dhcp is simply the string "dhcp" (no quotes, though) if the interface # is to be configured using DHCP. See dhclient(8) and dhclient.conf(5) # for details. # # the only required contents of the file are the addr_family field # and the hostname. ( tmp="$IFS" IFS="$IFS." set -- `echo /etc/hostname*` IFS=$tmp unset tmp while [ $# -ge 2 ] ; do shift # get rid of "hostname" ( read af name mask bcaddr extras read dt dtaddr # check to see if device should be configure by dhcp if [ "$af" = "dhcp" ]; then ifconfig $1 $extras down cmd="/sbin/dhclient $1"; else if [ ! -n "$name" ]; then echo "/etc/hostname.$1: invalid network configuration file" exit fi cmd="ifconfig $1 $af $name " if [ "${dt}" = "dest" ]; then cmd="$cmd $dtaddr"; fi if [ -n "$mask" ]; then cmd="$cmd netmask $mask"; fi if [ -n "$bcaddr" -a "X$bcaddr" != "XNONE" ]; then cmd="$cmd broadcast $bcaddr"; fi cmd="$cmd $extras"; fi $cmd ) < /etc/hostname.$1 shift done ) # /etc/mygate, if it exists, contains the name of my gateway host # that name must be in /etc/hosts. if [ -f /etc/mygate ]; then route -n add -host default `cat /etc/mygate` # default multicast route for hosts with a gateway route -n add -net 224.0.0.0 -interface default else # default multicast route route -n add -net 224.0.0.0 -interface $hostname fi