if [ -z "$defrouters" ]; then
#
# Determine how many active interfaces there are and how many pt-pt
# interfaces. Act as an IPv4 router if there are more than 2 interfaces
# (including the loopback interface) or one or more point-point
# interface. Also act as an IPv4 router if /etc/gateways exists.
#
# Do NOT act as an IPv4 router if /etc/notrouter exists.
# Do NOT act as an IPv4 router if DHCP was used to configure
# interface(s)
#
inetifaddrs="`/usr/sbin/ifconfig -a4u | /usr/bin/grep inet`"
numifs=`echo "$inetifaddrs" | /usr/bin/wc -l`
numptptifs=`echo "$inetifaddrs" | /usr/bin/egrep -c -e '-->'`
if [ "$_INIT_NET_STRATEGY" = "dhcp" ]; then
numdhcp=`/usr/sbin/ifconfig -a4 | /usr/bin/grep -c DHCP`
else
numdhcp=0
fi
if [ ! -f /etc/notrouter -a $numdhcp -eq 0 -a \
\( $numifs -gt 2 -o $numptptifs -gt 0 -o -f /etc/gateways \) ]; then
#
# Machine is an IPv4 router: turn on ip_forwarding, run
# in.routed, and advertise ourselves as a router using router
# discovery.
#
echo 'Machine is an IPv4 router.'
/usr/sbin/ndd -set /dev/ip ip_forwarding 1
[ -f /usr/sbin/in.routed ] && /usr/sbin/in.routed -s
[ -f /usr/sbin/in.rdisc ] && /usr/sbin/in.rdisc -r
else
#
# Machine is an IPv4 host: if router discovery finds a router
# then we rely on router discovery. If there are no routers
# advertising themselves through router discovery
# run in.routed in quiet mode. In both cases, turn off
# ip_forwarding.
#
/usr/sbin/ndd -set /dev/ip ip_forwarding 0
if [ -f /usr/sbin/in.rdisc ] && /usr/sbin/in.rdisc -s; then
echo 'Starting IPv4 router discovery.'
elif [ -f /usr/sbin/in.routed ]; then
/usr/sbin/in.routed -q
echo 'Starting IPv4 routing daemon.'
fi
fi
else
/usr/sbin/ndd -set /dev/ip ip_forwarding 0
fi