Annotation of src/etc/netstart, Revision 1.33
1.1 deraadt 1: #!/bin/sh -
2: #
1.33 ! deraadt 3: # $OpenBSD: netstart,v 1.32 1997/11/29 02:03:43 kstailey 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: #
18: if [ X"${ipfilter}" = X"YES" -a -f "${ipfilter_rules}" ]; then
19: echo 'configuring IP filter'
20: ipf -Fa -f ${ipfilter_rules} -E
21: else
22: ipfilter=NO
1.1 deraadt 23: fi
1.17 kstailey 24:
25: # Configure NAT before configuring network interfaces
26: #
1.32 kstailey 27: if [ "${nat}" = "YES" -a "${ipfilter}" = "YES" -a -f "${nat_rules}" ]; then
1.17 kstailey 28: echo 'configuring NAT'
29: ipnat -CF -f ${nat_rules}
30: else
31: nat=NO
1.33 ! deraadt 32: fi
! 33:
! 34: if [ X"${iproute}" = X"YES" ]; then
! 35: sysctl -w net.inet.ip.forwarding=1
1.17 kstailey 36: fi
37:
1.24 kstailey 38: # set the address for the loopback interface
39: ifconfig lo0 inet localhost
1.1 deraadt 40:
1.24 kstailey 41: # use loopback, not the wire
1.28 millert 42: route add -host $hostname localhost
1.24 kstailey 43: route add -net 127 127.0.0.1 -reject
44:
45: # configure all of the non-loopback interfaces which we know about.
1.1 deraadt 46: # do this by reading /etc/hostname.* files, where * is the name
47: # of a given interface.
48: #
49: # these files are formatted like the following, but with no # at the
50: # beginning of the line
51: #
52: # addr_family hostname netmask broadcast_addr options
53: # dest dest_addr
54: #
55: # addr_family is the address family of the interface, generally inet
56: # hostname is the host name that belongs to the interface, in /etc/hosts.
57: # netmask is the network mask for the interface.
58: # broadcast_addr is the broadcast address for the interface
59: # options are misc. options to ifconfig for the interface.
60: #
61: # dest is simply the string "dest" (no quotes, though) if the interface
62: # has a "destination" (i.e. it's a point-to-point link, like SLIP).
63: # dest_addr is the hostname of the other end of the link, in /etc/hosts
64: #
65: # the only required contents of the file are the addr_family field
66: # and the hostname.
67:
68: (
69: tmp="$IFS"
70: IFS="$IFS."
71: set -- `echo /etc/hostname*`
72: IFS=$tmp
73: unset tmp
74:
75: while [ $# -ge 2 ] ; do
76: shift # get rid of "hostname"
77: (
78: read af name mask bcaddr extras
1.31 deraadt 79: read dt dtaddr
1.1 deraadt 80:
81: if [ ! -n "$name" ]; then
82: echo "/etc/hostname.$1: invalid network configuration file"
83: exit
84: fi
85:
86: cmd="ifconfig $1 $af $name "
87: if [ "${dt}" = "dest" ]; then cmd="$cmd $dtaddr"; fi
88: if [ -n "$mask" ]; then cmd="$cmd netmask $mask"; fi
89: if [ -n "$bcaddr" -a "X$bcaddr" != "XNONE" ]; then
90: cmd="$cmd broadcast $bcaddr";
91: fi
92: cmd="$cmd $extras"
93:
94: $cmd
95: ) < /etc/hostname.$1
96: shift
97: done
98: )
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.
102: if [ -f /etc/mygate ]; then
1.28 millert 103: route add -host default `cat /etc/mygate`
1.14 deraadt 104: fi
1.6 tholo 105:
106: # default multicast route
1.9 deraadt 107: route add -net 224.0.0.0 -interface $hostname
1.1 deraadt 108: