version 1.179, 2017/04/30 19:37:13 |
version 1.180, 2017/05/01 14:23:29 |
|
|
inet6) ((${#_c[*]} > 1)) || return |
inet6) ((${#_c[*]} > 1)) || return |
if [[ ${_c[_name]} == autoconf ]]; then |
if [[ ${_c[_name]} == autoconf ]]; then |
_cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]}" |
_cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]}" |
rtsolif="$rtsolif $_if" |
V6_AUTOCONF=true |
return |
return |
fi |
fi |
[[ ${_c[_name]} == alias ]] && _prefix=3 |
[[ ${_c[_name]} == alias ]] && _prefix=3 |
|
|
;; |
;; |
dhcp) _c[0]= |
dhcp) _c[0]= |
_cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} down;dhclient $_if" |
_cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} down;dhclient $_if" |
dhcpif="$dhcpif $_if" |
V4_DHCPCONF=true |
;; |
;; |
rtsol) # XXX Support the rtsol keyword for some time to enable a smooth |
rtsol) # XXX Support the rtsol keyword for some time to enable a smooth |
# XXX transition to autoconf. |
# XXX transition to autoconf. |
_c[0]= |
_c[0]= |
_cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} up" |
_cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} up" |
_cmds[${#_cmds[*]}]="ifconfig $_if inet6 autoconf" |
_cmds[${#_cmds[*]}]="ifconfig $_if inet6 autoconf" |
rtsolif="$rtsolif $_if" |
V6_AUTOCONF=true |
;; |
;; |
'!'*) _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g') |
'!'*) _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g') |
_cmds[${#_cmds[*]}]="${_cmd#!}" |
_cmds[${#_cmds[*]}]="${_cmd#!}" |
|
|
done |
done |
} |
} |
|
|
# IPv6 autoconf the interfaces in the $rtsolif list. |
|
# Usage: ifv6autoconf |
|
ifv6autoconf() { |
|
local _if |
|
|
|
# $ip6kernel will not have been set if we were invoked with a |
|
# list of interface names |
|
ifconfig lo0 inet6 >/dev/null 2>&1 || return 0 |
|
|
|
for _if in $rtsolif; do |
|
ifconfig $_if inet6 autoconf |
|
done |
|
} |
|
|
|
# Parse /etc/mygate and add default routes for IPv4 and IPv6 |
# Parse /etc/mygate and add default routes for IPv4 and IPv6 |
# Usage: defaultroute |
# Usage: defaultroute |
defaultroute() { |
defaultroute() { |
[[ -z $dhcpif ]] && stripcom /etc/mygate | while read gw; do |
! $V4_DHCPCONF && stripcom /etc/mygate | |
[[ $gw == @(*:*) ]] && continue |
while read gw; do |
route -qn add -host default $gw && break |
[[ $gw == @(*:*) ]] && continue |
|
route -qn add -host default $gw && break |
done |
done |
[[ -z $rtsolif ]] && stripcom /etc/mygate | while read gw; do |
! $V6_AUTOCONF && stripcom /etc/mygate | |
[[ $gw == !(*:*) ]] && continue |
while read gw; do |
route -qn add -host -inet6 default $gw && break |
[[ $gw == !(*:*) ]] && continue |
|
route -qn add -host -inet6 default $gw && break |
done |
done |
} |
} |
|
|
|
|
HN_DIR=${HN_DIR:-/etc} |
HN_DIR=${HN_DIR:-/etc} |
PRINT_ONLY=false |
PRINT_ONLY=false |
USAGE="USAGE: ${0##*/} [-n] [interface ...]" |
USAGE="USAGE: ${0##*/} [-n] [interface ...]" |
|
V4_DHCPCONF=false |
|
V6_AUTOCONF=false |
|
|
while getopts ":n" opt; do |
while getopts ":n" opt; do |
case $opt in |
case $opt in |
n) PRINT_ONLY=true;; |
n) PRINT_ONLY=true;; |
|
|
# interfaces (or bridges), add default routes and return. |
# interfaces (or bridges), add default routes and return. |
if (($# > 0)); then |
if (($# > 0)); then |
for _if; do ifstart $_if; done |
for _if; do ifstart $_if; done |
ifv6autoconf |
|
defaultroute |
defaultroute |
return |
return |
fi |
fi |
|
|
# Due to rare use of IPv4 compatible addresses, and security issues |
# Due to rare use of IPv4 compatible addresses, and security issues |
# with it, we disable it by default. |
# with it, we disable it by default. |
route -qn add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject >/dev/null |
route -qn add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject >/dev/null |
|
|
rtsolif="" |
|
else |
else |
ip6kernel=NO |
ip6kernel=NO |
fi |
fi |
|
|
# The (s)vlan interfaces need to come up after trunk. |
# The (s)vlan interfaces need to come up after trunk. |
# Configure all the carp interfaces which we know about before default route. |
# Configure all the carp interfaces which we know about before default route. |
ifmstart "trunk svlan vlan carp" |
ifmstart "trunk svlan vlan carp" |
|
|
# Now that $rtsolif has been populated, IPv6 autoconf those interfaces |
|
ifv6autoconf |
|
|
|
# Look for default routes in /etc/mygate. |
# Look for default routes in /etc/mygate. |
defaultroute |
defaultroute |