2002-07-18 05:00:17 +00:00
|
|
|
#!/bin/sh
|
1997-04-27 03:59:19 +00:00
|
|
|
#
|
2002-07-18 05:00:17 +00:00
|
|
|
# Configure routing and miscellaneous network tunables
|
2000-10-08 19:20:36 +00:00
|
|
|
#
|
1999-08-27 23:37:10 +00:00
|
|
|
# $FreeBSD$
|
2000-10-08 19:20:36 +00:00
|
|
|
#
|
1997-04-27 03:59:19 +00:00
|
|
|
|
2003-06-29 05:09:48 +00:00
|
|
|
# PROVIDE: routing
|
2008-06-05 17:26:47 +00:00
|
|
|
# REQUIRE: netif ppp
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2001-06-03 12:26:56 +00:00
|
|
|
|
2002-07-18 05:00:17 +00:00
|
|
|
. /etc/rc.subr
|
2008-05-18 02:57:54 +00:00
|
|
|
. /etc/network.subr
|
1999-09-13 15:44:20 +00:00
|
|
|
|
2003-06-29 05:09:48 +00:00
|
|
|
name="routing"
|
|
|
|
start_cmd="routing_start"
|
|
|
|
stop_cmd="routing_stop"
|
|
|
|
extra_commands="options static"
|
|
|
|
static_cmd="static_start"
|
|
|
|
options_cmd="options_start"
|
1999-12-12 01:58:30 +00:00
|
|
|
|
2003-06-29 05:09:48 +00:00
|
|
|
routing_start()
|
|
|
|
{
|
2009-09-12 22:13:41 +00:00
|
|
|
static_start "$@"
|
|
|
|
options_start "$@"
|
2003-06-29 05:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
routing_stop()
|
|
|
|
{
|
2009-09-12 22:13:41 +00:00
|
|
|
static_stop "$@"
|
2003-06-29 05:09:48 +00:00
|
|
|
route -n flush
|
2009-09-12 22:13:41 +00:00
|
|
|
for i in ${ipv6_network_interfaces}; do
|
|
|
|
ifconfig $i inet6 -defaultif
|
|
|
|
done
|
2003-06-29 05:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static_start()
|
2002-07-18 05:00:17 +00:00
|
|
|
{
|
2009-09-12 22:13:41 +00:00
|
|
|
local _af
|
|
|
|
_af=$1
|
|
|
|
|
|
|
|
case ${_af} in
|
|
|
|
inet)
|
|
|
|
do_static inet add
|
|
|
|
;;
|
|
|
|
inet6)
|
|
|
|
do_static inet6 add
|
|
|
|
;;
|
|
|
|
atm)
|
|
|
|
do_static atm add
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
do_static inet add
|
|
|
|
do_static inet6 add
|
|
|
|
do_static atm add
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
static_stop()
|
|
|
|
{
|
|
|
|
local _af
|
|
|
|
_af=$1
|
|
|
|
|
|
|
|
case ${_af} in
|
|
|
|
inet)
|
|
|
|
do_static inet delete
|
|
|
|
;;
|
|
|
|
inet6)
|
|
|
|
do_static inet6 delete
|
|
|
|
;;
|
|
|
|
atm)
|
|
|
|
do_static atm delete
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
do_static inet delete
|
|
|
|
do_static inet6 delete
|
|
|
|
do_static atm delete
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
do_static()
|
|
|
|
{
|
|
|
|
local _af _action
|
|
|
|
_af=$1
|
|
|
|
_action=$2
|
|
|
|
|
|
|
|
eval $1_static $2
|
|
|
|
}
|
|
|
|
|
|
|
|
inet_static()
|
|
|
|
{
|
|
|
|
local _action
|
|
|
|
_action=$1
|
|
|
|
|
1999-09-13 15:44:20 +00:00
|
|
|
case ${defaultrouter} in
|
|
|
|
[Nn][Oo] | '')
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
static_routes="default ${static_routes}"
|
|
|
|
route_default="default ${defaultrouter}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ -n "${static_routes}" ]; then
|
|
|
|
for i in ${static_routes}; do
|
2009-09-12 22:13:41 +00:00
|
|
|
route_args=`get_if_var $i route_IF`
|
|
|
|
route ${_action} ${route_args}
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
inet6_static()
|
|
|
|
{
|
|
|
|
local _action i
|
|
|
|
_action=$1
|
|
|
|
|
|
|
|
# disallow "internal" addresses to appear on the wire
|
|
|
|
route ${_action} -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
|
|
|
|
route ${_action} -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
|
|
|
|
|
|
|
|
case ${ipv6_defaultrouter} in
|
|
|
|
[Nn][Oo] | '')
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
ipv6_static_routes="default ${ipv6_static_routes}"
|
|
|
|
ipv6_route_default="default ${ipv6_defaultrouter}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ -n "${ipv6_static_routes}" ]; then
|
|
|
|
for i in ${ipv6_static_routes}; do
|
|
|
|
ipv6_route_args=`get_if_var $i ipv6_route_IF`
|
2009-09-13 20:19:02 +00:00
|
|
|
route ${_action} -inet6 ${ipv6_route_args}
|
2009-09-12 22:13:41 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Fixup $ipv6_network_interfaces
|
|
|
|
case ${ipv6_network_interfaces} in
|
|
|
|
[Nn][Oo][Nn][Ee])
|
|
|
|
ipv6_network_interfaces=''
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if checkyesno ipv6_gateway_enable; then
|
|
|
|
for i in ${ipv6_network_interfaces}; do
|
|
|
|
|
|
|
|
laddr=`network6_getladdr $i exclude_tentative`
|
|
|
|
case ${laddr} in
|
|
|
|
'')
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
ipv6_working_interfaces="$i \
|
|
|
|
${ipv6_working_interfaces}"
|
|
|
|
;;
|
|
|
|
esac
|
1999-09-13 15:44:20 +00:00
|
|
|
done
|
2009-09-12 22:13:41 +00:00
|
|
|
ipv6_network_interfaces=${ipv6_working_interfaces}
|
1999-09-13 15:44:20 +00:00
|
|
|
fi
|
2009-09-12 22:13:41 +00:00
|
|
|
|
|
|
|
# Install the "default interface" to kernel, which will be used
|
|
|
|
# as the default route when there's no router.
|
|
|
|
case "${ipv6_default_interface}" in
|
|
|
|
[Nn][Oo] | [Nn][Oo][Nn][Ee])
|
|
|
|
ipv6_default_interface=""
|
|
|
|
;;
|
|
|
|
[Aa][Uu][Tt][Oo] | "")
|
|
|
|
for i in ${ipv6_network_interfaces}; do
|
|
|
|
case $i in
|
|
|
|
lo0|faith[0-9]*)
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
laddr=`network6_getladdr $i exclude_tentative`
|
|
|
|
case ${laddr} in
|
|
|
|
'')
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
ipv6_default_interface=$i
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Disallow unicast packets without outgoing scope identifiers,
|
|
|
|
# or route such packets to a "default" interface, if it is specified.
|
|
|
|
route ${_action} -inet6 fe80:: -prefixlen 10 ::1 -reject
|
|
|
|
|
|
|
|
case ${ipv6_default_interface} in
|
|
|
|
'')
|
|
|
|
route ${_action} -inet6 ff02:: -prefixlen 16 ::1 -reject
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
laddr=`network6_getladdr ${ipv6_default_interface}`
|
|
|
|
route ${_action} -inet6 ff02:: ${laddr} -prefixlen 16 -interface
|
|
|
|
|
|
|
|
# Disable installing the default interface with the
|
|
|
|
# case net.inet6.ip6.forwarding=0 and
|
|
|
|
# the interface with no ND6_IFF_ACCEPT_RTADV
|
|
|
|
# to avoid conflict between the default router list and
|
|
|
|
# the manual configured default route.
|
|
|
|
if ! checkyesno ipv6_gateway_enable; then
|
|
|
|
ifconfig ${ipv6_default_interface} nd6 | \
|
|
|
|
while read proto options
|
|
|
|
do
|
|
|
|
case "${proto}:${options}" in
|
|
|
|
nd6:*ACCEPT_RTADV*)
|
|
|
|
ifconfig ${ipv6_default_interface} inet6 defaultif
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
atm_static()
|
|
|
|
{
|
|
|
|
local _action i
|
|
|
|
_action=$1
|
|
|
|
|
2003-08-14 15:27:32 +00:00
|
|
|
if [ -n "${natm_static_routes}" ]; then
|
|
|
|
for i in ${natm_static_routes}; do
|
2009-09-12 22:13:41 +00:00
|
|
|
route_args=`get_if_var $i route_IF`
|
|
|
|
atmconfig natm ${_action} ${route_args}
|
2003-08-14 15:27:32 +00:00
|
|
|
done
|
|
|
|
fi
|
2003-06-29 05:09:48 +00:00
|
|
|
}
|
1999-09-13 15:44:20 +00:00
|
|
|
|
2008-06-23 04:00:45 +00:00
|
|
|
_ropts_initdone=
|
|
|
|
ropts_init()
|
|
|
|
{
|
|
|
|
if [ -z "${_ropts_initdone}" ]; then
|
|
|
|
echo -n 'Additional routing options:'
|
|
|
|
_ropts_initdone=yes
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2003-06-29 05:09:48 +00:00
|
|
|
options_start()
|
|
|
|
{
|
2009-09-12 22:13:41 +00:00
|
|
|
if checkyesno icmp_bmcastecho; then
|
2008-06-23 04:00:45 +00:00
|
|
|
ropts_init
|
1999-09-13 15:44:20 +00:00
|
|
|
echo -n ' broadcast ping responses=YES'
|
2001-12-11 08:21:46 +00:00
|
|
|
sysctl net.inet.icmp.bmcastecho=1 >/dev/null
|
2009-09-12 22:13:41 +00:00
|
|
|
fi
|
1999-09-13 15:44:20 +00:00
|
|
|
|
2009-09-12 22:13:41 +00:00
|
|
|
if checkyesno icmp_drop_redirect; then
|
2008-06-23 04:00:45 +00:00
|
|
|
ropts_init
|
1999-09-13 15:44:20 +00:00
|
|
|
echo -n ' ignore ICMP redirect=YES'
|
2001-12-11 08:21:46 +00:00
|
|
|
sysctl net.inet.icmp.drop_redirect=1 >/dev/null
|
2009-09-12 22:13:41 +00:00
|
|
|
fi
|
1999-09-13 15:44:20 +00:00
|
|
|
|
2009-09-12 22:13:41 +00:00
|
|
|
if checkyesno icmp_log_redirect; then
|
2008-06-23 04:00:45 +00:00
|
|
|
ropts_init
|
1999-09-13 15:44:20 +00:00
|
|
|
echo -n ' log ICMP redirect=YES'
|
2001-12-11 08:21:46 +00:00
|
|
|
sysctl net.inet.icmp.log_redirect=1 >/dev/null
|
2009-09-12 22:13:41 +00:00
|
|
|
fi
|
1999-09-13 15:44:20 +00:00
|
|
|
|
2009-09-12 22:13:41 +00:00
|
|
|
if checkyesno gateway_enable; then
|
2008-06-23 04:00:45 +00:00
|
|
|
ropts_init
|
2009-09-12 22:13:41 +00:00
|
|
|
echo -n ' IPv4 gateway=YES'
|
2001-12-11 08:21:46 +00:00
|
|
|
sysctl net.inet.ip.forwarding=1 >/dev/null
|
2009-09-12 22:13:41 +00:00
|
|
|
fi
|
1999-09-13 15:44:20 +00:00
|
|
|
|
2009-09-12 22:13:41 +00:00
|
|
|
if checkyesno ipv6_gateway_enable; then
|
|
|
|
ropts_init
|
|
|
|
echo -n ' IPv6 gateway=YES'
|
|
|
|
sysctl net.inet6.ip6.forwarding=1 >/dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
if checkyesno forward_sourceroute; then
|
2008-06-23 04:00:45 +00:00
|
|
|
ropts_init
|
1999-09-13 15:44:20 +00:00
|
|
|
echo -n ' do source routing=YES'
|
2001-12-11 08:21:46 +00:00
|
|
|
sysctl net.inet.ip.sourceroute=1 >/dev/null
|
2009-09-12 22:13:41 +00:00
|
|
|
fi
|
1999-09-13 15:44:20 +00:00
|
|
|
|
2009-09-12 22:13:41 +00:00
|
|
|
if checkyesno accept_sourceroute; then
|
2008-06-23 04:00:45 +00:00
|
|
|
ropts_init
|
1999-09-13 15:44:20 +00:00
|
|
|
echo -n ' accept source routing=YES'
|
2001-12-11 08:21:46 +00:00
|
|
|
sysctl net.inet.ip.accept_sourceroute=1 >/dev/null
|
2009-09-12 22:13:41 +00:00
|
|
|
fi
|
1999-09-13 15:44:20 +00:00
|
|
|
|
2009-09-12 22:13:41 +00:00
|
|
|
if checkyesno ipxgateway_enable; then
|
2008-06-23 04:00:45 +00:00
|
|
|
ropts_init
|
1999-09-13 15:44:20 +00:00
|
|
|
echo -n ' IPX gateway=YES'
|
2001-12-11 08:21:46 +00:00
|
|
|
sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null
|
2009-09-12 22:13:41 +00:00
|
|
|
fi
|
1999-09-13 15:44:20 +00:00
|
|
|
|
2009-09-12 22:13:41 +00:00
|
|
|
if checkyesno arpproxy_all; then
|
2008-06-23 04:00:45 +00:00
|
|
|
ropts_init
|
1999-09-13 15:44:20 +00:00
|
|
|
echo -n ' ARP proxyall=YES'
|
2001-12-11 08:21:46 +00:00
|
|
|
sysctl net.link.ether.inet.proxyall=1 >/dev/null
|
2009-09-12 22:13:41 +00:00
|
|
|
fi
|
2000-06-22 17:40:53 +00:00
|
|
|
|
2008-06-23 04:00:45 +00:00
|
|
|
[ -n "${_ropts_initdone}" ] && echo '.'
|
1997-04-27 03:59:19 +00:00
|
|
|
}
|
|
|
|
|
2002-07-18 05:00:17 +00:00
|
|
|
load_rc_config $name
|
2009-09-12 22:13:41 +00:00
|
|
|
run_rc_command "$@"
|