aboutsummaryrefslogtreecommitdiff
path: root/rc.d/rc.inet1
blob: 69eba7444e71c48a30b981dc1c534b1f520c6ba8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#! /bin/sh
#
# rc.inet1	This shell script boots up the base INET system.
#
# Copyright (C) 2001, 2005, 2006 Sergey Pozyakoff
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.

############### Configurable part. Tailor to suit your needs #################
# Ethernet setup:
# A list of interfaces to be configured. If a name contains colons (:) replace
# them with underscores (_).
if_list="lo eth0 eth0_0"

# ifconfig parameters and if-specific routes:
if_lo="127.0.0.1"
route_lo="add -net 127.0.0.0 netmask 255.0.0.0 lo"
if_eth0="inet 192.168.10.1 netmask 255.255.255.224 broadcast 192.168.10.31"
if_eth0_0="inet 192.168.10.2 netmask 255.255.255.224 broadcast 192.168.10.31"

# Static routing setup:
default_gw="192.168.10.10"
# Specify a list of static routes to add. The actual routing parameters
# for each route shoud be assigned to route_ROUTENAME. 
static_routes="1"
route_1="add -net 192.168.10.0 netmask 255.255.255.224 gw 192.168.10.10 metric 216 reject"

################# !!! NOTHING TO MODIFY BELOW THIS LINE !!! ###################

HOSTNAME=`cat /etc/HOSTNAME`

start() {
  for iface in $if_list
  do
	ifname=`echo $iface|sed 's/_/:/g'`
	eval ifconfig_args=\$if_${iface} 
	if [ -n "${ifconfig_args}" ]; then
		/sbin/ifconfig $ifname $ifconfig_args
	fi
	# Add any special routes if needed
	eval route_args=\$route_${iface}
	if [ -n "$route_args" ]; then
		/sbin/route $route_args
	fi
  done

  if [ "$default_gw" != "" ]; then 
	/sbin/route add default gw $default_gw netmask 0.0.0.0 metric 1
  fi

  for rt in $static_routes
  do
	eval route_args=\$route_${rt}
	if [ -n "${route_args}" ]; then
		/sbin/route $route_args
	fi
  done
}

stop() {
  for iface in $if_list
  do
	ifname=`echo $iface|sed 's/_/:/g'`
	/sbin/ifconfig $ifname down
  done
}

case ${1:-start} in
start)	start;;
stop)	stop;;
*)	echo "usage: $0 {start|stop}" >&2
esac

# EOF

Return to:

Send suggestions and report system problems to the System administrator.